@screeb/sdk-browser 0.1.5 → 0.1.7

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="https://screeb.app" alt="Intercom">
2
+ <a href="https://screeb.app" alt="Screeb">
3
3
  <img src="https://raw.githubusercontent.com/ScreebApp/sdk-js/master/packages/screeb-sdk-browser/readme/screeb-logo.svg?token=GHSAT0AAAAAAB2OOPMGT2QD5TL3IRJN3CKCZDEYHJA" alt="Logo" height="120px" style="margin-top: 20px;"/>
4
4
  </a>
5
5
  </p>
@@ -9,15 +9,22 @@
9
9
 
10
10
  <b>Continuous Product Discovery, Without the Time Sink.</b>
11
11
 
12
- <a href="https://screeb.app" alt="Intercom">Screeb</a> is the only Continuous Product Discovery platform that lets you analyse users' behaviour, ask in-app questions, recruit people for interviews and analyse data in a blink with AI.
12
+ <a href="https://screeb.app" alt="Screeb">Screeb</a> is the only Continuous Product Discovery platform that lets you analyse users' behaviour, ask in-app questions, recruit people for interviews and analyse data in a blink with AI.
13
13
  </p>
14
14
 
15
15
  <p align="center">
16
- <a href="https://github.com/ScreebApp/sdk-js/actions/workflows/node.js.yml" alt="ci">
17
- <img alt="ci" src="https://github.com/ScreebApp/sdk-js/actions/workflows/node.js.yml/badge.svg">
18
- </a>
19
- <img alt="version" src="https://img.shields.io/npm/v/@screeb/sdk-browser.svg" />
20
- <img alt="minzipped size" src="https://badgen.net/bundlephobia/minzip/@screeb/sdk-browser">
16
+ <a href="https://github.com/ScreebApp/sdk-js/actions/workflows/node.js.yml" alt="ci">
17
+ <img alt="ci" src="https://github.com/ScreebApp/sdk-js/actions/workflows/node.js.yml/badge.svg">
18
+ </a>
19
+ <a href="https://www.npmjs.com/package/@screeb/sdk-browser" alt="version">
20
+ <img alt="version" src="https://img.shields.io/npm/v/@screeb/sdk-browser.svg" />
21
+ </a>
22
+ <a href="https://bundlephobia.com/package/@screeb/sdk-browser" alt="min size">
23
+ <img alt="min size" src="https://img.shields.io/bundlephobia/min/@screeb/sdk-browser">
24
+ </a>
25
+ <a href="https://bundlephobia.com/package/@screeb/sdk-browser" alt="minzipped size">
26
+ <img alt="minzipped size" src="https://img.shields.io/bundlephobia/minzip/@screeb/sdk-browser">
27
+ </a>
21
28
  <img alt="downloads" src="https://badgen.net/npm/dw/@screeb/sdk-browser" />
22
29
  </p>
23
30
 
@@ -12,9 +12,27 @@ export type ScreebOptions = {
12
12
  screebEndpoint?: string;
13
13
  };
14
14
  type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
15
+ /** This is the Screeb object publicly exposed in browser `window`. */
15
16
  export type ScreebObject = ScreebFunction & {
16
17
  q?: unknown[][];
17
18
  };
19
+ /** This is the object returned by the function `identityGet()`. */
20
+ export type ScreebIdentityGetReturn = {
21
+ /** Anonymous id given to each user */
22
+ anonymous_id: string;
23
+ /** The authenticated id assigned to the user. */
24
+ user_id: string;
25
+ /** The current user session id */
26
+ session_id: string;
27
+ /** The current user session start time */
28
+ session_start: string;
29
+ /** The current user session end time */
30
+ session_end: string;
31
+ /** The current channel id with which the tag was initialized */
32
+ channel_id: string;
33
+ /** `true` if the tag us loaded, initialized and ready to rock */
34
+ is_ready: boolean;
35
+ };
18
36
  /**
19
37
  * Appends Screeb tag into your dom.
20
38
  *
@@ -173,15 +191,6 @@ export declare const eventTrack: (eventName: string, eventProperties?: PropertyR
173
191
  * ```
174
192
  */
175
193
  export declare const identity: (userId: string, userProperties?: PropertyRecord) => void | Promise<unknown>;
176
- type ScreebIdentityGetReturn = {
177
- anonymous_id: string;
178
- user_id: string;
179
- session_id: string;
180
- session_start: string;
181
- session_end: string;
182
- channel_id: string;
183
- is_ready: boolean;
184
- };
185
194
  /**
186
195
  * Retrieves the current user identity.
187
196
  *
package/dist/es/index.js CHANGED
@@ -1,5 +1,15 @@
1
1
  var SCREEB_TAG_ENDPOINT = "https://t.screeb.app/tag.js";
2
2
  var _window = window;
3
+ var callScreebCommand = function () {
4
+ var args = [];
5
+ for (var _i = 0; _i < arguments.length; _i++) {
6
+ args[_i] = arguments[_i];
7
+ }
8
+ if (_window.$screeb) {
9
+ return _window.$screeb.apply(_window.$screeb, args);
10
+ }
11
+ return Promise.reject("[Screeb] Screeb.load() must be called before any other function.");
12
+ };
3
13
  /**
4
14
  * Appends Screeb tag into your dom.
5
15
  *
@@ -77,7 +87,7 @@ var init = function (websiteId, userId, userProperties) {
77
87
  },
78
88
  };
79
89
  }
80
- return $screeb("init", websiteId, identityObject);
90
+ return callScreebCommand("init", websiteId, identityObject);
81
91
  };
82
92
  /**
83
93
  * Checks if Screeb tag has been loaded.
@@ -91,7 +101,9 @@ var init = function (websiteId, userId, userProperties) {
91
101
  * console.log(Screeb.isLoaded()); // true
92
102
  * ```
93
103
  */
94
- var isLoaded = function () { return $screeb && typeof $screeb === "function"; };
104
+ var isLoaded = function () {
105
+ return Boolean(_window.$screeb) && typeof _window.$screeb === "function";
106
+ };
95
107
  /**
96
108
  * Shutdowns current Screeb session.
97
109
  *
@@ -102,7 +114,7 @@ var isLoaded = function () { return $screeb && typeof $screeb === "function"; };
102
114
  * Screeb.close();
103
115
  * ```
104
116
  */
105
- var close = function () { return $screeb("close"); };
117
+ var close = function () { return callScreebCommand("close"); };
106
118
  /**
107
119
  * Prints the actual state information of Screeb tag.
108
120
  *
@@ -130,7 +142,7 @@ var close = function () { return $screeb("close"); };
130
142
  * // **************************************************************
131
143
  * ```
132
144
  */
133
- var debug = function () { return $screeb("debug"); };
145
+ var debug = function () { return callScreebCommand("debug"); };
134
146
  /**
135
147
  * Tracks a user event.
136
148
  *
@@ -162,7 +174,7 @@ var debug = function () { return $screeb("debug"); };
162
174
  * );
163
175
  * ```
164
176
  */
165
- var eventTrack = function (eventName, eventProperties) { return $screeb("event.track", eventName, eventProperties); };
177
+ var eventTrack = function (eventName, eventProperties) { return callScreebCommand("event.track", eventName, eventProperties); };
166
178
  /**
167
179
  * Change the current user identity.
168
180
  * Warning: Running surveys will be closed.
@@ -192,7 +204,7 @@ var eventTrack = function (eventName, eventProperties) { return $screeb("event.t
192
204
  * ```
193
205
  */
194
206
  var identity = function (userId, userProperties) {
195
- return $screeb("identity", userId, userProperties);
207
+ return callScreebCommand("identity", userId, userProperties);
196
208
  };
197
209
  /**
198
210
  * Retrieves the current user identity.
@@ -214,7 +226,7 @@ var identity = function (userId, userProperties) {
214
226
  * ```
215
227
  */
216
228
  var identityGet = function () {
217
- return $screeb("identity.get");
229
+ return callScreebCommand("identity.get");
218
230
  };
219
231
  /**
220
232
  * Assigns the current user to a group.
@@ -246,7 +258,9 @@ var identityGet = function () {
246
258
  * );
247
259
  * ```
248
260
  */
249
- var identityGroupAssign = function (groupName, groupType, groupProperties) { return $screeb("identity.group.assign", groupType, groupName, groupProperties); };
261
+ var identityGroupAssign = function (groupName, groupType, groupProperties) {
262
+ return callScreebCommand("identity.group.assign", groupType, groupName, groupProperties);
263
+ };
250
264
  /**
251
265
  * Unassigns the current user to a group.
252
266
  *
@@ -261,7 +275,7 @@ var identityGroupAssign = function (groupName, groupType, groupProperties) { ret
261
275
  * ```
262
276
  */
263
277
  var identityGroupUnassign = function (groupName, groupType) {
264
- return $screeb("identity.group.unassign", groupType, groupName);
278
+ return callScreebCommand("identity.group.unassign", groupType, groupName);
265
279
  };
266
280
  /**
267
281
  * Adds properties to the current user identity.
@@ -299,7 +313,7 @@ var identityGroupUnassign = function (groupName, groupType) {
299
313
  * ```
300
314
  */
301
315
  var identityProperties = function (userProperties) {
302
- return $screeb("identity.properties", userProperties);
316
+ return callScreebCommand("identity.properties", userProperties);
303
317
  };
304
318
  /**
305
319
  * Resets the current user identity.
@@ -312,7 +326,7 @@ var identityProperties = function (userProperties) {
312
326
  * Screeb.identityReset();
313
327
  * ```
314
328
  */
315
- var identityReset = function () { return $screeb("identity.reset"); };
329
+ var identityReset = function () { return callScreebCommand("identity.reset"); };
316
330
  /**
317
331
  * Interrupts a running survey.
318
332
  *
@@ -323,7 +337,7 @@ var identityReset = function () { return $screeb("identity.reset"); };
323
337
  * Screeb.surveyClose();
324
338
  * ```
325
339
  */
326
- var surveyClose = function () { return $screeb("survey.close"); };
340
+ var surveyClose = function () { return callScreebCommand("survey.close"); };
327
341
  /**
328
342
  * Starts a survey by its ID.
329
343
  *
@@ -344,7 +358,7 @@ var surveyClose = function () { return $screeb("survey.close"); };
344
358
  var surveyStart = function (surveyId, allowMultipleResponses, hiddenFields) {
345
359
  if (allowMultipleResponses === void 0) { allowMultipleResponses = true; }
346
360
  if (hiddenFields === void 0) { hiddenFields = {}; }
347
- return $screeb("survey.start", surveyId, {
361
+ return callScreebCommand("survey.start", surveyId, {
348
362
  allow_multiple_responses: allowMultipleResponses,
349
363
  hidden_fields: hiddenFields,
350
364
  });
@@ -359,7 +373,7 @@ var surveyStart = function (surveyId, allowMultipleResponses, hiddenFields) {
359
373
  * Screeb.targetingCheck();
360
374
  * ```
361
375
  */
362
- var targetingCheck = function () { return $screeb("targeting.check"); };
376
+ var targetingCheck = function () { return callScreebCommand("targeting.check"); };
363
377
  /**
364
378
  * Prints the current state of the targeting engine.
365
379
  *
@@ -384,6 +398,6 @@ var targetingCheck = function () { return $screeb("targeting.check"); };
384
398
  * // - Rule of type "Capping per respondent display count": false 🔴
385
399
  * ```
386
400
  */
387
- var targetingDebug = function () { return $screeb("targeting.debug"); };
401
+ var targetingDebug = function () { return callScreebCommand("targeting.debug"); };
388
402
 
389
403
  export { close, debug, eventTrack, identity, identityGet, identityGroupAssign, identityGroupUnassign, identityProperties, identityReset, init, isLoaded, load, surveyClose, surveyStart, targetingCheck, targetingDebug };
package/docs/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  - [PropertyRecord](README.md#propertyrecord)
10
10
  - [PropertyType](README.md#propertytype)
11
+ - [ScreebIdentityGetReturn](README.md#screebidentitygetreturn)
11
12
  - [ScreebObject](README.md#screebobject)
12
13
  - [ScreebOptions](README.md#screeboptions)
13
14
 
@@ -52,10 +53,32 @@ This is property types that are supported by Screeb.
52
53
 
53
54
  ___
54
55
 
56
+ ### ScreebIdentityGetReturn
57
+
58
+ Ƭ **ScreebIdentityGetReturn**: `Object`
59
+
60
+ This is the object returned by the function `identityGet()`.
61
+
62
+ #### Type declaration
63
+
64
+ | Name | Type | Description |
65
+ | :------ | :------ | :------ |
66
+ | `anonymous_id` | `string` | Anonymous id given to each user |
67
+ | `channel_id` | `string` | The current channel id with which the tag was initialized |
68
+ | `is_ready` | `boolean` | `true` if the tag us loaded, initialized and ready to rock |
69
+ | `session_end` | `string` | The current user session end time |
70
+ | `session_id` | `string` | The current user session id |
71
+ | `session_start` | `string` | The current user session start time |
72
+ | `user_id` | `string` | The authenticated id assigned to the user. |
73
+
74
+ ___
75
+
55
76
  ### ScreebObject
56
77
 
57
78
  Ƭ **ScreebObject**: `ScreebFunction` & { `q?`: `unknown`[][] }
58
79
 
80
+ This is the Screeb object publicly exposed in browser `window`.
81
+
59
82
  ___
60
83
 
61
84
  ### ScreebOptions
@@ -209,7 +232,7 @@ ___
209
232
 
210
233
  ### identityGet
211
234
 
212
- ▸ **identityGet**(): `Promise`<`ScreebIdentityGetReturn`\>
235
+ ▸ **identityGet**(): `Promise`<[`ScreebIdentityGetReturn`](README.md#screebidentitygetreturn)\>
213
236
 
214
237
  Retrieves the current user identity.
215
238
 
@@ -232,7 +255,7 @@ console.log(await Screeb.identityGet());
232
255
 
233
256
  #### Returns
234
257
 
235
- `Promise`<`ScreebIdentityGetReturn`\>
258
+ `Promise`<[`ScreebIdentityGetReturn`](README.md#screebidentitygetreturn)\>
236
259
 
237
260
  ___
238
261
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screeb/sdk-browser",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Screeb's browser sdk.",
5
5
  "keywords": [
6
6
  "product discovery",
@@ -46,12 +46,12 @@
46
46
  "test": "jest"
47
47
  },
48
48
  "devDependencies": {
49
- "@screeb/eslint-config": "^0.1.2",
50
- "@screeb/typescript-config": "^0.1.2",
49
+ "@screeb/eslint-config": "^0.1.4",
50
+ "@screeb/typescript-config": "^0.1.4",
51
51
  "@types/jest": "^29.5.1",
52
52
  "@types/node": "^18.16.3",
53
- "@typescript-eslint/eslint-plugin": "^5.59.2",
54
- "eslint": "^8.39.0",
53
+ "@typescript-eslint/eslint-plugin": "^5.59.6",
54
+ "eslint": "^8.41.0",
55
55
  "eslint-plugin-import": "^2.27.5",
56
56
  "eslint-plugin-jest": "^27.2.1",
57
57
  "eslint-plugin-jsx-a11y": "^6.7.1",
@@ -59,9 +59,9 @@
59
59
  "jest": "^29.5.0",
60
60
  "jest-environment-jsdom": "^29.5.0",
61
61
  "prettier": "^2.8.8",
62
- "rollup": "^3.21.4",
62
+ "rollup": "^3.23.0",
63
63
  "ts-jest": "^29.1.0",
64
- "typedoc": "^0.24.6",
64
+ "typedoc": "^0.24.7",
65
65
  "typedoc-plugin-markdown": "^3.15.3"
66
66
  },
67
67
  "publishConfig": {