NotificationEvents

Events

Lifecycle event bus and timeline store

Events

Subscribe to lifecycle events and build a per-message timeline.

import { NotificationEventBus, MemoryEventStore } from "@visulima/notification/events";

const bus = new NotificationEventBus();
const store = new MemoryEventStore();

bus.on("sent", (event) => console.log("sent", event.messageId));
bus.on("failed", (event) => console.error("failed", event.messageId));
bus.on("*", (event) => store.append(event)); // wildcard: every event

bus.emit({ type: "sent", messageId: "m1", channel: "sms", provider: "twilio", timestamp: new Date() });

await store.timeline("m1"); // ordered events for message m1

Event types

queued, sent, delivered, failed, bounced, read, clicked, interacted.

Provider webhooks can be normalised into these events via a provider's optional parseEventBody(body, headers) method, then fed to the bus and store.

Custom store

Implement EventStore (append / timeline) to persist events in your database.

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues