@screeb/sdk-browser 0.6.1 → 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/dist/cjs/hooks.types.d.ts +26 -0
- package/dist/cjs/index.cjs +12 -14
- package/dist/cjs/index.d.ts +9 -13
- package/dist/cjs/types.d.ts +9 -0
- package/dist/es/hooks.types.d.ts +26 -0
- package/dist/es/index.d.ts +9 -13
- package/dist/es/index.mjs +13 -14
- package/dist/es/types.d.ts +9 -0
- package/docs/README.md +78 -22
- package/package.json +3 -3
|
@@ -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
|
@@ -118,6 +118,11 @@ var load = function (options) {
|
|
|
118
118
|
*
|
|
119
119
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
120
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
|
+
*
|
|
121
126
|
* @example
|
|
122
127
|
* ```ts
|
|
123
128
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -135,12 +140,14 @@ var load = function (options) {
|
|
|
135
140
|
* {
|
|
136
141
|
* version: "1.0.0",
|
|
137
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),
|
|
138
145
|
* },
|
|
139
146
|
* "en"
|
|
140
147
|
* );
|
|
141
148
|
* ```
|
|
142
149
|
*/
|
|
143
|
-
var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
150
|
+
var init = function (websiteId, userId, userProperties, hooks, language, spaNavigationHandler) {
|
|
144
151
|
var identityObject;
|
|
145
152
|
if (userId || userProperties) {
|
|
146
153
|
identityObject = {
|
|
@@ -154,6 +161,9 @@ var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
|
154
161
|
if (language) {
|
|
155
162
|
identityObject = __assign(__assign({}, identityObject), { language: language });
|
|
156
163
|
}
|
|
164
|
+
if (spaNavigationHandler) {
|
|
165
|
+
identityObject = __assign(__assign({}, identityObject), { spaNavigationHandler: spaNavigationHandler });
|
|
166
|
+
}
|
|
157
167
|
return callScreebCommand("init", websiteId, identityObject);
|
|
158
168
|
};
|
|
159
169
|
/**
|
|
@@ -508,17 +518,6 @@ var sessionReplayStop = function () { return callScreebCommand("session-replay.s
|
|
|
508
518
|
var sessionReplayStart = function () {
|
|
509
519
|
return callScreebCommand("session-replay.start");
|
|
510
520
|
};
|
|
511
|
-
/**
|
|
512
|
-
* Forces a targeting check.
|
|
513
|
-
*
|
|
514
|
-
* @example
|
|
515
|
-
* ```ts
|
|
516
|
-
* import * as Screeb from "@screeb/sdk-browser";
|
|
517
|
-
*
|
|
518
|
-
* Screeb.targetingCheck();
|
|
519
|
-
* ```
|
|
520
|
-
*/
|
|
521
|
-
var targetingCheck = function () { return callScreebCommand("targeting.check"); };
|
|
522
521
|
/**
|
|
523
522
|
* Prints the current state of the targeting engine.
|
|
524
523
|
*
|
|
@@ -563,6 +562,5 @@ exports.sessionReplayStart = sessionReplayStart;
|
|
|
563
562
|
exports.sessionReplayStop = sessionReplayStop;
|
|
564
563
|
exports.surveyClose = surveyClose;
|
|
565
564
|
exports.surveyStart = surveyStart;
|
|
566
|
-
exports.targetingCheck = targetingCheck;
|
|
567
565
|
exports.targetingDebug = targetingDebug;
|
|
568
|
-
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
|
/**
|
|
@@ -35,6 +35,11 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
35
35
|
*
|
|
36
36
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
37
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
|
+
*
|
|
38
43
|
* @example
|
|
39
44
|
* ```ts
|
|
40
45
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -52,12 +57,14 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
52
57
|
* {
|
|
53
58
|
* version: "1.0.0",
|
|
54
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),
|
|
55
62
|
* },
|
|
56
63
|
* "en"
|
|
57
64
|
* );
|
|
58
65
|
* ```
|
|
59
66
|
*/
|
|
60
|
-
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>;
|
|
61
68
|
/**
|
|
62
69
|
* Checks if Screeb tag has been loaded.
|
|
63
70
|
*
|
|
@@ -376,17 +383,6 @@ export declare const sessionReplayStop: () => void | Promise<unknown>;
|
|
|
376
383
|
* ```
|
|
377
384
|
*/
|
|
378
385
|
export declare const sessionReplayStart: () => void | Promise<unknown>;
|
|
379
|
-
/**
|
|
380
|
-
* Forces a targeting check.
|
|
381
|
-
*
|
|
382
|
-
* @example
|
|
383
|
-
* ```ts
|
|
384
|
-
* import * as Screeb from "@screeb/sdk-browser";
|
|
385
|
-
*
|
|
386
|
-
* Screeb.targetingCheck();
|
|
387
|
-
* ```
|
|
388
|
-
*/
|
|
389
|
-
export declare const targetingCheck: () => void | Promise<unknown>;
|
|
390
386
|
/**
|
|
391
387
|
* Prints the current state of the targeting engine.
|
|
392
388
|
*
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -47,6 +47,15 @@ export type ScreebOptions = {
|
|
|
47
47
|
/** @hidden Use a specific platform */
|
|
48
48
|
platform?: string;
|
|
49
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>;
|
|
50
59
|
export type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
|
|
51
60
|
/** This is the Screeb object publicly exposed in browser `window`. */
|
|
52
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
|
/**
|
|
@@ -35,6 +35,11 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
35
35
|
*
|
|
36
36
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
37
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
|
+
*
|
|
38
43
|
* @example
|
|
39
44
|
* ```ts
|
|
40
45
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -52,12 +57,14 @@ export declare const load: (options?: ScreebOptions) => Promise<undefined>;
|
|
|
52
57
|
* {
|
|
53
58
|
* version: "1.0.0",
|
|
54
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),
|
|
55
62
|
* },
|
|
56
63
|
* "en"
|
|
57
64
|
* );
|
|
58
65
|
* ```
|
|
59
66
|
*/
|
|
60
|
-
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>;
|
|
61
68
|
/**
|
|
62
69
|
* Checks if Screeb tag has been loaded.
|
|
63
70
|
*
|
|
@@ -376,17 +383,6 @@ export declare const sessionReplayStop: () => void | Promise<unknown>;
|
|
|
376
383
|
* ```
|
|
377
384
|
*/
|
|
378
385
|
export declare const sessionReplayStart: () => void | Promise<unknown>;
|
|
379
|
-
/**
|
|
380
|
-
* Forces a targeting check.
|
|
381
|
-
*
|
|
382
|
-
* @example
|
|
383
|
-
* ```ts
|
|
384
|
-
* import * as Screeb from "@screeb/sdk-browser";
|
|
385
|
-
*
|
|
386
|
-
* Screeb.targetingCheck();
|
|
387
|
-
* ```
|
|
388
|
-
*/
|
|
389
|
-
export declare const targetingCheck: () => void | Promise<unknown>;
|
|
390
386
|
/**
|
|
391
387
|
* Prints the current state of the targeting engine.
|
|
392
388
|
*
|
package/dist/es/index.mjs
CHANGED
|
@@ -116,6 +116,11 @@ var load = function (options) {
|
|
|
116
116
|
*
|
|
117
117
|
* @param language Force a specific language for the tag. eg: 'en'. default: browser language.
|
|
118
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
|
+
*
|
|
119
124
|
* @example
|
|
120
125
|
* ```ts
|
|
121
126
|
* import * as Screeb from "@screeb/sdk-browser";
|
|
@@ -133,12 +138,14 @@ var load = function (options) {
|
|
|
133
138
|
* {
|
|
134
139
|
* version: "1.0.0",
|
|
135
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),
|
|
136
143
|
* },
|
|
137
144
|
* "en"
|
|
138
145
|
* );
|
|
139
146
|
* ```
|
|
140
147
|
*/
|
|
141
|
-
var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
148
|
+
var init = function (websiteId, userId, userProperties, hooks, language, spaNavigationHandler) {
|
|
142
149
|
var identityObject;
|
|
143
150
|
if (userId || userProperties) {
|
|
144
151
|
identityObject = {
|
|
@@ -152,6 +159,9 @@ var init = function (websiteId, userId, userProperties, hooks, language) {
|
|
|
152
159
|
if (language) {
|
|
153
160
|
identityObject = __assign(__assign({}, identityObject), { language: language });
|
|
154
161
|
}
|
|
162
|
+
if (spaNavigationHandler) {
|
|
163
|
+
identityObject = __assign(__assign({}, identityObject), { spaNavigationHandler: spaNavigationHandler });
|
|
164
|
+
}
|
|
155
165
|
return callScreebCommand("init", websiteId, identityObject);
|
|
156
166
|
};
|
|
157
167
|
/**
|
|
@@ -506,17 +516,6 @@ var sessionReplayStop = function () { return callScreebCommand("session-replay.s
|
|
|
506
516
|
var sessionReplayStart = function () {
|
|
507
517
|
return callScreebCommand("session-replay.start");
|
|
508
518
|
};
|
|
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
519
|
/**
|
|
521
520
|
* Prints the current state of the targeting engine.
|
|
522
521
|
*
|
|
@@ -543,5 +542,5 @@ var targetingCheck = function () { return callScreebCommand("targeting.check");
|
|
|
543
542
|
*/
|
|
544
543
|
var targetingDebug = function () { return callScreebCommand("targeting.debug"); };
|
|
545
544
|
|
|
546
|
-
export { close, debug, eventTrack, identity, identityGet, identityGroupAssign, identityGroupUnassign, identityProperties, identityReset, init, isLoaded, load, messageClose, messageStart, sessionReplayStart, sessionReplayStop, surveyClose, surveyStart,
|
|
547
|
-
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
|
@@ -47,6 +47,15 @@ export type ScreebOptions = {
|
|
|
47
47
|
/** @hidden Use a specific platform */
|
|
48
48
|
platform?: string;
|
|
49
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>;
|
|
50
59
|
export type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
|
|
51
60
|
/** This is the Screeb object publicly exposed in browser `window`. */
|
|
52
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)
|
|
@@ -38,6 +40,7 @@
|
|
|
38
40
|
- [ScreebIdentityGetReturn](README.md#screebidentitygetreturn)
|
|
39
41
|
- [ScreebObject](README.md#screebobject)
|
|
40
42
|
- [ScreebOptions](README.md#screeboptions)
|
|
43
|
+
- [SpaNavigationHandler](README.md#spanavigationhandler)
|
|
41
44
|
- [Survey](README.md#survey)
|
|
42
45
|
- [SurveyFormat](README.md#surveyformat)
|
|
43
46
|
- [SurveyPosition](README.md#surveyposition)
|
|
@@ -64,7 +67,6 @@
|
|
|
64
67
|
- [sessionReplayStop](README.md#sessionreplaystop)
|
|
65
68
|
- [surveyClose](README.md#surveyclose)
|
|
66
69
|
- [surveyStart](README.md#surveystart)
|
|
67
|
-
- [targetingCheck](README.md#targetingcheck)
|
|
68
70
|
- [targetingDebug](README.md#targetingdebug)
|
|
69
71
|
|
|
70
72
|
## Type Aliases
|
|
@@ -113,6 +115,46 @@ ___
|
|
|
113
115
|
|
|
114
116
|
___
|
|
115
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
|
+
|
|
116
158
|
### HookOnMessageCompleted
|
|
117
159
|
|
|
118
160
|
Ƭ **HookOnMessageCompleted**: (`data`: [`HookCommonPropertiesMessage`](README.md#hookcommonpropertiesmessage) & \{ `response`: \{ `id`: `string` ; `items`: [`ResponseItem`](README.md#responseitem)[] } }) => `void`
|
|
@@ -373,6 +415,8 @@ This is the Screeb tag hooks object available on `message.start` command.
|
|
|
373
415
|
|
|
374
416
|
| Name | Type | Description |
|
|
375
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. |
|
|
376
420
|
| `onMessageCompleted?` | [`HookOnMessageCompleted`](README.md#hookonmessagecompleted) | This hook is triggered when a message is completed |
|
|
377
421
|
| `onMessageHidden?` | [`HookOnMessageHidden`](README.md#hookonmessagehidden) | This hook is triggered when a message is hidden |
|
|
378
422
|
| `onMessageShowed?` | [`HookOnMessageShowed`](README.md#hookonmessageshowed) | This hook is triggered when a message is displayed on screen (also triggered when page is reloaded) |
|
|
@@ -391,6 +435,8 @@ This is the Screeb tag hooks object available on `survey.start` command.
|
|
|
391
435
|
|
|
392
436
|
| Name | Type | Description |
|
|
393
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. |
|
|
394
440
|
| `onQuestionReplied?` | [`HookOnQuestionReplied`](README.md#hookonquestionreplied) | This hook is triggered when a question is answered |
|
|
395
441
|
| `onSurveyCompleted?` | [`HookOnSurveyCompleted`](README.md#hookonsurveycompleted) | This hook is triggered when a survey is completed |
|
|
396
442
|
| `onSurveyHidden?` | [`HookOnSurveyHidden`](README.md#hookonsurveyhidden) | This hook is triggered when a survey is hidden |
|
|
@@ -572,6 +618,33 @@ This is the Screeb tag options object.
|
|
|
572
618
|
|
|
573
619
|
___
|
|
574
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
|
+
|
|
575
648
|
### Survey
|
|
576
649
|
|
|
577
650
|
Ƭ **Survey**: `Object`
|
|
@@ -914,7 +987,7 @@ ___
|
|
|
914
987
|
|
|
915
988
|
### init
|
|
916
989
|
|
|
917
|
-
▸ **init**(`websiteId`, `userId?`, `userProperties?`, `hooks?`, `language?`): `void` \| `Promise`\<`unknown`\>
|
|
990
|
+
▸ **init**(`websiteId`, `userId?`, `userProperties?`, `hooks?`, `language?`, `spaNavigationHandler?`): `void` \| `Promise`\<`unknown`\>
|
|
918
991
|
|
|
919
992
|
Initializes Screeb tag.
|
|
920
993
|
|
|
@@ -927,6 +1000,7 @@ Initializes Screeb tag.
|
|
|
927
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 ``` |
|
|
928
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. |
|
|
929
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. |
|
|
930
1004
|
|
|
931
1005
|
#### Returns
|
|
932
1006
|
|
|
@@ -950,6 +1024,8 @@ Screeb.init(
|
|
|
950
1024
|
{
|
|
951
1025
|
version: "1.0.0",
|
|
952
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),
|
|
953
1029
|
},
|
|
954
1030
|
"en"
|
|
955
1031
|
);
|
|
@@ -1173,26 +1249,6 @@ Screeb.surveyStart(
|
|
|
1173
1249
|
|
|
1174
1250
|
___
|
|
1175
1251
|
|
|
1176
|
-
### targetingCheck
|
|
1177
|
-
|
|
1178
|
-
▸ **targetingCheck**(): `void` \| `Promise`\<`unknown`\>
|
|
1179
|
-
|
|
1180
|
-
Forces a targeting check.
|
|
1181
|
-
|
|
1182
|
-
#### Returns
|
|
1183
|
-
|
|
1184
|
-
`void` \| `Promise`\<`unknown`\>
|
|
1185
|
-
|
|
1186
|
-
**`Example`**
|
|
1187
|
-
|
|
1188
|
-
```ts
|
|
1189
|
-
import * as Screeb from "@screeb/sdk-browser";
|
|
1190
|
-
|
|
1191
|
-
Screeb.targetingCheck();
|
|
1192
|
-
```
|
|
1193
|
-
|
|
1194
|
-
___
|
|
1195
|
-
|
|
1196
1252
|
### targetingDebug
|
|
1197
1253
|
|
|
1198
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",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"test": "echo 'test disabled'"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@screeb/eslint-config": "^0.1.
|
|
45
|
-
"@screeb/typescript-config": "^0.1.
|
|
44
|
+
"@screeb/eslint-config": "^0.1.8",
|
|
45
|
+
"@screeb/typescript-config": "^0.1.13",
|
|
46
46
|
"@types/jest": "^29.5.14",
|
|
47
47
|
"@types/node": "^20.8.10",
|
|
48
48
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|