Skip to content

Web SDK Reference

Initializes the SDK.

Params

  • options: InitializeOptions
    • projectId
    • (optional) serviceWorkerPath
FlareLane.initialize({
projectId: "<PROJECT_ID>",
serviceWorkerPath: "/sw.js" // optional
});

Sets the SDK's log level.

Params

  • logLevel: 'none' | 'error' | 'verbose'
    • none: nothing
    • error: errors only
    • verbose: everything (default)
FlareLane.setLogLevel('verbose');

Checks whether the current device is subscribed.

Params

  • callback: (Boolean) => {}
FlareLane.getIsSubscribed((isSubscribed) => {
// Do something...
console.log(isSubscribed);
});

Sets the subscription status of the current device.

Use this when you want to manage the subscription status directly, for example through a settings UI within your service.

When set to true, the entire permission flow required for subscription is triggered in a single step.

Params

  • isSubscribed: Boolean
  • callback: (Boolean) => {}
const callback = (isSubscribed) => {
// Do something...
console.log(isSubscribed);
};
// SUBSCRIBE
FlareLane.setIsSubscribed(true, callback);
// UNSUBSCRIBE
FlareLane.setIsSubscribed(false, callback);

Sets the user ID on the current device. Typically, you update the user ID upon a successful sign-up or login.

Params

  • userId: string | null
// SET
FlareLane.setUserId("USER_ID");
// REMOVE
FlareLane.setUserId(null);

Triggers an event. If the device has a user ID, the event is applied to the user; otherwise, it is applied to the individual device.

Params

  • type: string
  • (optional) data: Record<string, string | number>
FlareLane.trackEvent('test_event');
// OR
FlareLane.trackEvent('test_event', { "dataKey": "dataValue" });

Applies tags. If the device has a user ID, the tags are applied to the user; otherwise, they are applied to the individual device.

Params

  • tags: Record<string, string | number>
// SET
FlareLane.setTags({ gender: "men", age: 24 });

Applies a user profile.

Params

  • userAttributes: Record<string, string>
// SET
FlareLane.setUserAttributes({
"name": "John Smith",
"phoneNumber": "+12025550123",
"dob": "1992-03-01",
"email": "kevin@flarelane.com",
"country": "US",
"language": "en",
"timeZone": "America/New_York"
});

Retrieves the FlareLane device ID of the current device.

Params

  • callback: (string | null) => {}
FlareLane.getDeviceId((deviceId) => {
// Do something...
console.log(deviceId);
});

Registers a callback handler to run when a user enters your service after clicking a notification.

Params

  • callback: (Notification) => {}
FlareLane.setConvertedHandler((notification) => {
// Do something...
console.log(notification);
});

Displays the highest-priority in-app message from a specific group that the current device is eligible to show.

FlareLane.displayInApp("home");

Define your own handler to process custom actions triggered by in-app messages.

FlareLane.setInAppMessageActionHandler((iam, actionId) => {
// Do Something...
});