Web SDK Reference
Initialization
Section titled “Initialization”.initialize
Section titled “.initialize”Initializes the SDK.
Params
- options: InitializeOptions
- projectId
- (optional) serviceWorkerPath
FlareLane.initialize({ projectId: "<PROJECT_ID>", serviceWorkerPath: "/sw.js" // optional});.setLogLevel
Section titled “.setLogLevel”Sets the SDK's log level.
Params
- logLevel: 'none' | 'error' | 'verbose'
- none: nothing
- error: errors only
- verbose: everything (default)
FlareLane.setLogLevel('verbose');Notification Subscription
Section titled “Notification Subscription”.getIsSubscribed
Section titled “.getIsSubscribed”Checks whether the current device is subscribed.
Params
- callback: (Boolean) => {}
FlareLane.getIsSubscribed((isSubscribed) => { // Do something... console.log(isSubscribed);});.setIsSubscribed
Section titled “.setIsSubscribed”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);};
// SUBSCRIBEFlareLane.setIsSubscribed(true, callback);// UNSUBSCRIBEFlareLane.setIsSubscribed(false, callback);Customer Data Integration
Section titled “Customer Data Integration”.setUserId
Section titled “.setUserId”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
// SETFlareLane.setUserId("USER_ID");// REMOVEFlareLane.setUserId(null);.trackEvent
Section titled “.trackEvent”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');// ORFlareLane.trackEvent('test_event', { "dataKey": "dataValue" });.setTags
Section titled “.setTags”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>
// SETFlareLane.setTags({ gender: "men", age: 24 });.setUserAttributes
Section titled “.setUserAttributes”Applies a user profile.
Params
- userAttributes: Record<string, string>
// SETFlareLane.setUserAttributes({ "name": "John Smith", "phoneNumber": "+12025550123", "dob": "1992-03-01", "email": "kevin@flarelane.com", "country": "US", "language": "en", "timeZone": "America/New_York"});.getDeviceId
Section titled “.getDeviceId”Retrieves the FlareLane device ID of the current device.
Params
- callback: (string | null) => {}
FlareLane.getDeviceId((deviceId) => { // Do something... console.log(deviceId); });Notification Handlers
Section titled “Notification Handlers”.setConvertedHandler
Section titled “.setConvertedHandler”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); });In-App Messages
Section titled “In-App Messages”.displayInApp
Section titled “.displayInApp”Displays the highest-priority in-app message from a specific group that the current device is eligible to show.
FlareLane.displayInApp("home");.setInAppMessageActionHandler
Section titled “.setInAppMessageActionHandler”Define your own handler to process custom actions triggered by in-app messages.
FlareLane.setInAppMessageActionHandler((iam, actionId) => { // Do Something...});