Skip to main content
Version: Browser SDK

Reference

Complete reference for @screeb/sdk-browser.

New to Screeb? Start with the Install guide.

Methods

All methods return a Promise and can be awaited.

MethodDescriptionMore
load()Loads the Screeb SDK script asynchronously.👉
init(channelId, userId?, properties?, hooks?, language?)Initializes the SDK and starts a session.👉
close()Shuts down the Screeb SDK.👉
debug()Prints current SDK configuration (channel id, user id, session...).👉
targetingDebug()Prints survey targeting rules for the current user.👉
identity(userId, properties?)Identifies the current user.👉
identityProperties(properties)Updates user properties.👉
identityGroupAssign(groupName, groupType?, groupProperties?)Assigns the user to a segment.👉
identityGroupUnassign(groupName, groupType?)Removes the user from a segment.👉
identityReset()Resets the current user to anonymous.👉
identityGet()Returns the current user identity.👉
eventTrack(name, properties?)Tracks a user event.👉
surveyStart(surveyId, distributionId?, allowMultiple?, hiddenFields?, hooks?, language?, selectors?)Starts a survey programmatically.👉
surveyClose()Closes a running survey.👉
messageStart(messageId, allowMultiple?, hiddenFields?, hooks?, language?)Starts a message programmatically.👉
messageClose()Closes a running message.👉
sessionReplayStart()Starts a session replay.-
sessionReplayStop()Stops the current session replay.-
targetingCheck()Forces a targeting check.-

Type definitions

type PropertyType = number | boolean | string | Date | PropertyRecord;

type PropertyRecord = {
[key: string]: PropertyType | PropertyType[];
};

interface HooksInit {
version?: string;
onReady?: (payload: any) => void;
onSurveyShowed?: (payload: any) => void;
onSurveyStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onSurveyCompleted?: (payload: any) => void;
onSurveyHidden?: (payload: any) => void;
onMessageShowed?: (payload: any) => void;
onMessageStarted?: (payload: any) => void;
onMessageCompleted?: (payload: any) => void;
onMessageHidden?: (payload: any) => void;
onSurveyDisplayAllowed?: (payload: any) => boolean;
onMessageDisplayAllowed?: (payload: any) => boolean;
}

interface HooksSurveyStart {
onSurveyShowed?: (payload: any) => void;
onSurveyStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onSurveyCompleted?: (payload: any) => void;
onSurveyHidden?: (payload: any) => void;
}

interface HooksMessageStart {
onMessageShowed?: (payload: any) => void;
onMessageStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onMessageCompleted?: (payload: any) => void;
onMessageHidden?: (payload: any) => void;
}

For complete hook payload definitions, see the JS tag hooks reference.