Skip to content
Open Screeb

Every public method of @screeb/sdk-svelte, with its signature.

Complete reference for @screeb/sdk-svelte. New to Screeb? Start with the install guide.

Pass these options to setScreebContext(options) in your root component.

Option Type Required Description
websiteId string Yes Your website/channel id.
userId string No The unique identifier of your user.
userProperties PropertyRecord No The properties of your user.
hooks HooksInit No Hooks to define callbacks for Screeb events.
language string No Force a specific language (for example, “en”).
shouldLoad boolean No Indicates if Screeb should be automatically loaded.
autoInit boolean No Indicates if Screeb should be automatically initialized after load.
options ScreebOptions No Screeb tag loading options.
Method Description More
init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => Promise<void> Initialize the Screeb SDK. Guide
load(options?: ScreebOptions) => Promise<void> Load the Screeb tag. Guide
close() => Promise<void> Stop the SDK. Guide
Method Description More
identity(userId: string, userProperties?: PropertyRecord) => Promise<unknown> Identify the current user with optional properties. Guide
identityProperties(userProperties: PropertyRecord) => Promise<unknown> Send visitor properties without changing the identity. Guide
identityReset() => Promise<unknown> Reset the current visitor identity. Guide
setAnonymousId(anonymousId: string) => Promise<unknown> Tell Screeb which anonymous id your CDP already uses for the current visitor. Guide
identityGet() => Promise<ScreebIdentityGetReturn> Get the current visitor identity and properties. Guide
Method Description More
identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord) => Promise<unknown> Assign the current user to a group. Guide
identityGroupUnassign(groupName: string, groupType?: string) => Promise<unknown> Remove the current user from a group. Guide
Method Description More
eventTrack(eventName: string, eventProperties?: PropertyRecord) => Promise<unknown> Track a custom event. Guide
Method Description More
surveyStart(surveyId: string, distributionId?: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]) => Promise<unknown> Start a specific survey programmatically. Guide
surveyClose() => Promise<unknown> Close the currently displayed survey. Guide
Method Description More
messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string) => Promise<unknown> Start a specific message programmatically. Guide
messageClose() => Promise<unknown> Close the currently displayed message. Guide
Method Description More
sessionReplayStart() => Promise<unknown> Start session replay recording. Guide
sessionReplayStop() => Promise<unknown> Stop session replay recording. Guide
Method Description More
debug() => Promise<unknown> Get SDK debug information. Guide
targetingDebug() => Promise<unknown> Get targeting debug information. Guide
Method Description More
ScreebMaskText<T extends Element>(element: T) => T Mask a view or component in session replay. Guide
ScreebNoCapture<T extends Element>(element: T) => T Exclude a view or component from session replay capture. Guide
ScreebId<T extends Element>(element: T, id: string) => T Set a stable Screeb element ID for IAM targeting. Guide
init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => Promise<void>;
load(options?: ScreebOptions) => Promise<void>;
close() => Promise<void>;
identity(userId: string, userProperties?: PropertyRecord) => Promise<unknown>;
identityProperties(userProperties: PropertyRecord) => Promise<unknown>;
identityReset() => Promise<unknown>;
setAnonymousId(anonymousId: string) => Promise<unknown>;
identityGet() => Promise<ScreebIdentityGetReturn>;
identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord) => Promise<unknown>;
identityGroupUnassign(groupName: string, groupType?: string) => Promise<unknown>;
eventTrack(eventName: string, eventProperties?: PropertyRecord) => Promise<unknown>;
surveyStart(surveyId: string, distributionId?: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]) => Promise<unknown>;
surveyClose() => Promise<unknown>;
messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string) => Promise<unknown>;
messageClose() => Promise<unknown>;
sessionReplayStart() => Promise<unknown>;
sessionReplayStop() => Promise<unknown>;
debug() => Promise<unknown>;
targetingDebug() => Promise<unknown>;
ScreebMaskText<T extends Element>(element: T) => T;
ScreebNoCapture<T extends Element>(element: T) => T;
ScreebId<T extends Element>(element: T, id: string) => T;
type HookOnReady = (data: { channel: Channel; user: User }) => void;
type HookOnSurveyDisplayAllowed = (
data: HookCommonPropertiesSurvey,
) => boolean;
type HookOnMessageDisplayAllowed = (
data: HookCommonPropertiesSurvey,
) => boolean;
type HookOnSurveyShowed = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnSurveyStarted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
};
},
) => void;
type HookOnSurveyCompleted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnSurveyHidden = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
hide_reason: ResponseStatus;
};
},
) => void;
type HookOnMessageShowed = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnMessageStarted = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
};
},
) => void;
type HookOnMessageCompleted = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnMessageHidden = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
hide_reason: ResponseStatus;
};
},
) => void;
type HookOnQuestionReplied = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
status: null;
question: ResponseItemQuestion;
answer: ResponseItemAnswer;
items: ResponseItem[];
};
},
) => void;
type HookOnButtonNavigateStarted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
};
button: {
url: string;
url_target?: string;
};
},
) => void;
type HookOnButtonNavigateCompleted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
};
button: {
url: string;
url_target?: string;
};
},
) => void;

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

type ScreebConfig = {
websiteId: string;
userId?: string;
userProperties?: PropertyRecord;
hooks?: HooksInit;
language?: string;
shouldLoad?: boolean;
autoInit?: boolean;
options?: ScreebOptions;
};
type ScreebClient = {
close: CloseFunction;
debug: DebugFunction;
eventTrack: EventTrackFunction;
identity: IdentityFunction;
identityGet: IdentityGetFunction;
identityGroupAssign: IdentityGroupAssignFunction;
identityGroupUnassign: IdentityGroupUnassignFunction;
identityProperties: IdentityPropertiesFunction;
identityReset: IdentityResetFunction;
setAnonymousId: SetAnonymousIdFunction;
init: InitFunction;
load: LoadFunction;
messageClose: MessageCloseFunction;
messageStart: MessageStartFunction;
sessionReplayStart: SessionReplayStartFunction;
sessionReplayStop: SessionReplayStopFunction;
surveyClose: SurveyCloseFunction;
surveyStart: SurveyStartFunction;
targetingDebug: TargetingDebugFunction;
ScreebMaskText: ScreebMaskTextFunction;
ScreebNoCapture: ScreebNoCaptureFunction;
ScreebId: ScreebIdFunction;
};
type PropertyType = number | boolean | string | Date | PropertyRecord;
type PropertyRecord = {
[key: string]: PropertyType | PropertyType[];
};
type ScreebEndpoints = {
rpc?: string;
static?: string;
report?: string;
hostedPage?: string;
centipede?: string;
};
type ScreebOptions = {
window?: Window;
sdkName?: string;
sdkVersion?: string;
screebEndpoint?: string;
endpoints?: ScreebEndpoints;
platform?: string;
};
type SpaNavigationHandler = (url: string) => void | Promise<void>;
type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
type ScreebObject = ScreebFunction & {
q?: {
args: unknown[];
ko: (reason?: unknown) => void;
ok: (value?: unknown) => void;
v: number;
}[];
};
type ScreebIdentityGetReturn = {
anonymous_id: string;
user_id: string;
session_id: string;
session_start: string;
session_end: string;
channel_id: string;
is_ready: boolean;
};
type ChannelType = "widget" | "ios" | "android";
type Channel = {
id: string;
type: ChannelType;
};
type User = {
anonymous_id: string;
userId?: string;
};
type SurveyFormat = "conversationnal" | "cards";
type SurveySize = 25 | 50 | 75 | 100 | 125 | 150;
type SurveyPosition =
| "center-left"
| "center-center"
| "center-right"
| "bottom-left"
| "bottom-center"
| "bottom-right";
type Survey = {
id: string;
survey_position: SurveyPosition;
survey_format: SurveyFormat;
survey_size: 100;
};
type Message = {
id: string;
messagey_size: 100;
};
type ResponseStatus =
| "displayed"
| "started"
| "ended"
| "closed"
| "interrupted";
type ResponseItemQuestion = {
id: string;
title: string;
type: "text" | "video";
url?: string;
};
type ResponseItemAnswer = {
replied_at?: string;
fields?: {
type: "string" | "number" | "boolean" | "none" | "time" | "file";
text?: string;
number?: number;
boolean?: boolean;
time?: string;
}[];
};
type ResponseItem = {
question: ResponseItemQuestion;
answer: ResponseItemAnswer;
};
type HookCommonProperties = {
channel: Channel;
user: User;
};
type HookCommonPropertiesSurvey = HookCommonProperties & {
survey: Survey;
};
type HookCommonPropertiesMessage = HookCommonProperties & {
message: Message;
};
type HookOnReady = (data: { channel: Channel; user: User }) => void;
type HookOnSurveyDisplayAllowed = (
data: HookCommonPropertiesSurvey,
) => boolean;
type HookOnMessageDisplayAllowed = (
data: HookCommonPropertiesSurvey,
) => boolean;
type HookOnSurveyShowed = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnSurveyStarted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
};
},
) => void;
type HookOnSurveyCompleted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnSurveyHidden = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
hide_reason: ResponseStatus;
};
},
) => void;
type HookOnMessageShowed = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnMessageStarted = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
};
},
) => void;
type HookOnMessageCompleted = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
type HookOnMessageHidden = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
hide_reason: ResponseStatus;
};
},
) => void;
type HookOnQuestionReplied = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
status: null;
question: ResponseItemQuestion;
answer: ResponseItemAnswer;
items: ResponseItem[];
};
},
) => void;
type HookOnButtonNavigateStarted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
};
button: {
url: string;
url_target?: string;
};
},
) => void;
type HookOnButtonNavigateCompleted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
};
button: {
url: string;
url_target?: string;
};
},
) => void;
type HooksSurveyStart = {
onSurveyShowed?: HookOnSurveyShowed;
onSurveyStarted?: HookOnSurveyStarted;
onSurveyCompleted?: HookOnSurveyCompleted;
onSurveyHidden?: HookOnSurveyHidden;
onQuestionReplied?: HookOnQuestionReplied;
onButtonNavigateStarted?: HookOnButtonNavigateStarted;
onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;
};
type HooksMessageStart = {
onMessageShowed?: HookOnMessageShowed;
onMessageStarted?: HookOnMessageStarted;
onMessageCompleted?: HookOnMessageCompleted;
onMessageHidden?: HookOnMessageHidden;
onQuestionReplied?: HookOnQuestionReplied;
onButtonNavigateStarted?: HookOnButtonNavigateStarted;
onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;
};
type HooksInit = HooksSurveyStart &
HooksMessageStart & {
version: string;
onReady?: HookOnReady;
onSurveyDisplayAllowed?: HookOnSurveyDisplayAllowed;
onMessageDisplayAllowed?: HookOnMessageDisplayAllowed;
};