Skip to main content

Notifizz Node.js SDK

The @notifizz/nodejs package is the official JavaScript/TypeScript client for Notifizz. Use it to track events, run workflows, generate hashed user tokens, and send notifications to the Notification Center.

Installation

npm install @notifizz/nodejs
Or with Yarn:
yarn add @notifizz/nodejs

Initialize the client

const { NotifizzClient } = require("@notifizz/nodejs");
// or ESM: import { NotifizzClient } from "@notifizz/nodejs";

const client = new NotifizzClient(
  "AUTH_SECRET_KEY",  // provided by Notifizz
  "SDK_SECRET_KEY"    // provided by Notifizz
);

Track events with workflows

Start tracking an event with track(), then attach one or more workflows and recipients. The context auto-sends after a short delay (configurable via config), or you can await it like a promise:
await client
  .track({
    eventName: "user_signed_up", // slug provided by notifizz's interface
    sdkSecretKey: "SDK_SECRET_KEY",
    properties: {
      plan: "pro",
      source: "landing_page",
    },
  })
  .workflow("campaign_123", [ // slug provided by notifizz's interface
    { id: "user_1", email: "user1@example.com" },
    { id: "user_2", email: "user2@example.com" },
  ]);
You can chain multiple .workflow(campaignId, recipients) calls before the event is sent.

Generate a hashed user token

Use this for backend authentication (e.g. when the Notification Center is authenticated with a backend token):
const token = client.generateHashedToken("user_123");

Configuration

Configure client options such as the auto-send delay for tracked events:
client.config({ autoSendDelayMs: 2000 });
You can pass a single workflow ID or an array of workflow IDs.

API summary

MethodDescription
new NotifizzClient(authSecretKey, sdkSecretKey)Create a client.
client.track({ eventName, sdkSecretKey, properties })Start tracking an event; returns a context.
context.workflow(campaignId, recipients)Attach a workflow and recipients (chainable).
client.generateHashedToken(userId)Generate a hashed token for the user.
client.send({ notifId, properties })Send a notification to the Notification Center.
client.config({ autoSendDelayMs })Configure options (e.g. auto-send delay in ms).