@screeb/sdk-browser 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks.types.d.ts +81 -0
- package/dist/cjs/index.d.ts +349 -0
- package/dist/cjs/index.js +440 -0
- package/dist/cjs/types.d.ts +58 -0
- package/dist/es/index.d.ts +1 -0
- package/docs/README.md +272 -6
- package/package.json +4 -9
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export type ChannelType = "widget" | "ios" | "android";
|
|
2
|
+
export type Channel = {
|
|
3
|
+
id: string;
|
|
4
|
+
type: ChannelType;
|
|
5
|
+
};
|
|
6
|
+
export type User = {
|
|
7
|
+
anonymous_id: string;
|
|
8
|
+
userId?: string;
|
|
9
|
+
};
|
|
10
|
+
export type SurveyFormat = "conversationnal" | "cards";
|
|
11
|
+
export type SurveySize = 25 | 50 | 75 | 100 | 125 | 150;
|
|
12
|
+
export type SurveyPosition = "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
13
|
+
export type Survey = {
|
|
14
|
+
id: string;
|
|
15
|
+
survey_position: SurveyPosition;
|
|
16
|
+
survey_format: SurveyFormat;
|
|
17
|
+
survey_size: 100;
|
|
18
|
+
};
|
|
19
|
+
export type ResponseStatus = "displayed" | "started" | "ended" | "closed" | "interrupted";
|
|
20
|
+
export type ResponseItemQuestion = {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
type: "text" | "video";
|
|
24
|
+
url?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ResponseItemAnswer = {
|
|
27
|
+
replied_at?: string;
|
|
28
|
+
fields?: {
|
|
29
|
+
type: "string" | "number" | "boolean" | "none" | "time" | "file";
|
|
30
|
+
text?: string;
|
|
31
|
+
number?: number;
|
|
32
|
+
boolean?: boolean;
|
|
33
|
+
time?: string;
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
36
|
+
export type ResponseItem = {
|
|
37
|
+
question: ResponseItemQuestion;
|
|
38
|
+
answer: ResponseItemAnswer;
|
|
39
|
+
};
|
|
40
|
+
export type HookCommonProperties = {
|
|
41
|
+
channel: Channel;
|
|
42
|
+
user: User;
|
|
43
|
+
survey: Survey;
|
|
44
|
+
};
|
|
45
|
+
export type HookOnReady = (data: {
|
|
46
|
+
channel: Channel;
|
|
47
|
+
user: User;
|
|
48
|
+
}) => void;
|
|
49
|
+
export type HookOnSurveyShowed = (data: HookCommonProperties & {
|
|
50
|
+
response: {
|
|
51
|
+
id: string;
|
|
52
|
+
items: ResponseItem[];
|
|
53
|
+
};
|
|
54
|
+
}) => void;
|
|
55
|
+
export type HookOnSurveyStarted = (data: HookCommonProperties & {
|
|
56
|
+
response: {
|
|
57
|
+
id: string;
|
|
58
|
+
};
|
|
59
|
+
}) => void;
|
|
60
|
+
export type HookOnQuestionReplied = (data: HookCommonProperties & {
|
|
61
|
+
response: {
|
|
62
|
+
id: string;
|
|
63
|
+
status: null;
|
|
64
|
+
question: ResponseItemQuestion;
|
|
65
|
+
answer: ResponseItemAnswer;
|
|
66
|
+
items: ResponseItem[];
|
|
67
|
+
};
|
|
68
|
+
}) => void;
|
|
69
|
+
export type HookOnSurveyCompleted = (data: HookCommonProperties & {
|
|
70
|
+
response: {
|
|
71
|
+
id: string;
|
|
72
|
+
items: ResponseItem[];
|
|
73
|
+
};
|
|
74
|
+
}) => void;
|
|
75
|
+
export type HookOnSurveyHidden = (data: HookCommonProperties & {
|
|
76
|
+
response: {
|
|
77
|
+
id: string;
|
|
78
|
+
items: ResponseItem[];
|
|
79
|
+
hide_reason: ResponseStatus;
|
|
80
|
+
};
|
|
81
|
+
}) => void;
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { Hooks, PropertyRecord, ScreebIdentityGetReturn, ScreebOptions } from "./types";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export * from "./hooks.types";
|
|
4
|
+
/**
|
|
5
|
+
* Appends Screeb tag into your dom.
|
|
6
|
+
*
|
|
7
|
+
* @param options Screeb module options.
|
|
8
|
+
* @param options.window If you're running Screeb tag in an iframe, please set the inner window here.
|
|
9
|
+
* @param options.screebEndpoint Please don't do this.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
14
|
+
*
|
|
15
|
+
* Screeb.load();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Initializes Screeb tag.
|
|
21
|
+
*
|
|
22
|
+
* @param websiteId Your website/channel id.
|
|
23
|
+
* @param userId The unique identifier of your user.
|
|
24
|
+
* @param userProperties The properties of your user.
|
|
25
|
+
* ```text Requirements:
|
|
26
|
+
* - Property names must be limited to 128 characters
|
|
27
|
+
* - No more than 1000 attributes
|
|
28
|
+
* - Supported types for values: string, number, boolean and Date
|
|
29
|
+
* ```
|
|
30
|
+
* @param hooks Hooks to be called when SDK is ready or a survey is showed, started, completed, hidden
|
|
31
|
+
* or when a question is replied.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
36
|
+
*
|
|
37
|
+
* Screeb.init(
|
|
38
|
+
* "<your-website-id>",
|
|
39
|
+
* "<your-user-id>",
|
|
40
|
+
* {
|
|
41
|
+
* firstname: '<user-firstname>',
|
|
42
|
+
* lastname: '<user-lastname>',
|
|
43
|
+
* plan: '<user-plan>',
|
|
44
|
+
* last_seen_at: new Date(),
|
|
45
|
+
* authenticated: true
|
|
46
|
+
* },
|
|
47
|
+
* {
|
|
48
|
+
* version: "1.0.0",
|
|
49
|
+
* onReady: (payload) => console.log("Screeb SDK is ready!", payload),
|
|
50
|
+
* },
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare const init: (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: Hooks) => void | Promise<unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if Screeb tag has been loaded.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
61
|
+
*
|
|
62
|
+
* console.log(Screeb.isLoaded()); // false
|
|
63
|
+
* Screeb.load();
|
|
64
|
+
* console.log(Screeb.isLoaded()); // true
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const isLoaded: () => boolean | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Shutdowns current Screeb session.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
74
|
+
*
|
|
75
|
+
* Screeb.close();
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare const close: () => void | Promise<unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Prints the actual state information of Screeb tag.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
85
|
+
*
|
|
86
|
+
* Screeb.debug();
|
|
87
|
+
* // ******************* SCREEB SESSION DEBUG *********************
|
|
88
|
+
* // Screeb channel id: <UUID>
|
|
89
|
+
* // Screeb channel type: widget
|
|
90
|
+
* // Screeb respondent id: <UUID>
|
|
91
|
+
* // Screeb survey id: none
|
|
92
|
+
* // Screeb response id: none
|
|
93
|
+
* //
|
|
94
|
+
* // Screeb current session start: Thu May 04 2023 16:53:49 GMT+0200 (Central European Summer Time)
|
|
95
|
+
* // Screeb current session last activity: Thu May 04 2023 17:41:30 GMT+0200 (Central European Summer Time)
|
|
96
|
+
* //
|
|
97
|
+
* // Screeb targeting engine status: disabled
|
|
98
|
+
* // Screeb targeting engine: 3 surveys
|
|
99
|
+
* //
|
|
100
|
+
* // Detected platform: desktop
|
|
101
|
+
* // Detected locale: en-GB
|
|
102
|
+
* // Detected timezone: -120
|
|
103
|
+
* // **************************************************************
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare const debug: () => void | Promise<unknown>;
|
|
107
|
+
/**
|
|
108
|
+
* Tracks a user event.
|
|
109
|
+
*
|
|
110
|
+
* @param eventName The event name.
|
|
111
|
+
* @param eventProperties The properties of your event.
|
|
112
|
+
* ```text Requirements:
|
|
113
|
+
* - Property names must be limited to 128 characters
|
|
114
|
+
* - No more than 1000 attributes
|
|
115
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
121
|
+
*
|
|
122
|
+
* Screeb.eventTrack(
|
|
123
|
+
* "Product added to cart",
|
|
124
|
+
* {
|
|
125
|
+
* product_name: 'Red bike 2021',
|
|
126
|
+
* category: 'sport',
|
|
127
|
+
* color: 'red',
|
|
128
|
+
* price: 299,
|
|
129
|
+
* count: 1,
|
|
130
|
+
* reference: '2CF093TG1',
|
|
131
|
+
* delivery_method: 'UPS',
|
|
132
|
+
* user_logged: false,
|
|
133
|
+
* added_at: new Date(),
|
|
134
|
+
* }
|
|
135
|
+
* );
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const eventTrack: (eventName: string, eventProperties?: PropertyRecord) => void | Promise<unknown>;
|
|
139
|
+
/**
|
|
140
|
+
* Change the current user identity.
|
|
141
|
+
* Warning: Running surveys will be closed.
|
|
142
|
+
*
|
|
143
|
+
* @param userId The unique identifier of your user.
|
|
144
|
+
* @param userProperties The properties of your user.
|
|
145
|
+
* ```text Requirements:
|
|
146
|
+
* - Property names must be limited to 128 characters
|
|
147
|
+
* - No more than 1000 attributes
|
|
148
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
154
|
+
*
|
|
155
|
+
* Screeb.identity(
|
|
156
|
+
* "<your-user-id>",
|
|
157
|
+
* {
|
|
158
|
+
* firstname: '<user-firstname>',
|
|
159
|
+
* lastname: '<user-lastname>',
|
|
160
|
+
* plan: '<user-plan>',
|
|
161
|
+
* last_seen_at: new Date(),
|
|
162
|
+
* authenticated: true
|
|
163
|
+
* }
|
|
164
|
+
* );
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export declare const identity: (userId: string, userProperties?: PropertyRecord) => void | Promise<unknown>;
|
|
168
|
+
/**
|
|
169
|
+
* Retrieves the current user identity.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```ts
|
|
173
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
174
|
+
*
|
|
175
|
+
* console.log(await Screeb.identityGet());
|
|
176
|
+
* // {
|
|
177
|
+
* // anonymous_id: "<UUID>",
|
|
178
|
+
* // user_id: "<UUID>",
|
|
179
|
+
* // session_id: "<UUID>",
|
|
180
|
+
* // session_start: "2023-05-04T16:30:15.882Z",
|
|
181
|
+
* // session_end: "2023-05-04T17:02:09.087Z",
|
|
182
|
+
* // channel_id: "<UUID>",
|
|
183
|
+
* // is_ready: true,
|
|
184
|
+
* // }
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export declare const identityGet: () => Promise<ScreebIdentityGetReturn>;
|
|
188
|
+
/**
|
|
189
|
+
* Assigns the current user to a group.
|
|
190
|
+
*
|
|
191
|
+
* @param groupName
|
|
192
|
+
* @param groupType
|
|
193
|
+
* @param groupProperties The properties of your user group.
|
|
194
|
+
* ```text Requirements:
|
|
195
|
+
* - Property names must be limited to 128 characters
|
|
196
|
+
* - No more than 1000 attributes
|
|
197
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```ts
|
|
202
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
203
|
+
*
|
|
204
|
+
* Screeb.identityGroupAssign(
|
|
205
|
+
* 'company',
|
|
206
|
+
* 'Apple',
|
|
207
|
+
* {
|
|
208
|
+
* address_line_1: 'Apple Campus',
|
|
209
|
+
* address_line_2: '1 Infinite Loop',
|
|
210
|
+
* city: 'Cupertino',
|
|
211
|
+
* zipcode: 95014,
|
|
212
|
+
* state: 'California',
|
|
213
|
+
* country: 'United states',
|
|
214
|
+
* }
|
|
215
|
+
* );
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare const identityGroupAssign: (groupName: string, groupType?: string, groupProperties?: PropertyRecord) => void | Promise<unknown>;
|
|
219
|
+
/**
|
|
220
|
+
* Unassigns the current user to a group.
|
|
221
|
+
*
|
|
222
|
+
* @param groupName The name of your user group.
|
|
223
|
+
* @param groupType The type of your user group.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
228
|
+
*
|
|
229
|
+
* Screeb.identityGroupUnassign('company', 'Apple');
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export declare const identityGroupUnassign: (groupName: string, groupType?: string) => void | Promise<unknown>;
|
|
233
|
+
/**
|
|
234
|
+
* Adds properties to the current user identity.
|
|
235
|
+
*
|
|
236
|
+
* @param userProperties The properties of your user.
|
|
237
|
+
* ```text Requirements:
|
|
238
|
+
* - Property names must be limited to 128 characters
|
|
239
|
+
* - No more than 1000 attributes
|
|
240
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
241
|
+
* ```
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
246
|
+
*
|
|
247
|
+
* // Set user properties
|
|
248
|
+
* Screeb.identityProperties(
|
|
249
|
+
* {
|
|
250
|
+
* firstname: '<user-firstname>',
|
|
251
|
+
* lastname: '<user-lastname>',
|
|
252
|
+
* plan: '<user-plan>',
|
|
253
|
+
* last_seen_at: new Date(),
|
|
254
|
+
* authenticated: true
|
|
255
|
+
* }
|
|
256
|
+
* );
|
|
257
|
+
*
|
|
258
|
+
* // Delete user property : set values to null
|
|
259
|
+
* Screeb.identityProperties(
|
|
260
|
+
* {
|
|
261
|
+
* age: null,
|
|
262
|
+
* company: null,
|
|
263
|
+
* logged: true,
|
|
264
|
+
* }
|
|
265
|
+
* );
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
export declare const identityProperties: (userProperties: PropertyRecord) => void | Promise<unknown>;
|
|
269
|
+
/**
|
|
270
|
+
* Resets the current user identity.
|
|
271
|
+
* Warning: This command must be called only once, since it creates a new identity on Screeb side.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* ```ts
|
|
275
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
276
|
+
*
|
|
277
|
+
* Screeb.identityReset();
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
export declare const identityReset: () => void | Promise<unknown>;
|
|
281
|
+
/**
|
|
282
|
+
* Interrupts a running survey.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
287
|
+
*
|
|
288
|
+
* Screeb.surveyClose();
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
export declare const surveyClose: () => void | Promise<unknown>;
|
|
292
|
+
/**
|
|
293
|
+
* Starts a survey by its ID.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
298
|
+
*
|
|
299
|
+
* Screeb.surveyStart(
|
|
300
|
+
* '<UUID>',
|
|
301
|
+
* false,
|
|
302
|
+
* {
|
|
303
|
+
* color: "green",
|
|
304
|
+
* article_id: 42
|
|
305
|
+
* },
|
|
306
|
+
* {
|
|
307
|
+
* version: "1.0.0",
|
|
308
|
+
* onSurveyShowed: (payload) => console.log("Survey showed", payload),
|
|
309
|
+
* },
|
|
310
|
+
* );
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
export declare const surveyStart: (surveyId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: Hooks) => void | Promise<unknown>;
|
|
314
|
+
/**
|
|
315
|
+
* Forces a targeting check.
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
320
|
+
*
|
|
321
|
+
* Screeb.targetingCheck();
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
export declare const targetingCheck: () => void | Promise<unknown>;
|
|
325
|
+
/**
|
|
326
|
+
* Prints the current state of the targeting engine.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```ts
|
|
330
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
331
|
+
*
|
|
332
|
+
* console.log(await Screeb.targetingDebug());
|
|
333
|
+
* // targeting ************ SCREEB TARGETING RULES DEBUG **************
|
|
334
|
+
* // Disabled surveys are not listed here.
|
|
335
|
+
* //
|
|
336
|
+
* // Screeb channel id: <UUID>
|
|
337
|
+
* // Screeb respondent id: <UUID>
|
|
338
|
+
* //
|
|
339
|
+
* // Survey <UUID>:
|
|
340
|
+
* // https://admin.screeb.app/org/last/survey/<UUID>/share
|
|
341
|
+
* //
|
|
342
|
+
* // - Rule of type "Device type (desktop/mobile/tablet)": true 🟢
|
|
343
|
+
* // - Rule of type "Multiple display": true 🟢
|
|
344
|
+
* // - Rule of type "Capping per time between survey display on current respondent": true 🟢
|
|
345
|
+
* // - Rule of type "User event count": false 🔴
|
|
346
|
+
* // - Rule of type "Capping per respondent display count": false 🔴
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
export declare const targetingDebug: () => void | Promise<unknown>;
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var SCREEB_TAG_ENDPOINT = "https://t.screeb.app/tag.js";
|
|
4
|
+
var _window = typeof window === "undefined" ? undefined : window;
|
|
5
|
+
var callScreebCommand = function () {
|
|
6
|
+
var args = [];
|
|
7
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8
|
+
args[_i] = arguments[_i];
|
|
9
|
+
}
|
|
10
|
+
if (_window === null || _window === void 0 ? void 0 : _window.$screeb) {
|
|
11
|
+
return _window.$screeb.apply(_window.$screeb, args);
|
|
12
|
+
}
|
|
13
|
+
return Promise.reject("[Screeb] Screeb.load() must be called before any other function.");
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Appends Screeb tag into your dom.
|
|
17
|
+
*
|
|
18
|
+
* @param options Screeb module options.
|
|
19
|
+
* @param options.window If you're running Screeb tag in an iframe, please set the inner window here.
|
|
20
|
+
* @param options.screebEndpoint Please don't do this.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
25
|
+
*
|
|
26
|
+
* Screeb.load();
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
var load = function (options) {
|
|
30
|
+
if (options === void 0) { options = {}; }
|
|
31
|
+
return new Promise(function (resolve, reject) {
|
|
32
|
+
var _a, _b, _c;
|
|
33
|
+
_window = (_a = options.window) !== null && _a !== void 0 ? _a : window;
|
|
34
|
+
var scriptElement = document.createElement("script");
|
|
35
|
+
scriptElement.async = true;
|
|
36
|
+
scriptElement.src = (_b = options.screebEndpoint) !== null && _b !== void 0 ? _b : SCREEB_TAG_ENDPOINT;
|
|
37
|
+
scriptElement.addEventListener("load", function () { return resolve(undefined); });
|
|
38
|
+
scriptElement.addEventListener("error", reject);
|
|
39
|
+
_window.$screeb =
|
|
40
|
+
(_c = _window.$screeb) !== null && _c !== void 0 ? _c : function () {
|
|
41
|
+
var args = [];
|
|
42
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
43
|
+
args[_i] = arguments[_i];
|
|
44
|
+
}
|
|
45
|
+
return new Promise(function (a, b) {
|
|
46
|
+
var _a;
|
|
47
|
+
if (_window === null || _window === void 0 ? void 0 : _window.$screeb) {
|
|
48
|
+
return (_window.$screeb.q = (_a = _window.$screeb.q) !== null && _a !== void 0 ? _a : []).push({
|
|
49
|
+
args: args,
|
|
50
|
+
ko: b,
|
|
51
|
+
ok: a,
|
|
52
|
+
v: 1,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return 0;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
_window.document.head.appendChild(scriptElement);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Initializes Screeb tag.
|
|
63
|
+
*
|
|
64
|
+
* @param websiteId Your website/channel id.
|
|
65
|
+
* @param userId The unique identifier of your user.
|
|
66
|
+
* @param userProperties The properties of your user.
|
|
67
|
+
* ```text Requirements:
|
|
68
|
+
* - Property names must be limited to 128 characters
|
|
69
|
+
* - No more than 1000 attributes
|
|
70
|
+
* - Supported types for values: string, number, boolean and Date
|
|
71
|
+
* ```
|
|
72
|
+
* @param hooks Hooks to be called when SDK is ready or a survey is showed, started, completed, hidden
|
|
73
|
+
* or when a question is replied.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
78
|
+
*
|
|
79
|
+
* Screeb.init(
|
|
80
|
+
* "<your-website-id>",
|
|
81
|
+
* "<your-user-id>",
|
|
82
|
+
* {
|
|
83
|
+
* firstname: '<user-firstname>',
|
|
84
|
+
* lastname: '<user-lastname>',
|
|
85
|
+
* plan: '<user-plan>',
|
|
86
|
+
* last_seen_at: new Date(),
|
|
87
|
+
* authenticated: true
|
|
88
|
+
* },
|
|
89
|
+
* {
|
|
90
|
+
* version: "1.0.0",
|
|
91
|
+
* onReady: (payload) => console.log("Screeb SDK is ready!", payload),
|
|
92
|
+
* },
|
|
93
|
+
* );
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
var init = function (websiteId, userId, userProperties, hooks) {
|
|
97
|
+
var identityObject;
|
|
98
|
+
if (userId || userProperties) {
|
|
99
|
+
identityObject = {
|
|
100
|
+
hooks: hooks,
|
|
101
|
+
identity: {
|
|
102
|
+
id: userId,
|
|
103
|
+
properties: userProperties,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return callScreebCommand("init", websiteId, identityObject);
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Checks if Screeb tag has been loaded.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
115
|
+
*
|
|
116
|
+
* console.log(Screeb.isLoaded()); // false
|
|
117
|
+
* Screeb.load();
|
|
118
|
+
* console.log(Screeb.isLoaded()); // true
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
var isLoaded = function () {
|
|
122
|
+
return (_window === null || _window === void 0 ? void 0 : _window.$screeb) && typeof _window.$screeb === "function";
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Shutdowns current Screeb session.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
130
|
+
*
|
|
131
|
+
* Screeb.close();
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
var close = function () { return callScreebCommand("close"); };
|
|
135
|
+
/**
|
|
136
|
+
* Prints the actual state information of Screeb tag.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
141
|
+
*
|
|
142
|
+
* Screeb.debug();
|
|
143
|
+
* // ******************* SCREEB SESSION DEBUG *********************
|
|
144
|
+
* // Screeb channel id: <UUID>
|
|
145
|
+
* // Screeb channel type: widget
|
|
146
|
+
* // Screeb respondent id: <UUID>
|
|
147
|
+
* // Screeb survey id: none
|
|
148
|
+
* // Screeb response id: none
|
|
149
|
+
* //
|
|
150
|
+
* // Screeb current session start: Thu May 04 2023 16:53:49 GMT+0200 (Central European Summer Time)
|
|
151
|
+
* // Screeb current session last activity: Thu May 04 2023 17:41:30 GMT+0200 (Central European Summer Time)
|
|
152
|
+
* //
|
|
153
|
+
* // Screeb targeting engine status: disabled
|
|
154
|
+
* // Screeb targeting engine: 3 surveys
|
|
155
|
+
* //
|
|
156
|
+
* // Detected platform: desktop
|
|
157
|
+
* // Detected locale: en-GB
|
|
158
|
+
* // Detected timezone: -120
|
|
159
|
+
* // **************************************************************
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
var debug = function () { return callScreebCommand("debug"); };
|
|
163
|
+
/**
|
|
164
|
+
* Tracks a user event.
|
|
165
|
+
*
|
|
166
|
+
* @param eventName The event name.
|
|
167
|
+
* @param eventProperties The properties of your event.
|
|
168
|
+
* ```text Requirements:
|
|
169
|
+
* - Property names must be limited to 128 characters
|
|
170
|
+
* - No more than 1000 attributes
|
|
171
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
177
|
+
*
|
|
178
|
+
* Screeb.eventTrack(
|
|
179
|
+
* "Product added to cart",
|
|
180
|
+
* {
|
|
181
|
+
* product_name: 'Red bike 2021',
|
|
182
|
+
* category: 'sport',
|
|
183
|
+
* color: 'red',
|
|
184
|
+
* price: 299,
|
|
185
|
+
* count: 1,
|
|
186
|
+
* reference: '2CF093TG1',
|
|
187
|
+
* delivery_method: 'UPS',
|
|
188
|
+
* user_logged: false,
|
|
189
|
+
* added_at: new Date(),
|
|
190
|
+
* }
|
|
191
|
+
* );
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
var eventTrack = function (eventName, eventProperties) { return callScreebCommand("event.track", eventName, eventProperties); };
|
|
195
|
+
/**
|
|
196
|
+
* Change the current user identity.
|
|
197
|
+
* Warning: Running surveys will be closed.
|
|
198
|
+
*
|
|
199
|
+
* @param userId The unique identifier of your user.
|
|
200
|
+
* @param userProperties The properties of your user.
|
|
201
|
+
* ```text Requirements:
|
|
202
|
+
* - Property names must be limited to 128 characters
|
|
203
|
+
* - No more than 1000 attributes
|
|
204
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
210
|
+
*
|
|
211
|
+
* Screeb.identity(
|
|
212
|
+
* "<your-user-id>",
|
|
213
|
+
* {
|
|
214
|
+
* firstname: '<user-firstname>',
|
|
215
|
+
* lastname: '<user-lastname>',
|
|
216
|
+
* plan: '<user-plan>',
|
|
217
|
+
* last_seen_at: new Date(),
|
|
218
|
+
* authenticated: true
|
|
219
|
+
* }
|
|
220
|
+
* );
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
var identity = function (userId, userProperties) {
|
|
224
|
+
return callScreebCommand("identity", userId, userProperties);
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Retrieves the current user identity.
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```ts
|
|
231
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
232
|
+
*
|
|
233
|
+
* console.log(await Screeb.identityGet());
|
|
234
|
+
* // {
|
|
235
|
+
* // anonymous_id: "<UUID>",
|
|
236
|
+
* // user_id: "<UUID>",
|
|
237
|
+
* // session_id: "<UUID>",
|
|
238
|
+
* // session_start: "2023-05-04T16:30:15.882Z",
|
|
239
|
+
* // session_end: "2023-05-04T17:02:09.087Z",
|
|
240
|
+
* // channel_id: "<UUID>",
|
|
241
|
+
* // is_ready: true,
|
|
242
|
+
* // }
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
var identityGet = function () {
|
|
246
|
+
return callScreebCommand("identity.get");
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Assigns the current user to a group.
|
|
250
|
+
*
|
|
251
|
+
* @param groupName
|
|
252
|
+
* @param groupType
|
|
253
|
+
* @param groupProperties The properties of your user group.
|
|
254
|
+
* ```text Requirements:
|
|
255
|
+
* - Property names must be limited to 128 characters
|
|
256
|
+
* - No more than 1000 attributes
|
|
257
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
263
|
+
*
|
|
264
|
+
* Screeb.identityGroupAssign(
|
|
265
|
+
* 'company',
|
|
266
|
+
* 'Apple',
|
|
267
|
+
* {
|
|
268
|
+
* address_line_1: 'Apple Campus',
|
|
269
|
+
* address_line_2: '1 Infinite Loop',
|
|
270
|
+
* city: 'Cupertino',
|
|
271
|
+
* zipcode: 95014,
|
|
272
|
+
* state: 'California',
|
|
273
|
+
* country: 'United states',
|
|
274
|
+
* }
|
|
275
|
+
* );
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
var identityGroupAssign = function (groupName, groupType, groupProperties) {
|
|
279
|
+
return callScreebCommand("identity.group.assign", groupType, groupName, groupProperties);
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Unassigns the current user to a group.
|
|
283
|
+
*
|
|
284
|
+
* @param groupName The name of your user group.
|
|
285
|
+
* @param groupType The type of your user group.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
290
|
+
*
|
|
291
|
+
* Screeb.identityGroupUnassign('company', 'Apple');
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
var identityGroupUnassign = function (groupName, groupType) {
|
|
295
|
+
return callScreebCommand("identity.group.unassign", groupType, groupName);
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Adds properties to the current user identity.
|
|
299
|
+
*
|
|
300
|
+
* @param userProperties The properties of your user.
|
|
301
|
+
* ```text Requirements:
|
|
302
|
+
* - Property names must be limited to 128 characters
|
|
303
|
+
* - No more than 1000 attributes
|
|
304
|
+
* - Supported types for values: string, number, boolean and Date.
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```ts
|
|
309
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
310
|
+
*
|
|
311
|
+
* // Set user properties
|
|
312
|
+
* Screeb.identityProperties(
|
|
313
|
+
* {
|
|
314
|
+
* firstname: '<user-firstname>',
|
|
315
|
+
* lastname: '<user-lastname>',
|
|
316
|
+
* plan: '<user-plan>',
|
|
317
|
+
* last_seen_at: new Date(),
|
|
318
|
+
* authenticated: true
|
|
319
|
+
* }
|
|
320
|
+
* );
|
|
321
|
+
*
|
|
322
|
+
* // Delete user property : set values to null
|
|
323
|
+
* Screeb.identityProperties(
|
|
324
|
+
* {
|
|
325
|
+
* age: null,
|
|
326
|
+
* company: null,
|
|
327
|
+
* logged: true,
|
|
328
|
+
* }
|
|
329
|
+
* );
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
var identityProperties = function (userProperties) {
|
|
333
|
+
return callScreebCommand("identity.properties", userProperties);
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Resets the current user identity.
|
|
337
|
+
* Warning: This command must be called only once, since it creates a new identity on Screeb side.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
342
|
+
*
|
|
343
|
+
* Screeb.identityReset();
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
var identityReset = function () { return callScreebCommand("identity.reset"); };
|
|
347
|
+
/**
|
|
348
|
+
* Interrupts a running survey.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```ts
|
|
352
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
353
|
+
*
|
|
354
|
+
* Screeb.surveyClose();
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
var surveyClose = function () { return callScreebCommand("survey.close"); };
|
|
358
|
+
/**
|
|
359
|
+
* Starts a survey by its ID.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```ts
|
|
363
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
364
|
+
*
|
|
365
|
+
* Screeb.surveyStart(
|
|
366
|
+
* '<UUID>',
|
|
367
|
+
* false,
|
|
368
|
+
* {
|
|
369
|
+
* color: "green",
|
|
370
|
+
* article_id: 42
|
|
371
|
+
* },
|
|
372
|
+
* {
|
|
373
|
+
* version: "1.0.0",
|
|
374
|
+
* onSurveyShowed: (payload) => console.log("Survey showed", payload),
|
|
375
|
+
* },
|
|
376
|
+
* );
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
var surveyStart = function (surveyId, allowMultipleResponses, hiddenFields, hooks) {
|
|
380
|
+
if (allowMultipleResponses === void 0) { allowMultipleResponses = true; }
|
|
381
|
+
if (hiddenFields === void 0) { hiddenFields = {}; }
|
|
382
|
+
return callScreebCommand("survey.start", surveyId, {
|
|
383
|
+
allow_multiple_responses: allowMultipleResponses,
|
|
384
|
+
hidden_fields: hiddenFields,
|
|
385
|
+
hooks: hooks,
|
|
386
|
+
});
|
|
387
|
+
};
|
|
388
|
+
/**
|
|
389
|
+
* Forces a targeting check.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* ```ts
|
|
393
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
394
|
+
*
|
|
395
|
+
* Screeb.targetingCheck();
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
var targetingCheck = function () { return callScreebCommand("targeting.check"); };
|
|
399
|
+
/**
|
|
400
|
+
* Prints the current state of the targeting engine.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```ts
|
|
404
|
+
* import * as Screeb from "@screeb/sdk-browser";
|
|
405
|
+
*
|
|
406
|
+
* console.log(await Screeb.targetingDebug());
|
|
407
|
+
* // targeting ************ SCREEB TARGETING RULES DEBUG **************
|
|
408
|
+
* // Disabled surveys are not listed here.
|
|
409
|
+
* //
|
|
410
|
+
* // Screeb channel id: <UUID>
|
|
411
|
+
* // Screeb respondent id: <UUID>
|
|
412
|
+
* //
|
|
413
|
+
* // Survey <UUID>:
|
|
414
|
+
* // https://admin.screeb.app/org/last/survey/<UUID>/share
|
|
415
|
+
* //
|
|
416
|
+
* // - Rule of type "Device type (desktop/mobile/tablet)": true 🟢
|
|
417
|
+
* // - Rule of type "Multiple display": true 🟢
|
|
418
|
+
* // - Rule of type "Capping per time between survey display on current respondent": true 🟢
|
|
419
|
+
* // - Rule of type "User event count": false 🔴
|
|
420
|
+
* // - Rule of type "Capping per respondent display count": false 🔴
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
var targetingDebug = function () { return callScreebCommand("targeting.debug"); };
|
|
424
|
+
|
|
425
|
+
exports.close = close;
|
|
426
|
+
exports.debug = debug;
|
|
427
|
+
exports.eventTrack = eventTrack;
|
|
428
|
+
exports.identity = identity;
|
|
429
|
+
exports.identityGet = identityGet;
|
|
430
|
+
exports.identityGroupAssign = identityGroupAssign;
|
|
431
|
+
exports.identityGroupUnassign = identityGroupUnassign;
|
|
432
|
+
exports.identityProperties = identityProperties;
|
|
433
|
+
exports.identityReset = identityReset;
|
|
434
|
+
exports.init = init;
|
|
435
|
+
exports.isLoaded = isLoaded;
|
|
436
|
+
exports.load = load;
|
|
437
|
+
exports.surveyClose = surveyClose;
|
|
438
|
+
exports.surveyStart = surveyStart;
|
|
439
|
+
exports.targetingCheck = targetingCheck;
|
|
440
|
+
exports.targetingDebug = targetingDebug;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { HookOnQuestionReplied, HookOnReady, HookOnSurveyCompleted, HookOnSurveyHidden, HookOnSurveyShowed, HookOnSurveyStarted } from "./hooks.types";
|
|
2
|
+
/** This is property types that are supported by Screeb. */
|
|
3
|
+
export type PropertyType = number | boolean | string | Date | PropertyRecord;
|
|
4
|
+
/** This is a property object that are supported by Screeb. */
|
|
5
|
+
export type PropertyRecord = {
|
|
6
|
+
[key: string]: PropertyType | PropertyType[];
|
|
7
|
+
};
|
|
8
|
+
/** This is the Screeb tag options object. */
|
|
9
|
+
export type ScreebOptions = {
|
|
10
|
+
/** If you're running Screeb tag in an iframe, please set the inner window here. */
|
|
11
|
+
window?: Window;
|
|
12
|
+
/** Please don't do this. */
|
|
13
|
+
screebEndpoint?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
|
|
16
|
+
/** This is the Screeb object publicly exposed in browser `window`. */
|
|
17
|
+
export type ScreebObject = ScreebFunction & {
|
|
18
|
+
q?: {
|
|
19
|
+
args: unknown[];
|
|
20
|
+
ko: (reason?: unknown) => void;
|
|
21
|
+
ok: (value?: unknown) => void;
|
|
22
|
+
v: number;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
/** This is the object returned by the function `identityGet()`. */
|
|
26
|
+
export type ScreebIdentityGetReturn = {
|
|
27
|
+
/** Anonymous id given to each user */
|
|
28
|
+
anonymous_id: string;
|
|
29
|
+
/** The authenticated id assigned to the user. */
|
|
30
|
+
user_id: string;
|
|
31
|
+
/** The current user session id */
|
|
32
|
+
session_id: string;
|
|
33
|
+
/** The current user session start time */
|
|
34
|
+
session_start: string;
|
|
35
|
+
/** The current user session end time */
|
|
36
|
+
session_end: string;
|
|
37
|
+
/** The current channel id with which the tag was initialized */
|
|
38
|
+
channel_id: string;
|
|
39
|
+
/** `true` if the tag is loaded, initialized and ready to rock */
|
|
40
|
+
is_ready: boolean;
|
|
41
|
+
};
|
|
42
|
+
/** This is the Screeb tag hooks object. */
|
|
43
|
+
export type Hooks = {
|
|
44
|
+
/** This defines the version of hooks and their data */
|
|
45
|
+
version: string;
|
|
46
|
+
/** This hook is triggered when Screeb SD is loaded, initialized and ready to rock */
|
|
47
|
+
onReady?: HookOnReady;
|
|
48
|
+
/** This hook is triggered when a survey is displayed on screen (also triggered when page is reloaded) */
|
|
49
|
+
onSurveyShowed?: HookOnSurveyShowed;
|
|
50
|
+
/** This hook is triggered when a survey is started */
|
|
51
|
+
onSurveyStarted?: HookOnSurveyStarted;
|
|
52
|
+
/** This hook is triggered when a question is answered */
|
|
53
|
+
onQuestionReplied?: HookOnQuestionReplied;
|
|
54
|
+
/** This hook is triggered when a survey is completed */
|
|
55
|
+
onSurveyCompleted?: HookOnSurveyCompleted;
|
|
56
|
+
/** This hook is triggered when a survey is hidden */
|
|
57
|
+
onSurveyHidden?: HookOnSurveyHidden;
|
|
58
|
+
};
|
package/dist/es/index.d.ts
CHANGED
package/docs/README.md
CHANGED
|
@@ -6,13 +6,31 @@
|
|
|
6
6
|
|
|
7
7
|
### Type Aliases
|
|
8
8
|
|
|
9
|
+
- [Channel](README.md#channel)
|
|
10
|
+
- [ChannelType](README.md#channeltype)
|
|
11
|
+
- [HookCommonProperties](README.md#hookcommonproperties)
|
|
12
|
+
- [HookOnQuestionReplied](README.md#hookonquestionreplied)
|
|
13
|
+
- [HookOnReady](README.md#hookonready)
|
|
14
|
+
- [HookOnSurveyCompleted](README.md#hookonsurveycompleted)
|
|
15
|
+
- [HookOnSurveyHidden](README.md#hookonsurveyhidden)
|
|
16
|
+
- [HookOnSurveyShowed](README.md#hookonsurveyshowed)
|
|
17
|
+
- [HookOnSurveyStarted](README.md#hookonsurveystarted)
|
|
9
18
|
- [Hooks](README.md#hooks)
|
|
10
19
|
- [PropertyRecord](README.md#propertyrecord)
|
|
11
20
|
- [PropertyType](README.md#propertytype)
|
|
21
|
+
- [ResponseItem](README.md#responseitem)
|
|
22
|
+
- [ResponseItemAnswer](README.md#responseitemanswer)
|
|
23
|
+
- [ResponseItemQuestion](README.md#responseitemquestion)
|
|
24
|
+
- [ResponseStatus](README.md#responsestatus)
|
|
12
25
|
- [ScreebFunction](README.md#screebfunction)
|
|
13
26
|
- [ScreebIdentityGetReturn](README.md#screebidentitygetreturn)
|
|
14
27
|
- [ScreebObject](README.md#screebobject)
|
|
15
28
|
- [ScreebOptions](README.md#screeboptions)
|
|
29
|
+
- [Survey](README.md#survey)
|
|
30
|
+
- [SurveyFormat](README.md#surveyformat)
|
|
31
|
+
- [SurveyPosition](README.md#surveyposition)
|
|
32
|
+
- [SurveySize](README.md#surveysize)
|
|
33
|
+
- [User](README.md#user)
|
|
16
34
|
|
|
17
35
|
### Functions
|
|
18
36
|
|
|
@@ -35,6 +53,161 @@
|
|
|
35
53
|
|
|
36
54
|
## Type Aliases
|
|
37
55
|
|
|
56
|
+
### Channel
|
|
57
|
+
|
|
58
|
+
Ƭ **Channel**: `Object`
|
|
59
|
+
|
|
60
|
+
#### Type declaration
|
|
61
|
+
|
|
62
|
+
| Name | Type |
|
|
63
|
+
| :------ | :------ |
|
|
64
|
+
| `id` | `string` |
|
|
65
|
+
| `type` | [`ChannelType`](README.md#channeltype) |
|
|
66
|
+
|
|
67
|
+
___
|
|
68
|
+
|
|
69
|
+
### ChannelType
|
|
70
|
+
|
|
71
|
+
Ƭ **ChannelType**: ``"widget"`` \| ``"ios"`` \| ``"android"``
|
|
72
|
+
|
|
73
|
+
___
|
|
74
|
+
|
|
75
|
+
### HookCommonProperties
|
|
76
|
+
|
|
77
|
+
Ƭ **HookCommonProperties**: `Object`
|
|
78
|
+
|
|
79
|
+
#### Type declaration
|
|
80
|
+
|
|
81
|
+
| Name | Type |
|
|
82
|
+
| :------ | :------ |
|
|
83
|
+
| `channel` | [`Channel`](README.md#channel) |
|
|
84
|
+
| `survey` | [`Survey`](README.md#survey) |
|
|
85
|
+
| `user` | [`User`](README.md#user) |
|
|
86
|
+
|
|
87
|
+
___
|
|
88
|
+
|
|
89
|
+
### HookOnQuestionReplied
|
|
90
|
+
|
|
91
|
+
Ƭ **HookOnQuestionReplied**: (`data`: [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `answer`: [`ResponseItemAnswer`](README.md#responseitemanswer) ; `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] ; `question`: [`ResponseItemQuestion`](README.md#responseitemquestion) ; `status`: ``null`` } }) => `void`
|
|
92
|
+
|
|
93
|
+
#### Type declaration
|
|
94
|
+
|
|
95
|
+
▸ (`data`): `void`
|
|
96
|
+
|
|
97
|
+
##### Parameters
|
|
98
|
+
|
|
99
|
+
| Name | Type |
|
|
100
|
+
| :------ | :------ |
|
|
101
|
+
| `data` | [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `answer`: [`ResponseItemAnswer`](README.md#responseitemanswer) ; `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] ; `question`: [`ResponseItemQuestion`](README.md#responseitemquestion) ; `status`: ``null`` } } |
|
|
102
|
+
|
|
103
|
+
##### Returns
|
|
104
|
+
|
|
105
|
+
`void`
|
|
106
|
+
|
|
107
|
+
___
|
|
108
|
+
|
|
109
|
+
### HookOnReady
|
|
110
|
+
|
|
111
|
+
Ƭ **HookOnReady**: (`data`: { `channel`: [`Channel`](README.md#channel) ; `user`: [`User`](README.md#user) }) => `void`
|
|
112
|
+
|
|
113
|
+
#### Type declaration
|
|
114
|
+
|
|
115
|
+
▸ (`data`): `void`
|
|
116
|
+
|
|
117
|
+
##### Parameters
|
|
118
|
+
|
|
119
|
+
| Name | Type |
|
|
120
|
+
| :------ | :------ |
|
|
121
|
+
| `data` | `Object` |
|
|
122
|
+
| `data.channel` | [`Channel`](README.md#channel) |
|
|
123
|
+
| `data.user` | [`User`](README.md#user) |
|
|
124
|
+
|
|
125
|
+
##### Returns
|
|
126
|
+
|
|
127
|
+
`void`
|
|
128
|
+
|
|
129
|
+
___
|
|
130
|
+
|
|
131
|
+
### HookOnSurveyCompleted
|
|
132
|
+
|
|
133
|
+
Ƭ **HookOnSurveyCompleted**: (`data`: [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } }) => `void`
|
|
134
|
+
|
|
135
|
+
#### Type declaration
|
|
136
|
+
|
|
137
|
+
▸ (`data`): `void`
|
|
138
|
+
|
|
139
|
+
##### Parameters
|
|
140
|
+
|
|
141
|
+
| Name | Type |
|
|
142
|
+
| :------ | :------ |
|
|
143
|
+
| `data` | [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } } |
|
|
144
|
+
|
|
145
|
+
##### Returns
|
|
146
|
+
|
|
147
|
+
`void`
|
|
148
|
+
|
|
149
|
+
___
|
|
150
|
+
|
|
151
|
+
### HookOnSurveyHidden
|
|
152
|
+
|
|
153
|
+
Ƭ **HookOnSurveyHidden**: (`data`: [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `hide_reason`: [`ResponseStatus`](README.md#responsestatus) ; `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } }) => `void`
|
|
154
|
+
|
|
155
|
+
#### Type declaration
|
|
156
|
+
|
|
157
|
+
▸ (`data`): `void`
|
|
158
|
+
|
|
159
|
+
##### Parameters
|
|
160
|
+
|
|
161
|
+
| Name | Type |
|
|
162
|
+
| :------ | :------ |
|
|
163
|
+
| `data` | [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `hide_reason`: [`ResponseStatus`](README.md#responsestatus) ; `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } } |
|
|
164
|
+
|
|
165
|
+
##### Returns
|
|
166
|
+
|
|
167
|
+
`void`
|
|
168
|
+
|
|
169
|
+
___
|
|
170
|
+
|
|
171
|
+
### HookOnSurveyShowed
|
|
172
|
+
|
|
173
|
+
Ƭ **HookOnSurveyShowed**: (`data`: [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } }) => `void`
|
|
174
|
+
|
|
175
|
+
#### Type declaration
|
|
176
|
+
|
|
177
|
+
▸ (`data`): `void`
|
|
178
|
+
|
|
179
|
+
##### Parameters
|
|
180
|
+
|
|
181
|
+
| Name | Type |
|
|
182
|
+
| :------ | :------ |
|
|
183
|
+
| `data` | [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } } |
|
|
184
|
+
|
|
185
|
+
##### Returns
|
|
186
|
+
|
|
187
|
+
`void`
|
|
188
|
+
|
|
189
|
+
___
|
|
190
|
+
|
|
191
|
+
### HookOnSurveyStarted
|
|
192
|
+
|
|
193
|
+
Ƭ **HookOnSurveyStarted**: (`data`: [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `id`: `string` } }) => `void`
|
|
194
|
+
|
|
195
|
+
#### Type declaration
|
|
196
|
+
|
|
197
|
+
▸ (`data`): `void`
|
|
198
|
+
|
|
199
|
+
##### Parameters
|
|
200
|
+
|
|
201
|
+
| Name | Type |
|
|
202
|
+
| :------ | :------ |
|
|
203
|
+
| `data` | [`HookCommonProperties`](README.md#hookcommonproperties) & { `response`: { `id`: `string` } } |
|
|
204
|
+
|
|
205
|
+
##### Returns
|
|
206
|
+
|
|
207
|
+
`void`
|
|
208
|
+
|
|
209
|
+
___
|
|
210
|
+
|
|
38
211
|
### Hooks
|
|
39
212
|
|
|
40
213
|
Ƭ **Hooks**: `Object`
|
|
@@ -45,12 +218,12 @@ This is the Screeb tag hooks object.
|
|
|
45
218
|
|
|
46
219
|
| Name | Type | Description |
|
|
47
220
|
| :------ | :------ | :------ |
|
|
48
|
-
| `onQuestionReplied?` | `HookOnQuestionReplied` | This hook is triggered when a question is answered |
|
|
49
|
-
| `onReady?` | `HookOnReady` | This hook is triggered when Screeb SD is loaded, initialized and ready to rock |
|
|
50
|
-
| `onSurveyCompleted?` | `HookOnSurveyCompleted` | This hook is triggered when a survey is completed |
|
|
51
|
-
| `onSurveyHidden?` | `HookOnSurveyHidden` | This hook is triggered when a survey is hidden |
|
|
52
|
-
| `onSurveyShowed?` | `HookOnSurveyShowed` | This hook is triggered when a survey is displayed on screen (also triggered when page is reloaded) |
|
|
53
|
-
| `onSurveyStarted?` | `HookOnSurveyStarted` | This hook is triggered when a survey is started |
|
|
221
|
+
| `onQuestionReplied?` | [`HookOnQuestionReplied`](README.md#hookonquestionreplied) | This hook is triggered when a question is answered |
|
|
222
|
+
| `onReady?` | [`HookOnReady`](README.md#hookonready) | This hook is triggered when Screeb SD is loaded, initialized and ready to rock |
|
|
223
|
+
| `onSurveyCompleted?` | [`HookOnSurveyCompleted`](README.md#hookonsurveycompleted) | This hook is triggered when a survey is completed |
|
|
224
|
+
| `onSurveyHidden?` | [`HookOnSurveyHidden`](README.md#hookonsurveyhidden) | This hook is triggered when a survey is hidden |
|
|
225
|
+
| `onSurveyShowed?` | [`HookOnSurveyShowed`](README.md#hookonsurveyshowed) | This hook is triggered when a survey is displayed on screen (also triggered when page is reloaded) |
|
|
226
|
+
| `onSurveyStarted?` | [`HookOnSurveyStarted`](README.md#hookonsurveystarted) | This hook is triggered when a survey is started |
|
|
54
227
|
| `version` | `string` | This defines the version of hooks and their data |
|
|
55
228
|
|
|
56
229
|
___
|
|
@@ -75,6 +248,53 @@ This is property types that are supported by Screeb.
|
|
|
75
248
|
|
|
76
249
|
___
|
|
77
250
|
|
|
251
|
+
### ResponseItem
|
|
252
|
+
|
|
253
|
+
Ƭ **ResponseItem**: `Object`
|
|
254
|
+
|
|
255
|
+
#### Type declaration
|
|
256
|
+
|
|
257
|
+
| Name | Type |
|
|
258
|
+
| :------ | :------ |
|
|
259
|
+
| `answer` | [`ResponseItemAnswer`](README.md#responseitemanswer) |
|
|
260
|
+
| `question` | [`ResponseItemQuestion`](README.md#responseitemquestion) |
|
|
261
|
+
|
|
262
|
+
___
|
|
263
|
+
|
|
264
|
+
### ResponseItemAnswer
|
|
265
|
+
|
|
266
|
+
Ƭ **ResponseItemAnswer**: `Object`
|
|
267
|
+
|
|
268
|
+
#### Type declaration
|
|
269
|
+
|
|
270
|
+
| Name | Type |
|
|
271
|
+
| :------ | :------ |
|
|
272
|
+
| `fields?` | { `boolean?`: `boolean` ; `number?`: `number` ; `text?`: `string` ; `time?`: `string` ; `type`: ``"string"`` \| ``"number"`` \| ``"boolean"`` \| ``"none"`` \| ``"time"`` \| ``"file"`` }[] |
|
|
273
|
+
| `replied_at?` | `string` |
|
|
274
|
+
|
|
275
|
+
___
|
|
276
|
+
|
|
277
|
+
### ResponseItemQuestion
|
|
278
|
+
|
|
279
|
+
Ƭ **ResponseItemQuestion**: `Object`
|
|
280
|
+
|
|
281
|
+
#### Type declaration
|
|
282
|
+
|
|
283
|
+
| Name | Type |
|
|
284
|
+
| :------ | :------ |
|
|
285
|
+
| `id` | `string` |
|
|
286
|
+
| `title` | `string` |
|
|
287
|
+
| `type` | ``"text"`` \| ``"video"`` |
|
|
288
|
+
| `url?` | `string` |
|
|
289
|
+
|
|
290
|
+
___
|
|
291
|
+
|
|
292
|
+
### ResponseStatus
|
|
293
|
+
|
|
294
|
+
Ƭ **ResponseStatus**: ``"displayed"`` \| ``"started"`` \| ``"ended"`` \| ``"closed"`` \| ``"interrupted"``
|
|
295
|
+
|
|
296
|
+
___
|
|
297
|
+
|
|
78
298
|
### ScreebFunction
|
|
79
299
|
|
|
80
300
|
Ƭ **ScreebFunction**: (...`_`: `unknown`[]) => `void` \| `Promise`<`unknown`\>
|
|
@@ -136,6 +356,52 @@ This is the Screeb tag options object.
|
|
|
136
356
|
| `screebEndpoint?` | `string` | Please don't do this. |
|
|
137
357
|
| `window?` | `Window` | If you're running Screeb tag in an iframe, please set the inner window here. |
|
|
138
358
|
|
|
359
|
+
___
|
|
360
|
+
|
|
361
|
+
### Survey
|
|
362
|
+
|
|
363
|
+
Ƭ **Survey**: `Object`
|
|
364
|
+
|
|
365
|
+
#### Type declaration
|
|
366
|
+
|
|
367
|
+
| Name | Type |
|
|
368
|
+
| :------ | :------ |
|
|
369
|
+
| `id` | `string` |
|
|
370
|
+
| `survey_format` | [`SurveyFormat`](README.md#surveyformat) |
|
|
371
|
+
| `survey_position` | [`SurveyPosition`](README.md#surveyposition) |
|
|
372
|
+
| `survey_size` | ``100`` |
|
|
373
|
+
|
|
374
|
+
___
|
|
375
|
+
|
|
376
|
+
### SurveyFormat
|
|
377
|
+
|
|
378
|
+
Ƭ **SurveyFormat**: ``"conversationnal"`` \| ``"cards"``
|
|
379
|
+
|
|
380
|
+
___
|
|
381
|
+
|
|
382
|
+
### SurveyPosition
|
|
383
|
+
|
|
384
|
+
Ƭ **SurveyPosition**: ``"center-left"`` \| ``"center-center"`` \| ``"center-right"`` \| ``"bottom-left"`` \| ``"bottom-center"`` \| ``"bottom-right"``
|
|
385
|
+
|
|
386
|
+
___
|
|
387
|
+
|
|
388
|
+
### SurveySize
|
|
389
|
+
|
|
390
|
+
Ƭ **SurveySize**: ``25`` \| ``50`` \| ``75`` \| ``100`` \| ``125`` \| ``150``
|
|
391
|
+
|
|
392
|
+
___
|
|
393
|
+
|
|
394
|
+
### User
|
|
395
|
+
|
|
396
|
+
Ƭ **User**: `Object`
|
|
397
|
+
|
|
398
|
+
#### Type declaration
|
|
399
|
+
|
|
400
|
+
| Name | Type |
|
|
401
|
+
| :------ | :------ |
|
|
402
|
+
| `anonymous_id` | `string` |
|
|
403
|
+
| `userId?` | `string` |
|
|
404
|
+
|
|
139
405
|
## Functions
|
|
140
406
|
|
|
141
407
|
### close
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@screeb/sdk-browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Screeb's browser sdk.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"product discovery",
|
|
@@ -25,13 +25,8 @@
|
|
|
25
25
|
"author": "Screeb's frontend team",
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"type": "module",
|
|
28
|
-
"exports": {
|
|
29
|
-
"./package.json": "./package.json",
|
|
30
|
-
".": {
|
|
31
|
-
"import": "./dist/es/index.js"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
28
|
"module": "dist/es/index.js",
|
|
29
|
+
"main": "dist/cjs/index.js",
|
|
35
30
|
"types": "dist/es/index.d.ts",
|
|
36
31
|
"files": [
|
|
37
32
|
"dist",
|
|
@@ -43,11 +38,11 @@
|
|
|
43
38
|
"build:doc": "typedoc src/index.ts",
|
|
44
39
|
"clean": "rm -Rf dist",
|
|
45
40
|
"lint": "eslint .",
|
|
46
|
-
"test": "
|
|
41
|
+
"test": "echo 'test disabled'"
|
|
47
42
|
},
|
|
48
43
|
"devDependencies": {
|
|
49
44
|
"@screeb/eslint-config": "^0.1.6",
|
|
50
|
-
"@screeb/typescript-config": "^0.1.
|
|
45
|
+
"@screeb/typescript-config": "^0.1.8",
|
|
51
46
|
"@types/jest": "^29.5.5",
|
|
52
47
|
"@types/node": "^20.8.4",
|
|
53
48
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|