Reference
Complete reference for @screeb/sdk-vue.
โจ New to Screeb? Start with the Install guide.
Configurationโ
| Option | Type | Required | Description |
|---|---|---|---|
websiteId | string | Yes | - |
userId | string | No | - |
userProperties | PropertyRecord | No | - |
hooks | HooksInit | No | - |
language | string | No | - |
shouldLoad | boolean | No | - |
autoInit | boolean | No | - |
options | ScreebOptions | No | - |
useScreeb() methodsโ
Lifecycleโ
| Method | Description | More |
|---|---|---|
init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => Promise<void> | Initialize the Screeb SDK. | ๐ |
load(options?: ScreebOptions) => Promise<void> | Load the Screeb tag. | ๐ |
close() => Promise<void> | Stop the SDK. | ๐ |
Identityโ
| Method | Description | More |
|---|---|---|
identity(userId: string, userProperties?: PropertyRecord) => Promise<unknown> | Identify the current user with optional properties. | ๐ |
identityProperties(userProperties: PropertyRecord) => Promise<unknown> | Send visitor properties without changing the identity. | ๐ |
identityReset() => Promise<unknown> | Reset the current visitor identity. | ๐ |
identityGet() => Promise<ScreebIdentityGetReturn> | Get the current visitor identity and properties. | ๐ |
Groupsโ
| Method | Description | More |
|---|---|---|
identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord) => Promise<unknown> | Assign the current user to a group. | ๐ |
identityGroupUnassign(groupName: string, groupType?: string) => Promise<unknown> | Remove the current user from a group. | ๐ |
Trackingโ
| Method | Description | More |
|---|---|---|
eventTrack(eventName: string, eventProperties?: PropertyRecord) => Promise<unknown> | Track a custom event. | ๐ |
Surveysโ
| 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. | ๐ |
surveyClose() => Promise<unknown> | Close the currently displayed survey. | ๐ |
Messagesโ
| Method | Description | More |
|---|---|---|
messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string) => Promise<unknown> | Start a specific message programmatically. | ๐ |
messageClose() => Promise<unknown> | Close the currently displayed message. | ๐ |
Session replayโ
| Method | Description | More |
|---|---|---|
sessionReplayStart() => Promise<unknown> | Start session replay recording. | ๐ |
sessionReplayStop() => Promise<unknown> | Stop session replay recording. | ๐ |
Debugโ
| Method | Description | More |
|---|---|---|
debug() => Promise<unknown> | Get SDK debug information. | ๐ |
targetingDebug() => Promise<unknown> | Get targeting debug information. | ๐ |
Privacy helpersโ
| Method | Description | More |
|---|---|---|
ScreebMaskText<T extends Element>(element: T) => T | Mask a view or component in session replay. | ๐ |
ScreebNoCapture<T extends Element>(element: T) => T | Exclude a view or component from session replay capture. | ๐ |
ScreebId<T extends Element>(element: T, id: string) => T | Set a stable Screeb element ID for IAM targeting. | ๐ |
API signaturesโ
Lifecycleโ
init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => Promise<void>;
load(options?: ScreebOptions) => Promise<void>;
close() => Promise<void>;
Identityโ
identity(userId: string, userProperties?: PropertyRecord) => Promise<unknown>;
identityProperties(userProperties: PropertyRecord) => Promise<unknown>;
identityReset() => Promise<unknown>;
identityGet() => Promise<ScreebIdentityGetReturn>;
Groupsโ
identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord) => Promise<unknown>;
identityGroupUnassign(groupName: string, groupType?: string) => Promise<unknown>;
Trackingโ
eventTrack(eventName: string, eventProperties?: PropertyRecord) => Promise<unknown>;
Surveysโ
surveyStart(surveyId: string, distributionId?: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]) => Promise<unknown>;
surveyClose() => Promise<unknown>;
Messagesโ
messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string) => Promise<unknown>;
messageClose() => Promise<unknown>;
Session replayโ
sessionReplayStart() => Promise<unknown>;
sessionReplayStop() => Promise<unknown>;
Debugโ
debug() => Promise<unknown>;
targetingDebug() => Promise<unknown>;
Privacy helpersโ
ScreebMaskText<T extends Element>(element: T) => T;
ScreebNoCapture<T extends Element>(element: T) => T;
ScreebId<T extends Element>(element: T, id: string) => T;
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 ScreebConfig = {
websiteId: string;
userId?: string;
userProperties?: PropertyRecord;
hooks?: HooksInit;
language?: string;
shouldLoad?: boolean;
autoInit?: boolean;
options?: ScreebOptions;
};
type ScreebContextValues = {
close: CloseFunction;
debug: DebugFunction;
eventTrack: EventTrackFunction;
identity: IdentityFunction;
identityGet: IdentityGetFunction;
identityGroupAssign: IdentityGroupAssignFunction;
identityGroupUnassign: IdentityGroupUnassignFunction;
identityProperties: IdentityPropertiesFunction;
identityReset: IdentityResetFunction;
init: InitFunction;
load: LoadFunction;
surveyClose: SurveyCloseFunction;
surveyStart: SurveyStartFunction;
messageClose: MessageCloseFunction;
messageStart: MessageStartFunction;
sessionReplayStart: SessionReplayStartFunction;
sessionReplayStop: SessionReplayStopFunction;
targetingDebug: TargetingDebugFunction;
ScreebMaskText: ScreebMaskTextFunction;
ScreebNoCapture: ScreebNoCaptureFunction;
ScreebId: ScreebIdFunction;
};
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;
};