@screeb/sdk-browser 0.1.10 → 0.1.12

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.
@@ -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;
@@ -1,5 +1,6 @@
1
1
  import { Hooks, PropertyRecord, ScreebIdentityGetReturn, ScreebOptions } from "./types";
2
2
  export * from "./types";
3
+ export * from "./hooks.types";
3
4
  /**
4
5
  * Appends Screeb tag into your dom.
5
6
  *
@@ -63,7 +64,7 @@ export declare const init: (websiteId: string, userId?: string, userProperties?:
63
64
  * console.log(Screeb.isLoaded()); // true
64
65
  * ```
65
66
  */
66
- export declare const isLoaded: () => boolean;
67
+ export declare const isLoaded: () => boolean | undefined;
67
68
  /**
68
69
  * Shutdowns current Screeb session.
69
70
  *
@@ -1,11 +1,11 @@
1
1
  var SCREEB_TAG_ENDPOINT = "https://t.screeb.app/tag.js";
2
- var _window = window;
2
+ var _window = typeof window === "undefined" ? undefined : window;
3
3
  var callScreebCommand = function () {
4
4
  var args = [];
5
5
  for (var _i = 0; _i < arguments.length; _i++) {
6
6
  args[_i] = arguments[_i];
7
7
  }
8
- if (_window.$screeb) {
8
+ if (_window === null || _window === void 0 ? void 0 : _window.$screeb) {
9
9
  return _window.$screeb.apply(_window.$screeb, args);
10
10
  }
11
11
  return Promise.reject("[Screeb] Screeb.load() must be called before any other function.");
@@ -42,7 +42,7 @@ var load = function (options) {
42
42
  }
43
43
  return new Promise(function (a, b) {
44
44
  var _a;
45
- if (_window.$screeb) {
45
+ if (_window === null || _window === void 0 ? void 0 : _window.$screeb) {
46
46
  return (_window.$screeb.q = (_a = _window.$screeb.q) !== null && _a !== void 0 ? _a : []).push({
47
47
  args: args,
48
48
  ko: b,
@@ -117,7 +117,7 @@ var init = function (websiteId, userId, userProperties, hooks) {
117
117
  * ```
118
118
  */
119
119
  var isLoaded = function () {
120
- return Boolean(_window.$screeb) && typeof _window.$screeb === "function";
120
+ return (_window === null || _window === void 0 ? void 0 : _window.$screeb) && typeof _window.$screeb === "function";
121
121
  };
122
122
  /**
123
123
  * Shutdowns current Screeb session.
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
@@ -477,13 +743,13 @@ ___
477
743
 
478
744
  ### isLoaded
479
745
 
480
- ▸ **isLoaded**(): `boolean`
746
+ ▸ **isLoaded**(): `undefined` \| `boolean`
481
747
 
482
748
  Checks if Screeb tag has been loaded.
483
749
 
484
750
  #### Returns
485
751
 
486
- `boolean`
752
+ `undefined` \| `boolean`
487
753
 
488
754
  **`Example`**
489
755
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screeb/sdk-browser",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "Screeb's browser sdk.",
5
5
  "keywords": [
6
6
  "product discovery",
@@ -28,11 +28,20 @@
28
28
  "exports": {
29
29
  "./package.json": "./package.json",
30
30
  ".": {
31
- "import": "./dist/es/index.js"
31
+ "import": {
32
+ "types": "./dist/index.d.ts",
33
+ "default": "./dist/index.es.js"
34
+ },
35
+ "require": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.cjs.js"
38
+ }
32
39
  }
33
40
  },
34
- "module": "dist/es/index.js",
35
- "types": "dist/es/index.d.ts",
41
+ "module": "dist/index.es.js",
42
+ "main": "dist/index.cjs.js",
43
+ "jsnext:main": "dist/index.es.js",
44
+ "types": "dist/index.d.ts",
36
45
  "files": [
37
46
  "dist",
38
47
  "docs",
@@ -43,11 +52,11 @@
43
52
  "build:doc": "typedoc src/index.ts",
44
53
  "clean": "rm -Rf dist",
45
54
  "lint": "eslint .",
46
- "test": "jest"
55
+ "test": "echo 'test disabled'"
47
56
  },
48
57
  "devDependencies": {
49
58
  "@screeb/eslint-config": "^0.1.6",
50
- "@screeb/typescript-config": "^0.1.6",
59
+ "@screeb/typescript-config": "^0.1.7",
51
60
  "@types/jest": "^29.5.5",
52
61
  "@types/node": "^20.8.4",
53
62
  "@typescript-eslint/eslint-plugin": "^6.7.5",
File without changes
File without changes