@screeb/sdk-react 0.7.1 → 0.8.0

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.
@@ -151,7 +151,7 @@ var isSSR = typeof window === "undefined";
151
151
  var CONSTANTS = { version: "0.0.0-dev" };
152
152
  var isInitialized = false;
153
153
  var ScreebProvider = function (_a) {
154
- var websiteId = _a.websiteId, userId = _a.userId, userProperties = _a.userProperties, hooks = _a.hooks, language = _a.language, children = _a.children, _b = _a.shouldLoad, shouldLoad = _b === void 0 ? !isSSR : _b, _c = _a.autoInit, autoInit = _c === void 0 ? false : _c, options = _a.options, rest = __rest(_a, ["websiteId", "userId", "userProperties", "hooks", "language", "children", "shouldLoad", "autoInit", "options"]);
154
+ var websiteId = _a.websiteId, userId = _a.userId, userProperties = _a.userProperties, hooks = _a.hooks, language = _a.language, spaNavigationHandler = _a.spaNavigationHandler, children = _a.children, _b = _a.shouldLoad, shouldLoad = _b === void 0 ? !isSSR : _b, _c = _a.autoInit, autoInit = _c === void 0 ? false : _c, options = _a.options, rest = __rest(_a, ["websiteId", "userId", "userProperties", "hooks", "language", "spaNavigationHandler", "children", "shouldLoad", "autoInit", "options"]);
155
155
  var isLoaded = React__namespace.useRef(Screeb__namespace.isLoaded());
156
156
  var currentUserId = React__namespace.useRef(userId);
157
157
  // Allow data-x attributes, see https://github.com/devrnt/react-use-screeb/issues/478
@@ -270,12 +270,12 @@ var ScreebProvider = function (_a) {
270
270
  case 1: return [2 /*return*/, _a.sent()];
271
271
  }
272
272
  }); }); }, []);
273
- var init = React__namespace.useCallback(function (websiteId, userId, userProperties, hooks, language) { return __awaiter(void 0, void 0, void 0, function () {
273
+ var init = React__namespace.useCallback(function (websiteId, userId, userProperties, hooks, language, spaNavigationHandler) { return __awaiter(void 0, void 0, void 0, function () {
274
274
  return __generator(this, function (_a) {
275
275
  switch (_a.label) {
276
276
  case 0: return [4 /*yield*/, ensureScreeb("init", function () {
277
277
  if (!isInitialized) {
278
- Screeb__namespace.init(websiteId, userId, userProperties, hooks, language);
278
+ Screeb__namespace.init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler);
279
279
  isInitialized = true;
280
280
  isLoaded.current = true;
281
281
  }
@@ -295,7 +295,7 @@ var ScreebProvider = function (_a) {
295
295
  isLoaded.current = true;
296
296
  if (!autoInit) return [3 /*break*/, 3];
297
297
  if (!websiteId) return [3 /*break*/, 2];
298
- return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language)];
298
+ return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler)];
299
299
  case 1:
300
300
  _a.sent();
301
301
  return [3 /*break*/, 3];
@@ -361,12 +361,6 @@ var ScreebProvider = function (_a) {
361
361
  }
362
362
  });
363
363
  }); }, []);
364
- var targetingCheck = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
365
- switch (_a.label) {
366
- case 0: return [4 /*yield*/, ensureScreeb("targetingCheck", function () { return Screeb__namespace.targetingCheck(); })];
367
- case 1: return [2 /*return*/, _a.sent()];
368
- }
369
- }); }); }, []);
370
364
  var targetingDebug = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
371
365
  switch (_a.label) {
372
366
  case 0: return [4 /*yield*/, ensureScreeb("targetingDebug", function () { return Screeb__namespace.targetingDebug(); })];
@@ -406,7 +400,6 @@ var ScreebProvider = function (_a) {
406
400
  messageStart: messageStart,
407
401
  sessionReplayStop: sessionReplayStop,
408
402
  sessionReplayStart: sessionReplayStart,
409
- targetingCheck: targetingCheck,
410
403
  targetingDebug: targetingDebug,
411
404
  }); }, [
412
405
  close,
@@ -426,7 +419,6 @@ var ScreebProvider = function (_a) {
426
419
  messageStart,
427
420
  sessionReplayStop,
428
421
  sessionReplayStart,
429
- targetingCheck,
430
422
  targetingDebug,
431
423
  ]);
432
424
  if (!isSSR && shouldLoad) {
@@ -449,4 +441,4 @@ var useScreeb = function () {
449
441
 
450
442
  exports.ScreebProvider = ScreebProvider;
451
443
  exports.useScreeb = useScreeb;
452
- CONSTANTS.version = '0.7.1'
444
+ CONSTANTS.version = '0.8.0'
@@ -1,4 +1,4 @@
1
- import { HooksInit, HooksMessageStart, HooksSurveyStart, PropertyRecord, ScreebIdentityGetReturn, ScreebOptions } from "@screeb/sdk-browser";
1
+ import { HooksInit, HooksMessageStart, HooksSurveyStart, PropertyRecord, ScreebIdentityGetReturn, ScreebOptions, SpaNavigationHandler } from "@screeb/sdk-browser";
2
2
  /** Properties of Screeb provider */
3
3
  export type ScreebProps = {
4
4
  /** Your website/channel id. */
@@ -11,6 +11,8 @@ export type ScreebProps = {
11
11
  hooks?: HooksInit;
12
12
  /** The language you want to force */
13
13
  language?: string;
14
+ /** Optional handler for the `in-page-spa` "Navigate to URL" target (custom SPA routers). */
15
+ spaNavigationHandler?: SpaNavigationHandler;
14
16
  };
15
17
  /**
16
18
  * Shutdowns current Screeb session.
@@ -256,7 +258,7 @@ export type IdentityResetFunction = () => Promise<unknown>;
256
258
  * );
257
259
  * ```
258
260
  */
259
- export type InitFunction = (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => Promise<void>;
261
+ export type InitFunction = (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string, spaNavigationHandler?: SpaNavigationHandler) => Promise<void>;
260
262
  /**
261
263
  * Appends Screeb tag into your dom.
262
264
  *
@@ -359,17 +361,6 @@ export type SessionReplayStopFunction = () => Promise<unknown>;
359
361
  * ```
360
362
  */
361
363
  export type SessionReplayStartFunction = () => Promise<unknown>;
362
- /**
363
- * Forces a targeting check.
364
- *
365
- * @example
366
- * ```ts
367
- * const { targetingCheck } = useScreeb();
368
- *
369
- * targetingCheck();
370
- * ```
371
- */
372
- export type TargetingCheckFunction = () => Promise<unknown>;
373
364
  /**
374
365
  * Prints the current state of the targeting engine.
375
366
  *
@@ -414,7 +405,6 @@ export type ScreebContextValues = {
414
405
  messageStart: MessageStartFunction;
415
406
  sessionReplayStart: SessionReplayStartFunction;
416
407
  sessionReplayStop: SessionReplayStopFunction;
417
- targetingCheck: TargetingCheckFunction;
418
408
  targetingDebug: TargetingDebugFunction;
419
409
  };
420
410
  /** Properties of Screeb provider */
package/dist/es/index.mjs CHANGED
@@ -129,7 +129,7 @@ var isSSR = typeof window === "undefined";
129
129
  var CONSTANTS = { version: "0.0.0-dev" };
130
130
  var isInitialized = false;
131
131
  var ScreebProvider = function (_a) {
132
- var websiteId = _a.websiteId, userId = _a.userId, userProperties = _a.userProperties, hooks = _a.hooks, language = _a.language, children = _a.children, _b = _a.shouldLoad, shouldLoad = _b === void 0 ? !isSSR : _b, _c = _a.autoInit, autoInit = _c === void 0 ? false : _c, options = _a.options, rest = __rest(_a, ["websiteId", "userId", "userProperties", "hooks", "language", "children", "shouldLoad", "autoInit", "options"]);
132
+ var websiteId = _a.websiteId, userId = _a.userId, userProperties = _a.userProperties, hooks = _a.hooks, language = _a.language, spaNavigationHandler = _a.spaNavigationHandler, children = _a.children, _b = _a.shouldLoad, shouldLoad = _b === void 0 ? !isSSR : _b, _c = _a.autoInit, autoInit = _c === void 0 ? false : _c, options = _a.options, rest = __rest(_a, ["websiteId", "userId", "userProperties", "hooks", "language", "spaNavigationHandler", "children", "shouldLoad", "autoInit", "options"]);
133
133
  var isLoaded = React.useRef(Screeb.isLoaded());
134
134
  var currentUserId = React.useRef(userId);
135
135
  // Allow data-x attributes, see https://github.com/devrnt/react-use-screeb/issues/478
@@ -248,12 +248,12 @@ var ScreebProvider = function (_a) {
248
248
  case 1: return [2 /*return*/, _a.sent()];
249
249
  }
250
250
  }); }); }, []);
251
- var init = React.useCallback(function (websiteId, userId, userProperties, hooks, language) { return __awaiter(void 0, void 0, void 0, function () {
251
+ var init = React.useCallback(function (websiteId, userId, userProperties, hooks, language, spaNavigationHandler) { return __awaiter(void 0, void 0, void 0, function () {
252
252
  return __generator(this, function (_a) {
253
253
  switch (_a.label) {
254
254
  case 0: return [4 /*yield*/, ensureScreeb("init", function () {
255
255
  if (!isInitialized) {
256
- Screeb.init(websiteId, userId, userProperties, hooks, language);
256
+ Screeb.init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler);
257
257
  isInitialized = true;
258
258
  isLoaded.current = true;
259
259
  }
@@ -273,7 +273,7 @@ var ScreebProvider = function (_a) {
273
273
  isLoaded.current = true;
274
274
  if (!autoInit) return [3 /*break*/, 3];
275
275
  if (!websiteId) return [3 /*break*/, 2];
276
- return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language)];
276
+ return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler)];
277
277
  case 1:
278
278
  _a.sent();
279
279
  return [3 /*break*/, 3];
@@ -339,12 +339,6 @@ var ScreebProvider = function (_a) {
339
339
  }
340
340
  });
341
341
  }); }, []);
342
- var targetingCheck = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
343
- switch (_a.label) {
344
- case 0: return [4 /*yield*/, ensureScreeb("targetingCheck", function () { return Screeb.targetingCheck(); })];
345
- case 1: return [2 /*return*/, _a.sent()];
346
- }
347
- }); }); }, []);
348
342
  var targetingDebug = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
349
343
  switch (_a.label) {
350
344
  case 0: return [4 /*yield*/, ensureScreeb("targetingDebug", function () { return Screeb.targetingDebug(); })];
@@ -384,7 +378,6 @@ var ScreebProvider = function (_a) {
384
378
  messageStart: messageStart,
385
379
  sessionReplayStop: sessionReplayStop,
386
380
  sessionReplayStart: sessionReplayStart,
387
- targetingCheck: targetingCheck,
388
381
  targetingDebug: targetingDebug,
389
382
  }); }, [
390
383
  close,
@@ -404,7 +397,6 @@ var ScreebProvider = function (_a) {
404
397
  messageStart,
405
398
  sessionReplayStop,
406
399
  sessionReplayStart,
407
- targetingCheck,
408
400
  targetingDebug,
409
401
  ]);
410
402
  if (!isSSR && shouldLoad) {
@@ -426,4 +418,4 @@ var useScreeb = function () {
426
418
  };
427
419
 
428
420
  export { ScreebProvider, useScreeb };
429
- CONSTANTS.version = '0.7.1'
421
+ CONSTANTS.version = '0.8.0'
@@ -1,4 +1,4 @@
1
- import { HooksInit, HooksMessageStart, HooksSurveyStart, PropertyRecord, ScreebIdentityGetReturn, ScreebOptions } from "@screeb/sdk-browser";
1
+ import { HooksInit, HooksMessageStart, HooksSurveyStart, PropertyRecord, ScreebIdentityGetReturn, ScreebOptions, SpaNavigationHandler } from "@screeb/sdk-browser";
2
2
  /** Properties of Screeb provider */
3
3
  export type ScreebProps = {
4
4
  /** Your website/channel id. */
@@ -11,6 +11,8 @@ export type ScreebProps = {
11
11
  hooks?: HooksInit;
12
12
  /** The language you want to force */
13
13
  language?: string;
14
+ /** Optional handler for the `in-page-spa` "Navigate to URL" target (custom SPA routers). */
15
+ spaNavigationHandler?: SpaNavigationHandler;
14
16
  };
15
17
  /**
16
18
  * Shutdowns current Screeb session.
@@ -256,7 +258,7 @@ export type IdentityResetFunction = () => Promise<unknown>;
256
258
  * );
257
259
  * ```
258
260
  */
259
- export type InitFunction = (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => Promise<void>;
261
+ export type InitFunction = (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string, spaNavigationHandler?: SpaNavigationHandler) => Promise<void>;
260
262
  /**
261
263
  * Appends Screeb tag into your dom.
262
264
  *
@@ -359,17 +361,6 @@ export type SessionReplayStopFunction = () => Promise<unknown>;
359
361
  * ```
360
362
  */
361
363
  export type SessionReplayStartFunction = () => Promise<unknown>;
362
- /**
363
- * Forces a targeting check.
364
- *
365
- * @example
366
- * ```ts
367
- * const { targetingCheck } = useScreeb();
368
- *
369
- * targetingCheck();
370
- * ```
371
- */
372
- export type TargetingCheckFunction = () => Promise<unknown>;
373
364
  /**
374
365
  * Prints the current state of the targeting engine.
375
366
  *
@@ -414,7 +405,6 @@ export type ScreebContextValues = {
414
405
  messageStart: MessageStartFunction;
415
406
  sessionReplayStart: SessionReplayStartFunction;
416
407
  sessionReplayStop: SessionReplayStopFunction;
417
- targetingCheck: TargetingCheckFunction;
418
408
  targetingDebug: TargetingDebugFunction;
419
409
  };
420
410
  /** Properties of Screeb provider */
package/docs/README.md CHANGED
@@ -26,7 +26,6 @@
26
26
  - [SessionReplayStopFunction](README.md#sessionreplaystopfunction)
27
27
  - [SurveyCloseFunction](README.md#surveyclosefunction)
28
28
  - [SurveyStartFunction](README.md#surveystartfunction)
29
- - [TargetingCheckFunction](README.md#targetingcheckfunction)
30
29
  - [TargetingDebugFunction](README.md#targetingdebugfunction)
31
30
 
32
31
  ### Functions
@@ -368,7 +367,7 @@ ___
368
367
 
369
368
  ### InitFunction
370
369
 
371
- Ƭ **InitFunction**: (`websiteId`: `string`, `userId?`: `string`, `userProperties?`: `PropertyRecord`, `hooks?`: `HooksInit`, `language?`: `string`) => `Promise`\<`void`\>
370
+ Ƭ **InitFunction**: (`websiteId`: `string`, `userId?`: `string`, `userProperties?`: `PropertyRecord`, `hooks?`: `HooksInit`, `language?`: `string`, `spaNavigationHandler?`: `SpaNavigationHandler`) => `Promise`\<`void`\>
372
371
 
373
372
  Initializes Screeb tag.
374
373
 
@@ -393,7 +392,7 @@ init(
393
392
 
394
393
  #### Type declaration
395
394
 
396
- ▸ (`websiteId`, `userId?`, `userProperties?`, `hooks?`, `language?`): `Promise`\<`void`\>
395
+ ▸ (`websiteId`, `userId?`, `userProperties?`, `hooks?`, `language?`, `spaNavigationHandler?`): `Promise`\<`void`\>
397
396
 
398
397
  ##### Parameters
399
398
 
@@ -404,6 +403,7 @@ init(
404
403
  | `userProperties?` | `PropertyRecord` | The properties of your user. ```text Requirements: - Property names must be limited to 128 characters - No more than 1000 attributes - Supported types for values: string, number, boolean and Date ``` |
405
404
  | `hooks?` | `HooksInit` | - |
406
405
  | `language?` | `string` | Force a specific language for the tag. eg: 'en'. default: browser language. |
406
+ | `spaNavigationHandler?` | `SpaNavigationHandler` | - |
407
407
 
408
408
  ##### Returns
409
409
 
@@ -533,7 +533,6 @@ Screeb context API
533
533
  | `sessionReplayStop` | [`SessionReplayStopFunction`](README.md#sessionreplaystopfunction) |
534
534
  | `surveyClose` | [`SurveyCloseFunction`](README.md#surveyclosefunction) |
535
535
  | `surveyStart` | [`SurveyStartFunction`](README.md#surveystartfunction) |
536
- | `targetingCheck` | [`TargetingCheckFunction`](README.md#targetingcheckfunction) |
537
536
  | `targetingDebug` | [`TargetingDebugFunction`](README.md#targetingdebugfunction) |
538
537
 
539
538
  ___
@@ -550,6 +549,7 @@ Properties of Screeb provider
550
549
  | :------ | :------ | :------ |
551
550
  | `hooks?` | `HooksInit` | Hooks to define callback for various event |
552
551
  | `language?` | `string` | The language you want to force |
552
+ | `spaNavigationHandler?` | `SpaNavigationHandler` | Optional handler for the `in-page-spa` "Navigate to URL" target (custom SPA routers). |
553
553
  | `userId?` | `string` | The unique identifier of your user. |
554
554
  | `userProperties?` | `PropertyRecord` | The properties of your user. |
555
555
  | `websiteId` | `string` | Your website/channel id. |
@@ -686,30 +686,6 @@ surveyStart(
686
686
 
687
687
  ___
688
688
 
689
- ### TargetingCheckFunction
690
-
691
- Ƭ **TargetingCheckFunction**: () => `Promise`\<`unknown`\>
692
-
693
- Forces a targeting check.
694
-
695
- **`Example`**
696
-
697
- ```ts
698
- const { targetingCheck } = useScreeb();
699
-
700
- targetingCheck();
701
- ```
702
-
703
- #### Type declaration
704
-
705
- ▸ (): `Promise`\<`unknown`\>
706
-
707
- ##### Returns
708
-
709
- `Promise`\<`unknown`\>
710
-
711
- ___
712
-
713
689
  ### TargetingDebugFunction
714
690
 
715
691
  Ƭ **TargetingDebugFunction**: () => `Promise`\<`unknown`\>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@screeb/sdk-react",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Screeb's browser sdk, optimized for React.",
5
5
  "keywords": [
6
6
  "product discovery",
@@ -41,11 +41,11 @@
41
41
  "test": "echo '@TODO'"
42
42
  },
43
43
  "dependencies": {
44
- "@screeb/sdk-browser": "^0.6.1"
44
+ "@screeb/sdk-browser": "^0.7.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@screeb/eslint-config": "^0.1.7",
48
- "@screeb/typescript-config": "^0.1.12",
47
+ "@screeb/eslint-config": "^0.1.8",
48
+ "@screeb/typescript-config": "^0.1.13",
49
49
  "@types/jest": "^29.5.14",
50
50
  "@types/node": "^20.8.10",
51
51
  "@types/react": "^18.2.79",