Reference
Complete reference for the Ionic SDK, which uses @screeb/sdk-angular internally.
โจ New to Screeb? Start with the Install guide.
Methods by capabilityโ
Inject the Screeb service and call these methods. All methods return a Promise.
Lifecycleโ
| Method | Description | More |
|---|---|---|
init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) | Initializes Screeb tag. | ๐ |
load(options?: ScreebOptions) | Appends Screeb tag into your dom. | ๐ |
close() | Shutdowns current Screeb session. | ๐ |
Identityโ
| Method | Description | More |
|---|---|---|
identity(userId: string, userProperties?: PropertyRecord) | Change the current user identity. | ๐ |
identityProperties(userProperties: PropertyRecord) | Adds properties to the current user identity. | ๐ |
identityReset() | Resets the current user identity. | ๐ |
identityGet() | Retrieves the current user identity. | ๐ |
Groupsโ
| Method | Description | More |
|---|---|---|
identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord) | Assigns the current user to a group. | ๐ |
identityGroupUnassign(groupName: string, groupType?: string) | Unassigns the current user to a group. | ๐ |
Trackingโ
| Method | Description | More |
|---|---|---|
eventTrack(eventName: string, eventProperties?: PropertyRecord) | Tracks a user event. | ๐ |
Surveysโ
| Method | Description | More |
|---|---|---|
surveyStart(surveyId: string, distributionId: string, allowMultipleResponses: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]) | Starts a survey by its ID. | ๐ |
surveyClose() | Interrupts a running survey. | ๐ |
Messagesโ
| Method | Description | More |
|---|---|---|
messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string) | Starts a message by its ID. | ๐ |
messageClose() | Interrupts a running message. | ๐ |
Session replayโ
| Method | Description | More |
|---|---|---|
sessionReplayStart() | Starts a session replay. | ๐ |
sessionReplayStop() | Interrupts a running session replay. | ๐ |
Debugโ
| Method | Description | More |
|---|---|---|
debug() | Prints the actual state information of Screeb tag. | ๐ |
targetingDebug() | Prints the current state of the targeting engine. | ๐ |
Privacy helpersโ
| Method | Description | More |
|---|---|---|
ScreebMaskText<T extends Element>(element: T): T | Marks an element as sensitive in Screeb session replay. | ๐ |
ScreebNoCapture<T extends Element>(element: T): T | Excludes an element from Screeb session replay capture. | ๐ |
ScreebId<T extends Element>(element: T, id: string): T | Sets a stable Screeb element ID for IAM targeting and replay context. | ๐ |
API signaturesโ
Lifecycleโ
public async init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string);
public async load(options?: ScreebOptions);
public async close();
Identityโ
public async identity(userId: string, userProperties?: PropertyRecord);
public async identityProperties(userProperties: PropertyRecord);
public async identityReset();
public async identityGet();
Groupsโ
public async identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord);
public async identityGroupUnassign(groupName: string, groupType?: string);
Trackingโ
public async eventTrack(eventName: string, eventProperties?: PropertyRecord);
Surveysโ
public async surveyStart(surveyId: string, distributionId: string, allowMultipleResponses: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]);
public async surveyClose();
Messagesโ
public async messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string);
public async messageClose();
Session replayโ
public async sessionReplayStart();
public async sessionReplayStop();
Debugโ
public async debug();
public async targetingDebug();
Privacy helpersโ
public ScreebMaskText<T extends Element>(element: T): T;
public ScreebNoCapture<T extends Element>(element: T): T;
public ScreebId<T extends Element>(element: T, id: string): T;
ScreebModule configurationโ
| Option | Type | Required | Description |
|---|---|---|---|
websiteId | string | No | 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 callback for various event. |
shouldLoad | boolean | No | Indicates if Screeb should be automatically loaded. |
autoInit | boolean | No | Indicates if Screeb should be automatically initialized. |
options | ScreebOptions | No | Screeb tag initialization options. |
Note: The
languageparameter is not available inScreebModule.forRoot(). To set the language, use thelanguageparameter when callinginit()directly.
Hooksโ
HookOnReadyโ
type HookOnReady = (data: { channel: Channel; user: User }) => void;
HookOnSurveyDisplayAllowedโ
type HookOnSurveyDisplayAllowed = (
data: HookCommonPropertiesSurvey,
) => boolean;
HookOnMessageDisplayAllowedโ
type HookOnMessageDisplayAllowed = (
data: HookCommonPropertiesSurvey,
) => boolean;
HookOnSurveyShowedโ
type HookOnSurveyShowed = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
HookOnSurveyStartedโ
type HookOnSurveyStarted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
};
},
) => void;
HookOnSurveyCompletedโ
type HookOnSurveyCompleted = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
HookOnSurveyHiddenโ
type HookOnSurveyHidden = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
items: ResponseItem[];
hide_reason: ResponseStatus;
};
},
) => void;
HookOnMessageShowedโ
type HookOnMessageShowed = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
HookOnMessageStartedโ
type HookOnMessageStarted = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
};
},
) => void;
HookOnMessageCompletedโ
type HookOnMessageCompleted = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
};
},
) => void;
HookOnMessageHiddenโ
type HookOnMessageHidden = (
data: HookCommonPropertiesMessage & {
response: {
id: string;
items: ResponseItem[];
hide_reason: ResponseStatus;
};
},
) => void;
HookOnQuestionRepliedโ
type HookOnQuestionReplied = (
data: HookCommonPropertiesSurvey & {
response: {
id: string;
status: null;
question: ResponseItemQuestion;
answer: ResponseItemAnswer;
items: ResponseItem[];
};
},
) => void;
For complete hook payload definitions, see the JS tag hooks reference.
Type definitionsโ
type PropertyType = number | boolean | string | Date | PropertyRecord;
type PropertyRecord = {
[key: string]: PropertyType | PropertyType[];
};
type ScreebOptions = {
window?: Window;
sdkName?: string;
sdkVersion?: string;
screebEndpoint?: string;
platform?: string;
};
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 HooksSurveyStart = {
onSurveyShowed?: HookOnSurveyShowed;
onSurveyStarted?: HookOnSurveyStarted;
onSurveyCompleted?: HookOnSurveyCompleted;
onSurveyHidden?: HookOnSurveyHidden;
onQuestionReplied?: HookOnQuestionReplied;
};
type HooksMessageStart = {
onMessageShowed?: HookOnMessageShowed;
onMessageStarted?: HookOnMessageStarted;
onMessageCompleted?: HookOnMessageCompleted;
onMessageHidden?: HookOnMessageHidden;
onQuestionReplied?: HookOnQuestionReplied;
};
type HooksInit = HooksSurveyStart &
HooksMessageStart & {
version: string;
onReady?: HookOnReady;
onSurveyDisplayAllowed?: HookOnSurveyDisplayAllowed;
onMessageDisplayAllowed?: HookOnMessageDisplayAllowed;
};