@screeb/sdk-browser 0.5.0 → 0.7.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 +35 -7
- package/dist/cjs/hooks.types.d.ts +26 -0
- package/dist/cjs/index.cjs +17 -17
- package/dist/cjs/index.d.ts +11 -13
- package/dist/cjs/types.d.ts +39 -0
- package/dist/es/hooks.types.d.ts +26 -0
- package/dist/es/index.d.ts +11 -13
- package/dist/es/index.mjs +18 -17
- package/dist/es/types.d.ts +39 -0
- package/docs/README.md +107 -22
- package/package.json +10 -10
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-browser/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-browser</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-browser" alt="version">
|
|
20
20
|
<img alt="version" src="https://img.shields.io/npm/v/@screeb/sdk-browser.svg" />
|
|
@@ -50,11 +50,39 @@ Screeb.load();
|
|
|
50
50
|
Screeb.init('<your-website-id>');
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
### Custom domains (AdBlocker bypass)
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
If you route Screeb traffic through your own domain (reverse proxy) to bypass AdBlockers, pass an
|
|
56
|
+
`endpoints` object to `load()`. Only the endpoints you provide are overridden; the rest fall back
|
|
57
|
+
to Screeb's defaults. The tag loader URL itself is set separately via `screebEndpoint`.
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
```ts
|
|
60
|
+
import * as Screeb from "@screeb/sdk-browser";
|
|
61
|
+
|
|
62
|
+
Screeb.load({
|
|
63
|
+
// Load the SDK bundle from your domain
|
|
64
|
+
screebEndpoint: "https://analytics.acme.com/sdk/tag.js",
|
|
65
|
+
// Route collector traffic through your domain
|
|
66
|
+
endpoints: {
|
|
67
|
+
rpc: "https://analytics.acme.com/rpc",
|
|
68
|
+
static: "https://analytics.acme.com/static",
|
|
69
|
+
report: "https://analytics.acme.com/report",
|
|
70
|
+
hostedPage: "https://analytics.acme.com/hosted-page",
|
|
71
|
+
centipede: "wss://analytics.acme.com/centipede",
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
Screeb.init('<your-website-id>');
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
All endpoints must use `https://` (or `wss://` for `centipede`) and the domains must be allow-listed
|
|
78
|
+
in **Screeb Admin → Settings → Custom Domains**. See the
|
|
79
|
+
[Custom Collector URL guide](https://developers.screeb.app/sdk-js/custom-collector-url).
|
|
80
|
+
|
|
81
|
+
For a working example, see our [Screeb Browser SDK example app](https://github.com/ScreebApp/sdk/tree/master/examples/example-browser).
|
|
82
|
+
|
|
83
|
+
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-browser/docs).
|
|
84
|
+
|
|
85
|
+
For further information, see [our developer documentation](https://developers.screeb.app/sdk-js/install).
|
|
58
86
|
|
|
59
87
|
## Support
|
|
60
88
|
For any issues, please contact our support team at support@screeb.com.
|
|
@@ -64,4 +92,4 @@ All third party contributors acknowledge that any contributions they provide wil
|
|
|
64
92
|
|
|
65
93
|
## License
|
|
66
94
|
|
|
67
|
-
Released under [MIT License](https://github.com/ScreebApp/sdk
|
|
95
|
+
Released under [MIT License](https://github.com/ScreebApp/sdk/blob/master/LICENSE).
|
|
@@ -114,6 +114,24 @@ export type HookOnQuestionReplied = (data: HookCommonPropertiesSurvey & {
|
|
|
114
114
|
items: ResponseItem[];
|
|
115
115
|
};
|
|
116
116
|
}) => void;
|
|
117
|
+
export type HookOnButtonNavigateStarted = (data: HookCommonPropertiesSurvey & {
|
|
118
|
+
response: {
|
|
119
|
+
id: string;
|
|
120
|
+
};
|
|
121
|
+
button: {
|
|
122
|
+
url: string;
|
|
123
|
+
url_target?: string;
|
|
124
|
+
};
|
|
125
|
+
}) => void;
|
|
126
|
+
export type HookOnButtonNavigateCompleted = (data: HookCommonPropertiesSurvey & {
|
|
127
|
+
response: {
|
|
128
|
+
id: string;
|
|
129
|
+
};
|
|
130
|
+
button: {
|
|
131
|
+
url: string;
|
|
132
|
+
url_target?: string;
|
|
133
|
+
};
|
|
134
|
+
}) => void;
|
|
117
135
|
/** This is the Screeb tag hooks object available on `survey.start` command. */
|
|
118
136
|
export type HooksSurveyStart = {
|
|
119
137
|
/** This hook is triggered when a survey is displayed on screen (also triggered when page is reloaded) */
|
|
@@ -126,6 +144,10 @@ export type HooksSurveyStart = {
|
|
|
126
144
|
onSurveyHidden?: HookOnSurveyHidden;
|
|
127
145
|
/** This hook is triggered when a question is answered */
|
|
128
146
|
onQuestionReplied?: HookOnQuestionReplied;
|
|
147
|
+
/** This hook is triggered before a message/tour button "Navigate to URL" action runs. */
|
|
148
|
+
onButtonNavigateStarted?: HookOnButtonNavigateStarted;
|
|
149
|
+
/** This hook is triggered after a message/tour button "Navigate to URL" action ran (only fires when the SDK survives the navigation, e.g. `new-tab` or `in-page-spa`). */
|
|
150
|
+
onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;
|
|
129
151
|
};
|
|
130
152
|
/** This is the Screeb tag hooks object available on `message.start` command. */
|
|
131
153
|
export type HooksMessageStart = {
|
|
@@ -139,6 +161,10 @@ export type HooksMessageStart = {
|
|
|
139
161
|
onMessageHidden?: HookOnMessageHidden;
|
|
140
162
|
/** This hook is triggered when a question is answered */
|
|
141
163
|
onQuestionReplied?: HookOnQuestionReplied;
|
|
164
|
+
/** This hook is triggered before a message/tour button "Navigate to URL" action runs. */
|
|
165
|
+
onButtonNavigateStarted?: HookOnButtonNavigateStarted;
|
|
166
|
+
/** This hook is triggered after a message/tour button "Navigate to URL" action ran (only fires when the SDK survives the navigation, e.g. `new-tab` or `in-page-spa`). */
|
|
167
|
+
onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;
|
|
142
168
|
};
|
|
143
169
|
/** This is the Screeb tag hooks object available on `init` command. */
|
|
144
170
|
export type HooksInit = HooksSurveyStart & HooksMessageStart & {
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -14,7 +14,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
14
14
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
15
|
PERFORMANCE OF THIS SOFTWARE.
|
|
16
16
|
***************************************************************************** */
|
|
17
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
17
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
var __assign = function() {
|
|
@@ -52,6 +52,8 @@ var callScreebCommand = function () {
|
|
|
52
52
|
* @param options Screeb module options.
|
|
53
53
|
* @param options.window If you're running Screeb tag in an iframe, please set the inner window here.
|
|
54
54
|
* @param options.screebEndpoint Please don't do this.
|
|
55
|
+
* @param options.endpoints Override Screeb's collector URLs to route traffic through your own
|
|
56
|
+
* domain (custom domains / AdBlocker bypass). Only the endpoints you provide are overridden.
|
|
55
57
|
*
|
|
56
58
|
* @example
|
|
57
59
|
* ```ts
|
|
@@ -70,8 +72,8 @@ var load = function (options) {
|
|
|
70
72
|
scriptElement.src = (_b = options.screebEndpoint) !== null && _b !== void 0 ? _b : SCREEB_TAG_ENDPOINT;
|
|
71
73
|
scriptElement.addEventListener("load", function () { return resolve(undefined); });
|
|
72
74
|
scriptElement.addEventListener("error", reject);
|
|
73
|
-
if (options.platform) {
|
|
74
|
-
_window["ScreebConfig"] = { platform: options.platform };
|
|
75
|
+
if (options.platform || options.endpoints) {
|
|
76
|
+
_window["ScreebConfig"] = __assign(__assign({}, (options.platform ? { platform: options.platform } : {})), (options.endpoints ? { endpoints: options.endpoints } : {}));
|
|
75
77
|
}
|
|
76
78
|
_window.$screeb =
|
|
77
79
|
(_c = _window.$screeb) !== null && _c !== void 0 ? _c : function () {
|
|
@@ -116,6 +118,11 @@ var load = function (options) {
|
|
|
116
118
|
*
|
|
117
119
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
118
120
|
*
|
|
121
|
+
* @param spaNavigationHandler Optional handler for the `in-page-spa` "Navigate to URL"
|
|
122
|
+
* target. Runs in your page so your SPA router can navigate without a full reload. Only
|
|
123
|
+
* needed for custom routers that don't resync on `popstate` (React Router / Vue Router /
|
|
124
|
+
* Angular Router work out of the box). May be async so `onButtonNavigateCompleted` awaits it.
|
|
125
|
+
*
|
|
119
126
|
* @example
|
|
120
127
|
* ```ts
|
|
121
128
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -133,12 +140,14 @@ var load = function (options) {
|
|
|
133
140
|
* {
|
|
134
141
|
* version: "1.0.0",
|
|
135
142
|
* onReady: (payload) => console.log("Screeb SDK is ready!", payload),
|
|
143
|
+
* onButtonNavigateStarted: (payload) => console.log("Button navigate started", payload),
|
|
144
|
+
* onButtonNavigateCompleted: (payload) => console.log("Button navigate completed", payload),
|
|
136
145
|
* },
|
|
137
146
|
* "en"
|
|
138
147
|
* );
|
|
139
148
|
* ```
|
|
140
149
|
*/
|
|
141
|
-
var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
150
|
+
var init = function (websiteId, userId, userProperties, hooks, language, spaNavigationHandler) {
|
|
142
151
|
var identityObject;
|
|
143
152
|
if (userId || userProperties) {
|
|
144
153
|
identityObject = {
|
|
@@ -152,6 +161,9 @@ var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
|
152
161
|
if (language) {
|
|
153
162
|
identityObject = __assign(__assign({}, identityObject), { language: language });
|
|
154
163
|
}
|
|
164
|
+
if (spaNavigationHandler) {
|
|
165
|
+
identityObject = __assign(__assign({}, identityObject), { spaNavigationHandler: spaNavigationHandler });
|
|
166
|
+
}
|
|
155
167
|
return callScreebCommand("init", websiteId, identityObject);
|
|
156
168
|
};
|
|
157
169
|
/**
|
|
@@ -506,17 +518,6 @@ var sessionReplayStop = function () { return callScreebCommand("session-replay.s
|
|
|
506
518
|
var sessionReplayStart = function () {
|
|
507
519
|
return callScreebCommand("session-replay.start");
|
|
508
520
|
};
|
|
509
|
-
/**
|
|
510
|
-
* Forces a targeting check.
|
|
511
|
-
*
|
|
512
|
-
* @example
|
|
513
|
-
* ```ts
|
|
514
|
-
* import * as Screeb from "@screeb/sdk-browser";
|
|
515
|
-
*
|
|
516
|
-
* Screeb.targetingCheck();
|
|
517
|
-
* ```
|
|
518
|
-
*/
|
|
519
|
-
var targetingCheck = function () { return callScreebCommand("targeting.check"); };
|
|
520
521
|
/**
|
|
521
522
|
* Prints the current state of the targeting engine.
|
|
522
523
|
*
|
|
@@ -561,6 +562,5 @@ exports.sessionReplayStart = sessionReplayStart;
|
|
|
561
562
|
exports.sessionReplayStop = sessionReplayStop;
|
|
562
563
|
exports.surveyClose = surveyClose;
|
|
563
564
|
exports.surveyStart = surveyStart;
|
|
564
|
-
exports.targetingCheck = targetingCheck;
|
|
565
565
|
exports.targetingDebug = targetingDebug;
|
|
566
|
-
CONSTANTS.version = '0.
|
|
566
|
+
CONSTANTS.version = '0.7.0'
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HooksInit, HooksMessageStart, HooksSurveyStart } from "./hooks.types";
|
|
2
|
-
import { PropertyRecord, ScreebIdentityGetReturn, ScreebOptions } from "./types";
|
|
2
|
+
import { PropertyRecord, ScreebIdentityGetReturn, ScreebOptions, SpaNavigationHandler } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export * from "./hooks.types";
|
|
5
5
|
/**
|
|
@@ -8,6 +8,8 @@ export * from "./hooks.types";
|
|
|
8
8
|
* @param options Screeb module options.
|
|
9
9
|
* @param options.window If you're running Screeb tag in an iframe, please set the inner window here.
|
|
10
10
|
* @param options.screebEndpoint Please don't do this.
|
|
11
|
+
* @param options.endpoints Override Screeb's collector URLs to route traffic through your own
|
|
12
|
+
* domain (custom domains / AdBlocker bypass). Only the endpoints you provide are overridden.
|
|
11
13
|
*
|
|
12
14
|
* @example
|
|
13
15
|
* ```ts
|
|
@@ -33,6 +35,11 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
33
35
|
*
|
|
34
36
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
35
37
|
*
|
|
38
|
+
* @param spaNavigationHandler Optional handler for the `in-page-spa` "Navigate to URL"
|
|
39
|
+
* target. Runs in your page so your SPA router can navigate without a full reload. Only
|
|
40
|
+
* needed for custom routers that don't resync on `popstate` (React Router / Vue Router /
|
|
41
|
+
* Angular Router work out of the box). May be async so `onButtonNavigateCompleted` awaits it.
|
|
42
|
+
*
|
|
36
43
|
* @example
|
|
37
44
|
* ```ts
|
|
38
45
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -50,12 +57,14 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
50
57
|
* {
|
|
51
58
|
* version: "1.0.0",
|
|
52
59
|
* onReady: (payload) => console.log("Screeb SDK is ready!", payload),
|
|
60
|
+
* onButtonNavigateStarted: (payload) => console.log("Button navigate started", payload),
|
|
61
|
+
* onButtonNavigateCompleted: (payload) => console.log("Button navigate completed", payload),
|
|
53
62
|
* },
|
|
54
63
|
* "en"
|
|
55
64
|
* );
|
|
56
65
|
* ```
|
|
57
66
|
*/
|
|
58
|
-
export declare const init: (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => void | Promise<unknown>;
|
|
67
|
+
export declare const init: (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string, spaNavigationHandler?: SpaNavigationHandler) => void | Promise<unknown>;
|
|
59
68
|
/**
|
|
60
69
|
* Checks if Screeb tag has been loaded.
|
|
61
70
|
*
|
|
@@ -374,17 +383,6 @@ export declare const sessionReplayStop: () => void | Promise<unknown>;
|
|
|
374
383
|
* ```
|
|
375
384
|
*/
|
|
376
385
|
export declare const sessionReplayStart: () => void | Promise<unknown>;
|
|
377
|
-
/**
|
|
378
|
-
* Forces a targeting check.
|
|
379
|
-
*
|
|
380
|
-
* @example
|
|
381
|
-
* ```ts
|
|
382
|
-
* import * as Screeb from "@screeb/sdk-browser";
|
|
383
|
-
*
|
|
384
|
-
* Screeb.targetingCheck();
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
export declare const targetingCheck: () => void | Promise<unknown>;
|
|
388
386
|
/**
|
|
389
387
|
* Prints the current state of the targeting engine.
|
|
390
388
|
*
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -4,6 +4,28 @@ export type PropertyType = number | boolean | string | Date | PropertyRecord;
|
|
|
4
4
|
export type PropertyRecord = {
|
|
5
5
|
[key: string]: PropertyType | PropertyType[];
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Custom collector URLs used to bypass AdBlockers by routing Screeb traffic
|
|
9
|
+
* through your own domain (reverse proxy).
|
|
10
|
+
*
|
|
11
|
+
* Every key is optional: any omitted endpoint falls back to Screeb's default
|
|
12
|
+
* URL. All endpoints must use `https://` (or `wss://` for the WebSocket one),
|
|
13
|
+
* and the domains must be allow-listed in Screeb Admin → Settings → Custom Domains.
|
|
14
|
+
*
|
|
15
|
+
* @see https://developers.screeb.app/sdk-js/custom-collector-url
|
|
16
|
+
*/
|
|
17
|
+
export type ScreebEndpoints = {
|
|
18
|
+
/** REST API (surveys, tracking). Default: `https://rpc.screeb.app/rpc`. */
|
|
19
|
+
rpc?: string;
|
|
20
|
+
/** Static assets (images, fonts). Default: `https://static.screeb.app`. */
|
|
21
|
+
static?: string;
|
|
22
|
+
/** Response reporting. Default: `https://r.screeb.app/rpc`. */
|
|
23
|
+
report?: string;
|
|
24
|
+
/** Hosted survey page. Default: `https://survey.screeb.app`. */
|
|
25
|
+
hostedPage?: string;
|
|
26
|
+
/** WebSocket (real-time targeting). Default: `wss://centipede.screeb.app`. */
|
|
27
|
+
centipede?: string;
|
|
28
|
+
};
|
|
7
29
|
/** This is the Screeb tag options object. */
|
|
8
30
|
export type ScreebOptions = {
|
|
9
31
|
/** If you're running Screeb tag in an iframe, please set the inner window here. */
|
|
@@ -14,9 +36,26 @@ export type ScreebOptions = {
|
|
|
14
36
|
sdkVersion?: string;
|
|
15
37
|
/** Please don't do this. */
|
|
16
38
|
screebEndpoint?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Override Screeb's collector URLs to route traffic through your own domain
|
|
41
|
+
* (custom domains / AdBlocker bypass). Only the endpoints you provide are
|
|
42
|
+
* overridden; the rest fall back to Screeb's defaults.
|
|
43
|
+
*
|
|
44
|
+
* @see https://developers.screeb.app/sdk-js/custom-collector-url
|
|
45
|
+
*/
|
|
46
|
+
endpoints?: ScreebEndpoints;
|
|
17
47
|
/** @hidden Use a specific platform */
|
|
18
48
|
platform?: string;
|
|
19
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Host-provided navigation handler for the `in-page-spa` "Navigate to URL"
|
|
52
|
+
* target. It runs in your page (where your SPA router lives) instead of the tag
|
|
53
|
+
* doing a `history.pushState` + `popstate` dispatch itself. Provide this when
|
|
54
|
+
* your router does not resync on `popstate` (most React Router / Vue Router /
|
|
55
|
+
* Angular Router setups do, so this is only needed for custom routers). May be
|
|
56
|
+
* async so `onButtonNavigateCompleted` can await the route change.
|
|
57
|
+
*/
|
|
58
|
+
export type SpaNavigationHandler = (url: string) => void | Promise<void>;
|
|
20
59
|
export type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
|
|
21
60
|
/** This is the Screeb object publicly exposed in browser `window`. */
|
|
22
61
|
export type ScreebObject = ScreebFunction & {
|
package/dist/es/hooks.types.d.ts
CHANGED
|
@@ -114,6 +114,24 @@ export type HookOnQuestionReplied = (data: HookCommonPropertiesSurvey & {
|
|
|
114
114
|
items: ResponseItem[];
|
|
115
115
|
};
|
|
116
116
|
}) => void;
|
|
117
|
+
export type HookOnButtonNavigateStarted = (data: HookCommonPropertiesSurvey & {
|
|
118
|
+
response: {
|
|
119
|
+
id: string;
|
|
120
|
+
};
|
|
121
|
+
button: {
|
|
122
|
+
url: string;
|
|
123
|
+
url_target?: string;
|
|
124
|
+
};
|
|
125
|
+
}) => void;
|
|
126
|
+
export type HookOnButtonNavigateCompleted = (data: HookCommonPropertiesSurvey & {
|
|
127
|
+
response: {
|
|
128
|
+
id: string;
|
|
129
|
+
};
|
|
130
|
+
button: {
|
|
131
|
+
url: string;
|
|
132
|
+
url_target?: string;
|
|
133
|
+
};
|
|
134
|
+
}) => void;
|
|
117
135
|
/** This is the Screeb tag hooks object available on `survey.start` command. */
|
|
118
136
|
export type HooksSurveyStart = {
|
|
119
137
|
/** This hook is triggered when a survey is displayed on screen (also triggered when page is reloaded) */
|
|
@@ -126,6 +144,10 @@ export type HooksSurveyStart = {
|
|
|
126
144
|
onSurveyHidden?: HookOnSurveyHidden;
|
|
127
145
|
/** This hook is triggered when a question is answered */
|
|
128
146
|
onQuestionReplied?: HookOnQuestionReplied;
|
|
147
|
+
/** This hook is triggered before a message/tour button "Navigate to URL" action runs. */
|
|
148
|
+
onButtonNavigateStarted?: HookOnButtonNavigateStarted;
|
|
149
|
+
/** This hook is triggered after a message/tour button "Navigate to URL" action ran (only fires when the SDK survives the navigation, e.g. `new-tab` or `in-page-spa`). */
|
|
150
|
+
onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;
|
|
129
151
|
};
|
|
130
152
|
/** This is the Screeb tag hooks object available on `message.start` command. */
|
|
131
153
|
export type HooksMessageStart = {
|
|
@@ -139,6 +161,10 @@ export type HooksMessageStart = {
|
|
|
139
161
|
onMessageHidden?: HookOnMessageHidden;
|
|
140
162
|
/** This hook is triggered when a question is answered */
|
|
141
163
|
onQuestionReplied?: HookOnQuestionReplied;
|
|
164
|
+
/** This hook is triggered before a message/tour button "Navigate to URL" action runs. */
|
|
165
|
+
onButtonNavigateStarted?: HookOnButtonNavigateStarted;
|
|
166
|
+
/** This hook is triggered after a message/tour button "Navigate to URL" action ran (only fires when the SDK survives the navigation, e.g. `new-tab` or `in-page-spa`). */
|
|
167
|
+
onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;
|
|
142
168
|
};
|
|
143
169
|
/** This is the Screeb tag hooks object available on `init` command. */
|
|
144
170
|
export type HooksInit = HooksSurveyStart & HooksMessageStart & {
|
package/dist/es/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HooksInit, HooksMessageStart, HooksSurveyStart } from "./hooks.types";
|
|
2
|
-
import { PropertyRecord, ScreebIdentityGetReturn, ScreebOptions } from "./types";
|
|
2
|
+
import { PropertyRecord, ScreebIdentityGetReturn, ScreebOptions, SpaNavigationHandler } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export * from "./hooks.types";
|
|
5
5
|
/**
|
|
@@ -8,6 +8,8 @@ export * from "./hooks.types";
|
|
|
8
8
|
* @param options Screeb module options.
|
|
9
9
|
* @param options.window If you're running Screeb tag in an iframe, please set the inner window here.
|
|
10
10
|
* @param options.screebEndpoint Please don't do this.
|
|
11
|
+
* @param options.endpoints Override Screeb's collector URLs to route traffic through your own
|
|
12
|
+
* domain (custom domains / AdBlocker bypass). Only the endpoints you provide are overridden.
|
|
11
13
|
*
|
|
12
14
|
* @example
|
|
13
15
|
* ```ts
|
|
@@ -33,6 +35,11 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
33
35
|
*
|
|
34
36
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
35
37
|
*
|
|
38
|
+
* @param spaNavigationHandler Optional handler for the `in-page-spa` "Navigate to URL"
|
|
39
|
+
* target. Runs in your page so your SPA router can navigate without a full reload. Only
|
|
40
|
+
* needed for custom routers that don't resync on `popstate` (React Router / Vue Router /
|
|
41
|
+
* Angular Router work out of the box). May be async so `onButtonNavigateCompleted` awaits it.
|
|
42
|
+
*
|
|
36
43
|
* @example
|
|
37
44
|
* ```ts
|
|
38
45
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -50,12 +57,14 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
50
57
|
* {
|
|
51
58
|
* version: "1.0.0",
|
|
52
59
|
* onReady: (payload) => console.log("Screeb SDK is ready!", payload),
|
|
60
|
+
* onButtonNavigateStarted: (payload) => console.log("Button navigate started", payload),
|
|
61
|
+
* onButtonNavigateCompleted: (payload) => console.log("Button navigate completed", payload),
|
|
53
62
|
* },
|
|
54
63
|
* "en"
|
|
55
64
|
* );
|
|
56
65
|
* ```
|
|
57
66
|
*/
|
|
58
|
-
export declare const init: (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string) => void | Promise<unknown>;
|
|
67
|
+
export declare const init: (websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string, spaNavigationHandler?: SpaNavigationHandler) => void | Promise<unknown>;
|
|
59
68
|
/**
|
|
60
69
|
* Checks if Screeb tag has been loaded.
|
|
61
70
|
*
|
|
@@ -374,17 +383,6 @@ export declare const sessionReplayStop: () => void | Promise<unknown>;
|
|
|
374
383
|
* ```
|
|
375
384
|
*/
|
|
376
385
|
export declare const sessionReplayStart: () => void | Promise<unknown>;
|
|
377
|
-
/**
|
|
378
|
-
* Forces a targeting check.
|
|
379
|
-
*
|
|
380
|
-
* @example
|
|
381
|
-
* ```ts
|
|
382
|
-
* import * as Screeb from "@screeb/sdk-browser";
|
|
383
|
-
*
|
|
384
|
-
* Screeb.targetingCheck();
|
|
385
|
-
* ```
|
|
386
|
-
*/
|
|
387
|
-
export declare const targetingCheck: () => void | Promise<unknown>;
|
|
388
386
|
/**
|
|
389
387
|
* Prints the current state of the targeting engine.
|
|
390
388
|
*
|
package/dist/es/index.mjs
CHANGED
|
@@ -12,7 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
14
|
***************************************************************************** */
|
|
15
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
15
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
var __assign = function() {
|
|
@@ -50,6 +50,8 @@ var callScreebCommand = function () {
|
|
|
50
50
|
* @param options Screeb module options.
|
|
51
51
|
* @param options.window If you're running Screeb tag in an iframe, please set the inner window here.
|
|
52
52
|
* @param options.screebEndpoint Please don't do this.
|
|
53
|
+
* @param options.endpoints Override Screeb's collector URLs to route traffic through your own
|
|
54
|
+
* domain (custom domains / AdBlocker bypass). Only the endpoints you provide are overridden.
|
|
53
55
|
*
|
|
54
56
|
* @example
|
|
55
57
|
* ```ts
|
|
@@ -68,8 +70,8 @@ var load = function (options) {
|
|
|
68
70
|
scriptElement.src = (_b = options.screebEndpoint) !== null && _b !== void 0 ? _b : SCREEB_TAG_ENDPOINT;
|
|
69
71
|
scriptElement.addEventListener("load", function () { return resolve(undefined); });
|
|
70
72
|
scriptElement.addEventListener("error", reject);
|
|
71
|
-
if (options.platform) {
|
|
72
|
-
_window["ScreebConfig"] = { platform: options.platform };
|
|
73
|
+
if (options.platform || options.endpoints) {
|
|
74
|
+
_window["ScreebConfig"] = __assign(__assign({}, (options.platform ? { platform: options.platform } : {})), (options.endpoints ? { endpoints: options.endpoints } : {}));
|
|
73
75
|
}
|
|
74
76
|
_window.$screeb =
|
|
75
77
|
(_c = _window.$screeb) !== null && _c !== void 0 ? _c : function () {
|
|
@@ -114,6 +116,11 @@ var load = function (options) {
|
|
|
114
116
|
*
|
|
115
117
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
116
118
|
*
|
|
119
|
+
* @param spaNavigationHandler Optional handler for the `in-page-spa` "Navigate to URL"
|
|
120
|
+
* target. Runs in your page so your SPA router can navigate without a full reload. Only
|
|
121
|
+
* needed for custom routers that don't resync on `popstate` (React Router / Vue Router /
|
|
122
|
+
* Angular Router work out of the box). May be async so `onButtonNavigateCompleted` awaits it.
|
|
123
|
+
*
|
|
117
124
|
* @example
|
|
118
125
|
* ```ts
|
|
119
126
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -131,12 +138,14 @@ var load = function (options) {
|
|
|
131
138
|
* {
|
|
132
139
|
* version: "1.0.0",
|
|
133
140
|
* onReady: (payload) => console.log("Screeb SDK is ready!", payload),
|
|
141
|
+
* onButtonNavigateStarted: (payload) => console.log("Button navigate started", payload),
|
|
142
|
+
* onButtonNavigateCompleted: (payload) => console.log("Button navigate completed", payload),
|
|
134
143
|
* },
|
|
135
144
|
* "en"
|
|
136
145
|
* );
|
|
137
146
|
* ```
|
|
138
147
|
*/
|
|
139
|
-
var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
148
|
+
var init = function (websiteId, userId, userProperties, hooks, language, spaNavigationHandler) {
|
|
140
149
|
var identityObject;
|
|
141
150
|
if (userId || userProperties) {
|
|
142
151
|
identityObject = {
|
|
@@ -150,6 +159,9 @@ var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
|
150
159
|
if (language) {
|
|
151
160
|
identityObject = __assign(__assign({}, identityObject), { language: language });
|
|
152
161
|
}
|
|
162
|
+
if (spaNavigationHandler) {
|
|
163
|
+
identityObject = __assign(__assign({}, identityObject), { spaNavigationHandler: spaNavigationHandler });
|
|
164
|
+
}
|
|
153
165
|
return callScreebCommand("init", websiteId, identityObject);
|
|
154
166
|
};
|
|
155
167
|
/**
|
|
@@ -504,17 +516,6 @@ var sessionReplayStop = function () { return callScreebCommand("session-replay.s
|
|
|
504
516
|
var sessionReplayStart = function () {
|
|
505
517
|
return callScreebCommand("session-replay.start");
|
|
506
518
|
};
|
|
507
|
-
/**
|
|
508
|
-
* Forces a targeting check.
|
|
509
|
-
*
|
|
510
|
-
* @example
|
|
511
|
-
* ```ts
|
|
512
|
-
* import * as Screeb from "@screeb/sdk-browser";
|
|
513
|
-
*
|
|
514
|
-
* Screeb.targetingCheck();
|
|
515
|
-
* ```
|
|
516
|
-
*/
|
|
517
|
-
var targetingCheck = function () { return callScreebCommand("targeting.check"); };
|
|
518
519
|
/**
|
|
519
520
|
* Prints the current state of the targeting engine.
|
|
520
521
|
*
|
|
@@ -541,5 +542,5 @@ var targetingCheck = function () { return callScreebCommand("targeting.check");
|
|
|
541
542
|
*/
|
|
542
543
|
var targetingDebug = function () { return callScreebCommand("targeting.debug"); };
|
|
543
544
|
|
|
544
|
-
export { close, debug, eventTrack, identity, identityGet, identityGroupAssign, identityGroupUnassign, identityProperties, identityReset, init, isLoaded, load, messageClose, messageStart, sessionReplayStart, sessionReplayStop, surveyClose, surveyStart,
|
|
545
|
-
CONSTANTS.version = '0.
|
|
545
|
+
export { close, debug, eventTrack, identity, identityGet, identityGroupAssign, identityGroupUnassign, identityProperties, identityReset, init, isLoaded, load, messageClose, messageStart, sessionReplayStart, sessionReplayStop, surveyClose, surveyStart, targetingDebug };
|
|
546
|
+
CONSTANTS.version = '0.7.0'
|
package/dist/es/types.d.ts
CHANGED
|
@@ -4,6 +4,28 @@ export type PropertyType = number | boolean | string | Date | PropertyRecord;
|
|
|
4
4
|
export type PropertyRecord = {
|
|
5
5
|
[key: string]: PropertyType | PropertyType[];
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Custom collector URLs used to bypass AdBlockers by routing Screeb traffic
|
|
9
|
+
* through your own domain (reverse proxy).
|
|
10
|
+
*
|
|
11
|
+
* Every key is optional: any omitted endpoint falls back to Screeb's default
|
|
12
|
+
* URL. All endpoints must use `https://` (or `wss://` for the WebSocket one),
|
|
13
|
+
* and the domains must be allow-listed in Screeb Admin → Settings → Custom Domains.
|
|
14
|
+
*
|
|
15
|
+
* @see https://developers.screeb.app/sdk-js/custom-collector-url
|
|
16
|
+
*/
|
|
17
|
+
export type ScreebEndpoints = {
|
|
18
|
+
/** REST API (surveys, tracking). Default: `https://rpc.screeb.app/rpc`. */
|
|
19
|
+
rpc?: string;
|
|
20
|
+
/** Static assets (images, fonts). Default: `https://static.screeb.app`. */
|
|
21
|
+
static?: string;
|
|
22
|
+
/** Response reporting. Default: `https://r.screeb.app/rpc`. */
|
|
23
|
+
report?: string;
|
|
24
|
+
/** Hosted survey page. Default: `https://survey.screeb.app`. */
|
|
25
|
+
hostedPage?: string;
|
|
26
|
+
/** WebSocket (real-time targeting). Default: `wss://centipede.screeb.app`. */
|
|
27
|
+
centipede?: string;
|
|
28
|
+
};
|
|
7
29
|
/** This is the Screeb tag options object. */
|
|
8
30
|
export type ScreebOptions = {
|
|
9
31
|
/** If you're running Screeb tag in an iframe, please set the inner window here. */
|
|
@@ -14,9 +36,26 @@ export type ScreebOptions = {
|
|
|
14
36
|
sdkVersion?: string;
|
|
15
37
|
/** Please don't do this. */
|
|
16
38
|
screebEndpoint?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Override Screeb's collector URLs to route traffic through your own domain
|
|
41
|
+
* (custom domains / AdBlocker bypass). Only the endpoints you provide are
|
|
42
|
+
* overridden; the rest fall back to Screeb's defaults.
|
|
43
|
+
*
|
|
44
|
+
* @see https://developers.screeb.app/sdk-js/custom-collector-url
|
|
45
|
+
*/
|
|
46
|
+
endpoints?: ScreebEndpoints;
|
|
17
47
|
/** @hidden Use a specific platform */
|
|
18
48
|
platform?: string;
|
|
19
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Host-provided navigation handler for the `in-page-spa` "Navigate to URL"
|
|
52
|
+
* target. It runs in your page (where your SPA router lives) instead of the tag
|
|
53
|
+
* doing a `history.pushState` + `popstate` dispatch itself. Provide this when
|
|
54
|
+
* your router does not resync on `popstate` (most React Router / Vue Router /
|
|
55
|
+
* Angular Router setups do, so this is only needed for custom routers). May be
|
|
56
|
+
* async so `onButtonNavigateCompleted` can await the route change.
|
|
57
|
+
*/
|
|
58
|
+
export type SpaNavigationHandler = (url: string) => void | Promise<void>;
|
|
20
59
|
export type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
|
|
21
60
|
/** This is the Screeb object publicly exposed in browser `window`. */
|
|
22
61
|
export type ScreebObject = ScreebFunction & {
|
package/docs/README.md
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
- [HookCommonProperties](README.md#hookcommonproperties)
|
|
12
12
|
- [HookCommonPropertiesMessage](README.md#hookcommonpropertiesmessage)
|
|
13
13
|
- [HookCommonPropertiesSurvey](README.md#hookcommonpropertiessurvey)
|
|
14
|
+
- [HookOnButtonNavigateCompleted](README.md#hookonbuttonnavigatecompleted)
|
|
15
|
+
- [HookOnButtonNavigateStarted](README.md#hookonbuttonnavigatestarted)
|
|
14
16
|
- [HookOnMessageCompleted](README.md#hookonmessagecompleted)
|
|
15
17
|
- [HookOnMessageDisplayAllowed](README.md#hookonmessagedisplayallowed)
|
|
16
18
|
- [HookOnMessageHidden](README.md#hookonmessagehidden)
|
|
@@ -33,10 +35,12 @@
|
|
|
33
35
|
- [ResponseItemAnswer](README.md#responseitemanswer)
|
|
34
36
|
- [ResponseItemQuestion](README.md#responseitemquestion)
|
|
35
37
|
- [ResponseStatus](README.md#responsestatus)
|
|
38
|
+
- [ScreebEndpoints](README.md#screebendpoints)
|
|
36
39
|
- [ScreebFunction](README.md#screebfunction)
|
|
37
40
|
- [ScreebIdentityGetReturn](README.md#screebidentitygetreturn)
|
|
38
41
|
- [ScreebObject](README.md#screebobject)
|
|
39
42
|
- [ScreebOptions](README.md#screeboptions)
|
|
43
|
+
- [SpaNavigationHandler](README.md#spanavigationhandler)
|
|
40
44
|
- [Survey](README.md#survey)
|
|
41
45
|
- [SurveyFormat](README.md#surveyformat)
|
|
42
46
|
- [SurveyPosition](README.md#surveyposition)
|
|
@@ -63,7 +67,6 @@
|
|
|
63
67
|
- [sessionReplayStop](README.md#sessionreplaystop)
|
|
64
68
|
- [surveyClose](README.md#surveyclose)
|
|
65
69
|
- [surveyStart](README.md#surveystart)
|
|
66
|
-
- [targetingCheck](README.md#targetingcheck)
|
|
67
70
|
- [targetingDebug](README.md#targetingdebug)
|
|
68
71
|
|
|
69
72
|
## Type Aliases
|
|
@@ -112,6 +115,46 @@ ___
|
|
|
112
115
|
|
|
113
116
|
___
|
|
114
117
|
|
|
118
|
+
### HookOnButtonNavigateCompleted
|
|
119
|
+
|
|
120
|
+
Ƭ **HookOnButtonNavigateCompleted**: (`data`: [`HookCommonPropertiesSurvey`](README.md#hookcommonpropertiessurvey) & \{ `button`: \{ `url`: `string` ; `url_target?`: `string` } ; `response`: \{ `id`: `string` } }) => `void`
|
|
121
|
+
|
|
122
|
+
#### Type declaration
|
|
123
|
+
|
|
124
|
+
▸ (`data`): `void`
|
|
125
|
+
|
|
126
|
+
##### Parameters
|
|
127
|
+
|
|
128
|
+
| Name | Type |
|
|
129
|
+
| :------ | :------ |
|
|
130
|
+
| `data` | [`HookCommonPropertiesSurvey`](README.md#hookcommonpropertiessurvey) & \{ `button`: \{ `url`: `string` ; `url_target?`: `string` } ; `response`: \{ `id`: `string` } } |
|
|
131
|
+
|
|
132
|
+
##### Returns
|
|
133
|
+
|
|
134
|
+
`void`
|
|
135
|
+
|
|
136
|
+
___
|
|
137
|
+
|
|
138
|
+
### HookOnButtonNavigateStarted
|
|
139
|
+
|
|
140
|
+
Ƭ **HookOnButtonNavigateStarted**: (`data`: [`HookCommonPropertiesSurvey`](README.md#hookcommonpropertiessurvey) & \{ `button`: \{ `url`: `string` ; `url_target?`: `string` } ; `response`: \{ `id`: `string` } }) => `void`
|
|
141
|
+
|
|
142
|
+
#### Type declaration
|
|
143
|
+
|
|
144
|
+
▸ (`data`): `void`
|
|
145
|
+
|
|
146
|
+
##### Parameters
|
|
147
|
+
|
|
148
|
+
| Name | Type |
|
|
149
|
+
| :------ | :------ |
|
|
150
|
+
| `data` | [`HookCommonPropertiesSurvey`](README.md#hookcommonpropertiessurvey) & \{ `button`: \{ `url`: `string` ; `url_target?`: `string` } ; `response`: \{ `id`: `string` } } |
|
|
151
|
+
|
|
152
|
+
##### Returns
|
|
153
|
+
|
|
154
|
+
`void`
|
|
155
|
+
|
|
156
|
+
___
|
|
157
|
+
|
|
115
158
|
### HookOnMessageCompleted
|
|
116
159
|
|
|
117
160
|
Ƭ **HookOnMessageCompleted**: (`data`: [`HookCommonPropertiesMessage`](README.md#hookcommonpropertiesmessage) & \{ `response`: \{ `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } }) => `void`
|
|
@@ -372,6 +415,8 @@ This is the Screeb tag hooks object available on `message.start` command.
|
|
|
372
415
|
|
|
373
416
|
| Name | Type | Description |
|
|
374
417
|
| :------ | :------ | :------ |
|
|
418
|
+
| `onButtonNavigateCompleted?` | [`HookOnButtonNavigateCompleted`](README.md#hookonbuttonnavigatecompleted) | This hook is triggered after a message/tour button "Navigate to URL" action ran (only fires when the SDK survives the navigation, e.g. `new-tab` or `in-page-spa`). |
|
|
419
|
+
| `onButtonNavigateStarted?` | [`HookOnButtonNavigateStarted`](README.md#hookonbuttonnavigatestarted) | This hook is triggered before a message/tour button "Navigate to URL" action runs. |
|
|
375
420
|
| `onMessageCompleted?` | [`HookOnMessageCompleted`](README.md#hookonmessagecompleted) | This hook is triggered when a message is completed |
|
|
376
421
|
| `onMessageHidden?` | [`HookOnMessageHidden`](README.md#hookonmessagehidden) | This hook is triggered when a message is hidden |
|
|
377
422
|
| `onMessageShowed?` | [`HookOnMessageShowed`](README.md#hookonmessageshowed) | This hook is triggered when a message is displayed on screen (also triggered when page is reloaded) |
|
|
@@ -390,6 +435,8 @@ This is the Screeb tag hooks object available on `survey.start` command.
|
|
|
390
435
|
|
|
391
436
|
| Name | Type | Description |
|
|
392
437
|
| :------ | :------ | :------ |
|
|
438
|
+
| `onButtonNavigateCompleted?` | [`HookOnButtonNavigateCompleted`](README.md#hookonbuttonnavigatecompleted) | This hook is triggered after a message/tour button "Navigate to URL" action ran (only fires when the SDK survives the navigation, e.g. `new-tab` or `in-page-spa`). |
|
|
439
|
+
| `onButtonNavigateStarted?` | [`HookOnButtonNavigateStarted`](README.md#hookonbuttonnavigatestarted) | This hook is triggered before a message/tour button "Navigate to URL" action runs. |
|
|
393
440
|
| `onQuestionReplied?` | [`HookOnQuestionReplied`](README.md#hookonquestionreplied) | This hook is triggered when a question is answered |
|
|
394
441
|
| `onSurveyCompleted?` | [`HookOnSurveyCompleted`](README.md#hookonsurveycompleted) | This hook is triggered when a survey is completed |
|
|
395
442
|
| `onSurveyHidden?` | [`HookOnSurveyHidden`](README.md#hookonsurveyhidden) | This hook is triggered when a survey is hidden |
|
|
@@ -478,6 +525,33 @@ ___
|
|
|
478
525
|
|
|
479
526
|
___
|
|
480
527
|
|
|
528
|
+
### ScreebEndpoints
|
|
529
|
+
|
|
530
|
+
Ƭ **ScreebEndpoints**: `Object`
|
|
531
|
+
|
|
532
|
+
Custom collector URLs used to bypass AdBlockers by routing Screeb traffic
|
|
533
|
+
through your own domain (reverse proxy).
|
|
534
|
+
|
|
535
|
+
Every key is optional: any omitted endpoint falls back to Screeb's default
|
|
536
|
+
URL. All endpoints must use `https://` (or `wss://` for the WebSocket one),
|
|
537
|
+
and the domains must be allow-listed in Screeb Admin → Settings → Custom Domains.
|
|
538
|
+
|
|
539
|
+
**`See`**
|
|
540
|
+
|
|
541
|
+
https://developers.screeb.app/sdk-js/custom-collector-url
|
|
542
|
+
|
|
543
|
+
#### Type declaration
|
|
544
|
+
|
|
545
|
+
| Name | Type | Description |
|
|
546
|
+
| :------ | :------ | :------ |
|
|
547
|
+
| `centipede?` | `string` | WebSocket (real-time targeting). Default: `wss://centipede.screeb.app`. |
|
|
548
|
+
| `hostedPage?` | `string` | Hosted survey page. Default: `https://survey.screeb.app`. |
|
|
549
|
+
| `report?` | `string` | Response reporting. Default: `https://r.screeb.app/rpc`. |
|
|
550
|
+
| `rpc?` | `string` | REST API (surveys, tracking). Default: `https://rpc.screeb.app/rpc`. |
|
|
551
|
+
| `static?` | `string` | Static assets (images, fonts). Default: `https://static.screeb.app`. |
|
|
552
|
+
|
|
553
|
+
___
|
|
554
|
+
|
|
481
555
|
### ScreebFunction
|
|
482
556
|
|
|
483
557
|
Ƭ **ScreebFunction**: (...`_`: `unknown`[]) => `void` \| `Promise`\<`unknown`\>
|
|
@@ -536,6 +610,7 @@ This is the Screeb tag options object.
|
|
|
536
610
|
|
|
537
611
|
| Name | Type | Description |
|
|
538
612
|
| :------ | :------ | :------ |
|
|
613
|
+
| `endpoints?` | [`ScreebEndpoints`](README.md#screebendpoints) | Override Screeb's collector URLs to route traffic through your own domain (custom domains / AdBlocker bypass). Only the endpoints you provide are overridden; the rest fall back to Screeb's defaults. **`See`** https://developers.screeb.app/sdk-js/custom-collector-url |
|
|
539
614
|
| `screebEndpoint?` | `string` | Please don't do this. |
|
|
540
615
|
| `sdkName?` | `string` | SDK name (eg: sdk-browser, sdk-react, sdk-angular, etc...) |
|
|
541
616
|
| `sdkVersion?` | `string` | SDK version (eg: 1.2.3) |
|
|
@@ -543,6 +618,33 @@ This is the Screeb tag options object.
|
|
|
543
618
|
|
|
544
619
|
___
|
|
545
620
|
|
|
621
|
+
### SpaNavigationHandler
|
|
622
|
+
|
|
623
|
+
Ƭ **SpaNavigationHandler**: (`url`: `string`) => `void` \| `Promise`\<`void`\>
|
|
624
|
+
|
|
625
|
+
Host-provided navigation handler for the `in-page-spa` "Navigate to URL"
|
|
626
|
+
target. It runs in your page (where your SPA router lives) instead of the tag
|
|
627
|
+
doing a `history.pushState` + `popstate` dispatch itself. Provide this when
|
|
628
|
+
your router does not resync on `popstate` (most React Router / Vue Router /
|
|
629
|
+
Angular Router setups do, so this is only needed for custom routers). May be
|
|
630
|
+
async so `onButtonNavigateCompleted` can await the route change.
|
|
631
|
+
|
|
632
|
+
#### Type declaration
|
|
633
|
+
|
|
634
|
+
▸ (`url`): `void` \| `Promise`\<`void`\>
|
|
635
|
+
|
|
636
|
+
##### Parameters
|
|
637
|
+
|
|
638
|
+
| Name | Type |
|
|
639
|
+
| :------ | :------ |
|
|
640
|
+
| `url` | `string` |
|
|
641
|
+
|
|
642
|
+
##### Returns
|
|
643
|
+
|
|
644
|
+
`void` \| `Promise`\<`void`\>
|
|
645
|
+
|
|
646
|
+
___
|
|
647
|
+
|
|
546
648
|
### Survey
|
|
547
649
|
|
|
548
650
|
Ƭ **Survey**: `Object`
|
|
@@ -885,7 +987,7 @@ ___
|
|
|
885
987
|
|
|
886
988
|
### init
|
|
887
989
|
|
|
888
|
-
▸ **init**(`websiteId`, `userId?`, `userProperties?`, `hooks?`, `language?`): `void` \| `Promise`\<`unknown`\>
|
|
990
|
+
▸ **init**(`websiteId`, `userId?`, `userProperties?`, `hooks?`, `language?`, `spaNavigationHandler?`): `void` \| `Promise`\<`unknown`\>
|
|
889
991
|
|
|
890
992
|
Initializes Screeb tag.
|
|
891
993
|
|
|
@@ -898,6 +1000,7 @@ Initializes Screeb tag.
|
|
|
898
1000
|
| `userProperties?` | [`PropertyRecord`](README.md#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 ``` |
|
|
899
1001
|
| `hooks?` | [`HooksInit`](README.md#hooksinit) | Hooks to be called when SDK is ready or a survey is showed, started, completed, hidden or when a question is replied. |
|
|
900
1002
|
| `language?` | `string` | Force a specific language for the tag. eg: 'en'. default: browser language. |
|
|
1003
|
+
| `spaNavigationHandler?` | [`SpaNavigationHandler`](README.md#spanavigationhandler) | Optional handler for the `in-page-spa` "Navigate to URL" target. Runs in your page so your SPA router can navigate without a full reload. Only needed for custom routers that don't resync on `popstate` (React Router / Vue Router / Angular Router work out of the box). May be async so `onButtonNavigateCompleted` awaits it. |
|
|
901
1004
|
|
|
902
1005
|
#### Returns
|
|
903
1006
|
|
|
@@ -921,6 +1024,8 @@ Screeb.init(
|
|
|
921
1024
|
{
|
|
922
1025
|
version: "1.0.0",
|
|
923
1026
|
onReady: (payload) => console.log("Screeb SDK is ready!", payload),
|
|
1027
|
+
onButtonNavigateStarted: (payload) => console.log("Button navigate started", payload),
|
|
1028
|
+
onButtonNavigateCompleted: (payload) => console.log("Button navigate completed", payload),
|
|
924
1029
|
},
|
|
925
1030
|
"en"
|
|
926
1031
|
);
|
|
@@ -1144,26 +1249,6 @@ Screeb.surveyStart(
|
|
|
1144
1249
|
|
|
1145
1250
|
___
|
|
1146
1251
|
|
|
1147
|
-
### targetingCheck
|
|
1148
|
-
|
|
1149
|
-
▸ **targetingCheck**(): `void` \| `Promise`\<`unknown`\>
|
|
1150
|
-
|
|
1151
|
-
Forces a targeting check.
|
|
1152
|
-
|
|
1153
|
-
#### Returns
|
|
1154
|
-
|
|
1155
|
-
`void` \| `Promise`\<`unknown`\>
|
|
1156
|
-
|
|
1157
|
-
**`Example`**
|
|
1158
|
-
|
|
1159
|
-
```ts
|
|
1160
|
-
import * as Screeb from "@screeb/sdk-browser";
|
|
1161
|
-
|
|
1162
|
-
Screeb.targetingCheck();
|
|
1163
|
-
```
|
|
1164
|
-
|
|
1165
|
-
___
|
|
1166
|
-
|
|
1167
1252
|
### targetingDebug
|
|
1168
1253
|
|
|
1169
1254
|
▸ **targetingDebug**(): `void` \| `Promise`\<`unknown`\>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@screeb/sdk-browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Screeb's browser sdk.",
|
|
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-browser"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"author": "Screeb's frontend team",
|
|
@@ -41,21 +41,21 @@
|
|
|
41
41
|
"test": "echo 'test disabled'"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@screeb/eslint-config": "^0.1.
|
|
45
|
-
"@screeb/typescript-config": "^0.1.
|
|
46
|
-
"@types/jest": "^29.5.
|
|
47
|
-
"@types/node": "^20.8.
|
|
44
|
+
"@screeb/eslint-config": "^0.1.8",
|
|
45
|
+
"@screeb/typescript-config": "^0.1.13",
|
|
46
|
+
"@types/jest": "^29.5.14",
|
|
47
|
+
"@types/node": "^20.8.10",
|
|
48
48
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
49
49
|
"eslint": "^8.51.0",
|
|
50
50
|
"eslint-plugin-import": "^2.28.1",
|
|
51
|
-
"eslint-plugin-jest": "^27.4.
|
|
51
|
+
"eslint-plugin-jest": "^27.4.3",
|
|
52
52
|
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
53
53
|
"eslint-plugin-prettier": "^5.0.1",
|
|
54
54
|
"jest": "^29.7.0",
|
|
55
55
|
"jest-environment-jsdom": "^29.7.0",
|
|
56
56
|
"prettier": "^3.0.3",
|
|
57
57
|
"rollup": "^4.0.2",
|
|
58
|
-
"ts-jest": "^29.1.
|
|
58
|
+
"ts-jest": "^29.1.5",
|
|
59
59
|
"typedoc": "^0.25.2",
|
|
60
60
|
"typedoc-plugin-markdown": "^3.16.0"
|
|
61
61
|
},
|