@screeb/sdk-react 0.6.0 → 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.
- package/README.md +36 -7
- package/dist/cjs/index.cjs +28 -22
- package/dist/cjs/types.d.ts +4 -14
- package/dist/es/index.mjs +28 -22
- package/dist/es/types.d.ts +4 -14
- package/docs/README.md +4 -28
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://screeb.app" alt="Screeb">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/ScreebApp/sdk
|
|
3
|
+
<img src="https://raw.githubusercontent.com/ScreebApp/sdk/master/packages/sdk-react/readme/screeb-logo.svg" alt="Logo" height="120px" style="margin-top: 20px;"/>
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
<h1 align="center">@screeb/sdk-react</h1>
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|
<p align="center">
|
|
16
|
-
<a href="https://github.com/ScreebApp/sdk
|
|
17
|
-
<img alt="ci" src="https://github.com/ScreebApp/sdk
|
|
16
|
+
<a href="https://github.com/ScreebApp/sdk/actions/workflows/ci.yml" alt="ci">
|
|
17
|
+
<img alt="ci" src="https://github.com/ScreebApp/sdk/actions/workflows/ci.yml/badge.svg">
|
|
18
18
|
</a>
|
|
19
19
|
<a href="https://www.npmjs.com/package/@screeb/sdk-react" alt="version">
|
|
20
20
|
<img alt="version" src="https://img.shields.io/npm/v/@screeb/sdk-react.svg" />
|
|
@@ -86,11 +86,40 @@ const HomePage = () => {
|
|
|
86
86
|
};
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
### Custom domains (AdBlocker bypass)
|
|
90
|
+
|
|
91
|
+
If you route Screeb traffic through your own domain (reverse proxy) to bypass AdBlockers, pass the
|
|
92
|
+
`endpoints` (and optionally `screebEndpoint` for the loader URL) through the provider's `options`
|
|
93
|
+
prop. Only the endpoints you provide are overridden; the rest fall back to Screeb's defaults.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<ScreebProvider
|
|
97
|
+
autoInit
|
|
98
|
+
websiteId={SCREEB_APP_ID}
|
|
99
|
+
options={{
|
|
100
|
+
screebEndpoint: "https://analytics.acme.com/sdk/tag.js",
|
|
101
|
+
endpoints: {
|
|
102
|
+
rpc: "https://analytics.acme.com/rpc",
|
|
103
|
+
static: "https://analytics.acme.com/static",
|
|
104
|
+
report: "https://analytics.acme.com/report",
|
|
105
|
+
hostedPage: "https://analytics.acme.com/hosted-page",
|
|
106
|
+
centipede: "wss://analytics.acme.com/centipede",
|
|
107
|
+
},
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<HomePage />
|
|
111
|
+
</ScreebProvider>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
All endpoints must use `https://` (or `wss://` for `centipede`) and the domains must be allow-listed
|
|
115
|
+
in **Screeb Admin → Settings → Custom Domains**. See the
|
|
116
|
+
[Custom Collector URL guide](https://developers.screeb.app/sdk-js/custom-collector-url).
|
|
117
|
+
|
|
118
|
+
For a working example, see our [Screeb React SDK example app](https://github.com/ScreebApp/sdk/tree/master/examples/example-react).
|
|
90
119
|
|
|
91
|
-
For a more advanced usage and a complete API documentation, see [documentation generated from source files](https://github.com/ScreebApp/sdk
|
|
120
|
+
For a more advanced usage and a complete API documentation, see [documentation generated from source files](https://github.com/ScreebApp/sdk/tree/master/packages/sdk-react/docs).
|
|
92
121
|
|
|
93
|
-
For further information, see [our
|
|
122
|
+
For further information, see [our developer documentation](https://developers.screeb.app/sdk-js/install).
|
|
94
123
|
|
|
95
124
|
## Support
|
|
96
125
|
For any issues, please contact our support team at support@screeb.com.
|
|
@@ -100,4 +129,4 @@ All third party contributors acknowledge that any contributions they provide wil
|
|
|
100
129
|
|
|
101
130
|
## License
|
|
102
131
|
|
|
103
|
-
Released under [MIT License](https://github.com/ScreebApp/sdk
|
|
132
|
+
Released under [MIT License](https://github.com/ScreebApp/sdk/blob/master/LICENSE).
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -38,7 +38,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
38
38
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
39
39
|
PERFORMANCE OF THIS SOFTWARE.
|
|
40
40
|
***************************************************************************** */
|
|
41
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
41
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
var __assign = function() {
|
|
@@ -75,8 +75,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
function __generator(thisArg, body) {
|
|
78
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
79
|
-
return g =
|
|
78
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
79
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
80
80
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
81
81
|
function step(op) {
|
|
82
82
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -102,6 +102,16 @@ function __generator(thisArg, body) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
function __spreadArray(to, from, pack) {
|
|
106
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
107
|
+
if (ar || !(i in from)) {
|
|
108
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
109
|
+
ar[i] = from[i];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
113
|
+
}
|
|
114
|
+
|
|
105
115
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
106
116
|
var e = new Error(message);
|
|
107
117
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -141,7 +151,7 @@ var isSSR = typeof window === "undefined";
|
|
|
141
151
|
var CONSTANTS = { version: "0.0.0-dev" };
|
|
142
152
|
var isInitialized = false;
|
|
143
153
|
var ScreebProvider = function (_a) {
|
|
144
|
-
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"]);
|
|
145
155
|
var isLoaded = React__namespace.useRef(Screeb__namespace.isLoaded());
|
|
146
156
|
var currentUserId = React__namespace.useRef(userId);
|
|
147
157
|
// Allow data-x attributes, see https://github.com/devrnt/react-use-screeb/issues/478
|
|
@@ -154,10 +164,10 @@ var ScreebProvider = function (_a) {
|
|
|
154
164
|
}
|
|
155
165
|
var ensureScreeb = React__namespace.useCallback(
|
|
156
166
|
// eslint-disable-next-line no-unused-vars
|
|
157
|
-
function (
|
|
158
|
-
|
|
159
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
+
function (functionName_1, callback_1) {
|
|
168
|
+
return __awaiter(this, arguments, void 0, function (functionName, callback, onlyLoaded) {
|
|
160
169
|
var message, message;
|
|
170
|
+
if (onlyLoaded === void 0) { onlyLoaded = false; }
|
|
161
171
|
return __generator(this, function (_a) {
|
|
162
172
|
if (!Screeb__namespace.isLoaded() && !shouldLoad) {
|
|
163
173
|
message = "Screeb instance is not loaded because `shouldLoad` is set to `false` in `ScreebProvider`";
|
|
@@ -260,12 +270,12 @@ var ScreebProvider = function (_a) {
|
|
|
260
270
|
case 1: return [2 /*return*/, _a.sent()];
|
|
261
271
|
}
|
|
262
272
|
}); }); }, []);
|
|
263
|
-
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 () {
|
|
264
274
|
return __generator(this, function (_a) {
|
|
265
275
|
switch (_a.label) {
|
|
266
276
|
case 0: return [4 /*yield*/, ensureScreeb("init", function () {
|
|
267
277
|
if (!isInitialized) {
|
|
268
|
-
Screeb__namespace.init(websiteId, userId, userProperties, hooks, language);
|
|
278
|
+
Screeb__namespace.init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler);
|
|
269
279
|
isInitialized = true;
|
|
270
280
|
isLoaded.current = true;
|
|
271
281
|
}
|
|
@@ -285,7 +295,7 @@ var ScreebProvider = function (_a) {
|
|
|
285
295
|
isLoaded.current = true;
|
|
286
296
|
if (!autoInit) return [3 /*break*/, 3];
|
|
287
297
|
if (!websiteId) return [3 /*break*/, 2];
|
|
288
|
-
return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language)];
|
|
298
|
+
return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler)];
|
|
289
299
|
case 1:
|
|
290
300
|
_a.sent();
|
|
291
301
|
return [3 /*break*/, 3];
|
|
@@ -318,9 +328,13 @@ var ScreebProvider = function (_a) {
|
|
|
318
328
|
case 1: return [2 /*return*/, _a.sent()];
|
|
319
329
|
}
|
|
320
330
|
}); }); }, []);
|
|
321
|
-
var messageStart = React__namespace.useCallback(function (
|
|
322
|
-
|
|
323
|
-
|
|
331
|
+
var messageStart = React__namespace.useCallback(function (messageId_1) {
|
|
332
|
+
var args_1 = [];
|
|
333
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
334
|
+
args_1[_i - 1] = arguments[_i];
|
|
335
|
+
}
|
|
336
|
+
return __awaiter(void 0, __spreadArray([messageId_1], args_1, true), void 0, function (messageId, allowMultipleResponses, hiddenFields, hooks, language) {
|
|
337
|
+
if (allowMultipleResponses === void 0) { allowMultipleResponses = true; }
|
|
324
338
|
return __generator(this, function (_a) {
|
|
325
339
|
switch (_a.label) {
|
|
326
340
|
case 0: return [4 /*yield*/, ensureScreeb("messageStart", function () {
|
|
@@ -347,12 +361,6 @@ var ScreebProvider = function (_a) {
|
|
|
347
361
|
}
|
|
348
362
|
});
|
|
349
363
|
}); }, []);
|
|
350
|
-
var targetingCheck = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
351
|
-
switch (_a.label) {
|
|
352
|
-
case 0: return [4 /*yield*/, ensureScreeb("targetingCheck", function () { return Screeb__namespace.targetingCheck(); })];
|
|
353
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
354
|
-
}
|
|
355
|
-
}); }); }, []);
|
|
356
364
|
var targetingDebug = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
357
365
|
switch (_a.label) {
|
|
358
366
|
case 0: return [4 /*yield*/, ensureScreeb("targetingDebug", function () { return Screeb__namespace.targetingDebug(); })];
|
|
@@ -392,7 +400,6 @@ var ScreebProvider = function (_a) {
|
|
|
392
400
|
messageStart: messageStart,
|
|
393
401
|
sessionReplayStop: sessionReplayStop,
|
|
394
402
|
sessionReplayStart: sessionReplayStart,
|
|
395
|
-
targetingCheck: targetingCheck,
|
|
396
403
|
targetingDebug: targetingDebug,
|
|
397
404
|
}); }, [
|
|
398
405
|
close,
|
|
@@ -412,7 +419,6 @@ var ScreebProvider = function (_a) {
|
|
|
412
419
|
messageStart,
|
|
413
420
|
sessionReplayStop,
|
|
414
421
|
sessionReplayStart,
|
|
415
|
-
targetingCheck,
|
|
416
422
|
targetingDebug,
|
|
417
423
|
]);
|
|
418
424
|
if (!isSSR && shouldLoad) {
|
|
@@ -435,4 +441,4 @@ var useScreeb = function () {
|
|
|
435
441
|
|
|
436
442
|
exports.ScreebProvider = ScreebProvider;
|
|
437
443
|
exports.useScreeb = useScreeb;
|
|
438
|
-
CONSTANTS.version = '0.
|
|
444
|
+
CONSTANTS.version = '0.8.0'
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -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
|
@@ -16,7 +16,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
16
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
18
18
|
***************************************************************************** */
|
|
19
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
19
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
var __assign = function() {
|
|
@@ -53,8 +53,8 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
function __generator(thisArg, body) {
|
|
56
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
57
|
-
return g =
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
58
58
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
59
59
|
function step(op) {
|
|
60
60
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -80,6 +80,16 @@ function __generator(thisArg, body) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
function __spreadArray(to, from, pack) {
|
|
84
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
85
|
+
if (ar || !(i in from)) {
|
|
86
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
87
|
+
ar[i] = from[i];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
|
+
}
|
|
92
|
+
|
|
83
93
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
84
94
|
var e = new Error(message);
|
|
85
95
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -119,7 +129,7 @@ var isSSR = typeof window === "undefined";
|
|
|
119
129
|
var CONSTANTS = { version: "0.0.0-dev" };
|
|
120
130
|
var isInitialized = false;
|
|
121
131
|
var ScreebProvider = function (_a) {
|
|
122
|
-
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"]);
|
|
123
133
|
var isLoaded = React.useRef(Screeb.isLoaded());
|
|
124
134
|
var currentUserId = React.useRef(userId);
|
|
125
135
|
// Allow data-x attributes, see https://github.com/devrnt/react-use-screeb/issues/478
|
|
@@ -132,10 +142,10 @@ var ScreebProvider = function (_a) {
|
|
|
132
142
|
}
|
|
133
143
|
var ensureScreeb = React.useCallback(
|
|
134
144
|
// eslint-disable-next-line no-unused-vars
|
|
135
|
-
function (
|
|
136
|
-
|
|
137
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
+
function (functionName_1, callback_1) {
|
|
146
|
+
return __awaiter(this, arguments, void 0, function (functionName, callback, onlyLoaded) {
|
|
138
147
|
var message, message;
|
|
148
|
+
if (onlyLoaded === void 0) { onlyLoaded = false; }
|
|
139
149
|
return __generator(this, function (_a) {
|
|
140
150
|
if (!Screeb.isLoaded() && !shouldLoad) {
|
|
141
151
|
message = "Screeb instance is not loaded because `shouldLoad` is set to `false` in `ScreebProvider`";
|
|
@@ -238,12 +248,12 @@ var ScreebProvider = function (_a) {
|
|
|
238
248
|
case 1: return [2 /*return*/, _a.sent()];
|
|
239
249
|
}
|
|
240
250
|
}); }); }, []);
|
|
241
|
-
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 () {
|
|
242
252
|
return __generator(this, function (_a) {
|
|
243
253
|
switch (_a.label) {
|
|
244
254
|
case 0: return [4 /*yield*/, ensureScreeb("init", function () {
|
|
245
255
|
if (!isInitialized) {
|
|
246
|
-
Screeb.init(websiteId, userId, userProperties, hooks, language);
|
|
256
|
+
Screeb.init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler);
|
|
247
257
|
isInitialized = true;
|
|
248
258
|
isLoaded.current = true;
|
|
249
259
|
}
|
|
@@ -263,7 +273,7 @@ var ScreebProvider = function (_a) {
|
|
|
263
273
|
isLoaded.current = true;
|
|
264
274
|
if (!autoInit) return [3 /*break*/, 3];
|
|
265
275
|
if (!websiteId) return [3 /*break*/, 2];
|
|
266
|
-
return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language)];
|
|
276
|
+
return [4 /*yield*/, init(websiteId, userId, userProperties, hooks, language, spaNavigationHandler)];
|
|
267
277
|
case 1:
|
|
268
278
|
_a.sent();
|
|
269
279
|
return [3 /*break*/, 3];
|
|
@@ -296,9 +306,13 @@ var ScreebProvider = function (_a) {
|
|
|
296
306
|
case 1: return [2 /*return*/, _a.sent()];
|
|
297
307
|
}
|
|
298
308
|
}); }); }, []);
|
|
299
|
-
var messageStart = React.useCallback(function (
|
|
300
|
-
|
|
301
|
-
|
|
309
|
+
var messageStart = React.useCallback(function (messageId_1) {
|
|
310
|
+
var args_1 = [];
|
|
311
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
312
|
+
args_1[_i - 1] = arguments[_i];
|
|
313
|
+
}
|
|
314
|
+
return __awaiter(void 0, __spreadArray([messageId_1], args_1, true), void 0, function (messageId, allowMultipleResponses, hiddenFields, hooks, language) {
|
|
315
|
+
if (allowMultipleResponses === void 0) { allowMultipleResponses = true; }
|
|
302
316
|
return __generator(this, function (_a) {
|
|
303
317
|
switch (_a.label) {
|
|
304
318
|
case 0: return [4 /*yield*/, ensureScreeb("messageStart", function () {
|
|
@@ -325,12 +339,6 @@ var ScreebProvider = function (_a) {
|
|
|
325
339
|
}
|
|
326
340
|
});
|
|
327
341
|
}); }, []);
|
|
328
|
-
var targetingCheck = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
329
|
-
switch (_a.label) {
|
|
330
|
-
case 0: return [4 /*yield*/, ensureScreeb("targetingCheck", function () { return Screeb.targetingCheck(); })];
|
|
331
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
332
|
-
}
|
|
333
|
-
}); }); }, []);
|
|
334
342
|
var targetingDebug = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
335
343
|
switch (_a.label) {
|
|
336
344
|
case 0: return [4 /*yield*/, ensureScreeb("targetingDebug", function () { return Screeb.targetingDebug(); })];
|
|
@@ -370,7 +378,6 @@ var ScreebProvider = function (_a) {
|
|
|
370
378
|
messageStart: messageStart,
|
|
371
379
|
sessionReplayStop: sessionReplayStop,
|
|
372
380
|
sessionReplayStart: sessionReplayStart,
|
|
373
|
-
targetingCheck: targetingCheck,
|
|
374
381
|
targetingDebug: targetingDebug,
|
|
375
382
|
}); }, [
|
|
376
383
|
close,
|
|
@@ -390,7 +397,6 @@ var ScreebProvider = function (_a) {
|
|
|
390
397
|
messageStart,
|
|
391
398
|
sessionReplayStop,
|
|
392
399
|
sessionReplayStart,
|
|
393
|
-
targetingCheck,
|
|
394
400
|
targetingDebug,
|
|
395
401
|
]);
|
|
396
402
|
if (!isSSR && shouldLoad) {
|
|
@@ -412,4 +418,4 @@ var useScreeb = function () {
|
|
|
412
418
|
};
|
|
413
419
|
|
|
414
420
|
export { ScreebProvider, useScreeb };
|
|
415
|
-
CONSTANTS.version = '0.
|
|
421
|
+
CONSTANTS.version = '0.8.0'
|
package/dist/es/types.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Screeb's browser sdk, optimized for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"product discovery",
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
],
|
|
14
14
|
"homepage": "https://screeb.app",
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/ScreebApp/sdk
|
|
16
|
+
"url": "https://github.com/ScreebApp/sdk/issues",
|
|
17
17
|
"email": "support@screeb.app"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/ScreebApp/sdk
|
|
22
|
-
"directory": "packages/
|
|
21
|
+
"url": "https://github.com/ScreebApp/sdk.git",
|
|
22
|
+
"directory": "packages/sdk-react"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"author": "Screeb's frontend team",
|
|
@@ -41,25 +41,25 @@
|
|
|
41
41
|
"test": "echo '@TODO'"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@screeb/sdk-browser": "^0.
|
|
44
|
+
"@screeb/sdk-browser": "^0.7.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@screeb/eslint-config": "^0.1.
|
|
48
|
-
"@screeb/typescript-config": "^0.1.
|
|
49
|
-
"@types/jest": "^29.5.
|
|
50
|
-
"@types/node": "^20.8.
|
|
51
|
-
"@types/react": "^18.2.
|
|
52
|
-
"@types/react-dom": "^18.2.
|
|
47
|
+
"@screeb/eslint-config": "^0.1.8",
|
|
48
|
+
"@screeb/typescript-config": "^0.1.13",
|
|
49
|
+
"@types/jest": "^29.5.14",
|
|
50
|
+
"@types/node": "^20.8.10",
|
|
51
|
+
"@types/react": "^18.2.79",
|
|
52
|
+
"@types/react-dom": "^18.2.25",
|
|
53
53
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
54
54
|
"eslint": "^8.51.0",
|
|
55
55
|
"eslint-plugin-import": "^2.28.1",
|
|
56
|
-
"eslint-plugin-jest": "^27.4.
|
|
56
|
+
"eslint-plugin-jest": "^27.4.3",
|
|
57
57
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
58
58
|
"eslint-plugin-prettier": "^5.0.1",
|
|
59
59
|
"jest": "^29.7.0",
|
|
60
60
|
"prettier": "^3.0.3",
|
|
61
|
-
"react": ">=
|
|
62
|
-
"react-dom": ">=
|
|
61
|
+
"react": ">=16.8.6",
|
|
62
|
+
"react-dom": ">=16.8.6",
|
|
63
63
|
"rollup": "^4.0.2",
|
|
64
64
|
"typedoc": "^0.25.2",
|
|
65
65
|
"typedoc-plugin-markdown": "^3.16.0"
|