Skip to main content
Version: Ionic SDK

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โ€‹

MethodDescriptionMore
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โ€‹

MethodDescriptionMore
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โ€‹

MethodDescriptionMore
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โ€‹

MethodDescriptionMore
eventTrack(eventName: string, eventProperties?: PropertyRecord)Tracks a user event.๐Ÿ‘‰

Surveysโ€‹

MethodDescriptionMore
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โ€‹

MethodDescriptionMore
messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string)Starts a message by its ID.๐Ÿ‘‰
messageClose()Interrupts a running message.๐Ÿ‘‰

Session replayโ€‹

MethodDescriptionMore
sessionReplayStart()Starts a session replay.๐Ÿ‘‰
sessionReplayStop()Interrupts a running session replay.๐Ÿ‘‰

Debugโ€‹

MethodDescriptionMore
debug()Prints the actual state information of Screeb tag.๐Ÿ‘‰
targetingDebug()Prints the current state of the targeting engine.๐Ÿ‘‰

Privacy helpersโ€‹

MethodDescriptionMore
ScreebMaskText<T extends Element>(element: T): TMarks an element as sensitive in Screeb session replay.๐Ÿ‘‰
ScreebNoCapture<T extends Element>(element: T): TExcludes an element from Screeb session replay capture.๐Ÿ‘‰
ScreebId<T extends Element>(element: T, id: string): TSets 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โ€‹

OptionTypeRequiredDescription
websiteIdstringNoYour website/channel id.
userIdstringNoThe unique identifier of your user.
userPropertiesPropertyRecordNoThe properties of your user.
hooksHooksInitNoHooks to define callback for various event.
shouldLoadbooleanNoIndicates if Screeb should be automatically loaded.
autoInitbooleanNoIndicates if Screeb should be automatically initialized.
optionsScreebOptionsNoScreeb tag initialization options.

Note: The language parameter is not available in ScreebModule.forRoot(). To set the language, use the language parameter when calling init() 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;
};