@trycourier/courier-js
v1.4.2Overview
SDK used by client applications to interface with the Courier API.
Requirements | |
---|---|
Courier Account |
Sign Up
|
Client API Key |
Get key
|
Supported Interfaces
Feature | Description |
---|---|
Identify
|
Event that triggers a user Create or Update within Courier Profiles.
|
Track
|
Event ingested by Courier can be used to trigger an automation or supply inline payloads within an existing automation workflow. |
GeneratePreferencesUrl
|
Generates URL that can be used to link users to Preferences Center to manage their notification preferences. |
Installation
# npm
npm install @trycourier/courier-js
# yarn
yarn add @trycourier/courier-js
# pnpm
pnpm add @trycourier/courier-js
Usage
Initializing Client
import courier from "@trycourier/courier-js";
courier.init({
clientKey: "<REPLACE_WITH_YOUR_CLIENT_KEY>",
debug: true, // debug enables client side logs for error catching
});
Identify
await courierSDK.identify("purbleUserId", {
email: "[email protected]",
favoriteColor: "purple",
});
Track
Basic
await courierSDK.track("user-signup");
With data payload
await courierSDK.track("bake-cake", {
cakeFlavor: "carrot",
frosting: "cream cheese"
});
GeneratePreferencesUrl
const prefCenterLink = courier.generatePreferencesUrl("<user-id>", {
// optional
brandId: "<brand-id>",
});
Share feedback with Courier
We are building the best SDKs for handling notifications! Have an idea or feedback about our SDKs? Here are some links to contact us: