@ninetailed/experience.js 6.4.0-beta.1 → 6.4.0-beta.5
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/index.cjs +20 -18
- package/index.js +20 -18
- package/lib/Ninetailed.d.ts +10 -1
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -2621,7 +2621,7 @@ const ninetailedPlugin = ({
|
|
|
2621
2621
|
};
|
|
2622
2622
|
}
|
|
2623
2623
|
try {
|
|
2624
|
-
const anonymousId = _instance.storage.getItem(ANONYMOUS_ID);
|
|
2624
|
+
const anonymousId = yield _instance.storage.getItem(ANONYMOUS_ID);
|
|
2625
2625
|
const profile = yield apiClient.upsertProfile({
|
|
2626
2626
|
profileId: anonymousId,
|
|
2627
2627
|
events
|
|
@@ -2629,8 +2629,8 @@ const ninetailedPlugin = ({
|
|
|
2629
2629
|
locale,
|
|
2630
2630
|
enabledFeatures
|
|
2631
2631
|
});
|
|
2632
|
-
_instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2633
|
-
_instance.storage.setItem(PROFILE_FALLBACK_CACHE, profile);
|
|
2632
|
+
yield _instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2633
|
+
yield _instance.storage.setItem(PROFILE_FALLBACK_CACHE, profile);
|
|
2634
2634
|
experience_jsShared.logger.debug('Profile from api: ', profile);
|
|
2635
2635
|
_instance.dispatch({
|
|
2636
2636
|
type: PROFILE_CHANGE,
|
|
@@ -2642,7 +2642,7 @@ const ninetailedPlugin = ({
|
|
|
2642
2642
|
};
|
|
2643
2643
|
} catch (error) {
|
|
2644
2644
|
experience_jsShared.logger.debug('An error occurred during flushing the events: ', error);
|
|
2645
|
-
const fallbackProfile = _instance.storage.getItem(PROFILE_FALLBACK_CACHE);
|
|
2645
|
+
const fallbackProfile = yield _instance.storage.getItem(PROFILE_FALLBACK_CACHE);
|
|
2646
2646
|
if (fallbackProfile) {
|
|
2647
2647
|
experience_jsShared.logger.debug('Found a fallback profile - will use this.');
|
|
2648
2648
|
_instance.dispatch({
|
|
@@ -2683,21 +2683,21 @@ const ninetailedPlugin = ({
|
|
|
2683
2683
|
config: {},
|
|
2684
2684
|
initialize: ({
|
|
2685
2685
|
instance
|
|
2686
|
-
}) => {
|
|
2686
|
+
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2687
2687
|
_instance = instance;
|
|
2688
|
-
if (instance.storage.getItem(DEBUG_FLAG)) {
|
|
2688
|
+
if (yield instance.storage.getItem(DEBUG_FLAG)) {
|
|
2689
2689
|
experience_jsShared.logger.addSink(new experience_jsShared.ConsoleLogSink());
|
|
2690
2690
|
experience_jsShared.logger.info('Ninetailed Debug Mode is enabled.');
|
|
2691
2691
|
}
|
|
2692
2692
|
// legacy support for the old anonymousId
|
|
2693
|
-
const legacyAnonymousId = instance.storage.getItem(LEGACY_ANONYMOUS_ID);
|
|
2693
|
+
const legacyAnonymousId = yield instance.storage.getItem(LEGACY_ANONYMOUS_ID);
|
|
2694
2694
|
if (legacyAnonymousId) {
|
|
2695
2695
|
experience_jsShared.logger.debug('Found legacy anonymousId, migrating to new one.', legacyAnonymousId);
|
|
2696
|
-
instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
|
|
2697
|
-
instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
2696
|
+
yield instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
|
|
2697
|
+
yield instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
2698
2698
|
}
|
|
2699
2699
|
if (profile) {
|
|
2700
|
-
instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2700
|
+
yield instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2701
2701
|
}
|
|
2702
2702
|
instance.on(SET_ENABLED_FEATURES, ({
|
|
2703
2703
|
payload
|
|
@@ -2705,7 +2705,7 @@ const ninetailedPlugin = ({
|
|
|
2705
2705
|
enabledFeatures = payload.features || [];
|
|
2706
2706
|
});
|
|
2707
2707
|
experience_jsShared.logger.debug('Ninetailed Core plugin initialized.');
|
|
2708
|
-
},
|
|
2708
|
+
}),
|
|
2709
2709
|
flush: asyncThrottle(flush),
|
|
2710
2710
|
pageStart: params => {
|
|
2711
2711
|
return abortNonClientEvents(params);
|
|
@@ -2775,9 +2775,10 @@ const ninetailedPlugin = ({
|
|
|
2775
2775
|
instance.dispatch({
|
|
2776
2776
|
type: PROFILE_RESET
|
|
2777
2777
|
});
|
|
2778
|
-
instance.storage.removeItem(ANONYMOUS_ID);
|
|
2779
|
-
instance.storage.removeItem(PROFILE_FALLBACK_CACHE);
|
|
2778
|
+
yield instance.storage.removeItem(ANONYMOUS_ID);
|
|
2779
|
+
yield instance.storage.removeItem(PROFILE_FALLBACK_CACHE);
|
|
2780
2780
|
experience_jsShared.logger.debug('Removed old profile data from localstorage.');
|
|
2781
|
+
// TODO replace with a proper event instead of abusing the track event ssystem.
|
|
2781
2782
|
yield ninetailed.track('nt_reset');
|
|
2782
2783
|
experience_jsShared.logger.info('Profile reset successful.');
|
|
2783
2784
|
yield delay(10);
|
|
@@ -2787,11 +2788,11 @@ const ninetailedPlugin = ({
|
|
|
2787
2788
|
const instance = args[args.length - 1];
|
|
2788
2789
|
const consoleLogSink = new experience_jsShared.ConsoleLogSink();
|
|
2789
2790
|
if (enabled) {
|
|
2790
|
-
instance.storage.setItem(DEBUG_FLAG, true);
|
|
2791
|
+
yield instance.storage.setItem(DEBUG_FLAG, true);
|
|
2791
2792
|
experience_jsShared.logger.addSink(consoleLogSink);
|
|
2792
2793
|
experience_jsShared.logger.info('Debug mode enabled.');
|
|
2793
2794
|
} else {
|
|
2794
|
-
instance.storage.removeItem(DEBUG_FLAG);
|
|
2795
|
+
yield instance.storage.removeItem(DEBUG_FLAG);
|
|
2795
2796
|
experience_jsShared.logger.info('Debug mode disabled.');
|
|
2796
2797
|
experience_jsShared.logger.removeSink(consoleLogSink.name);
|
|
2797
2798
|
}
|
|
@@ -3364,7 +3365,8 @@ class Ninetailed {
|
|
|
3364
3365
|
onLog,
|
|
3365
3366
|
onError,
|
|
3366
3367
|
buildClientContext,
|
|
3367
|
-
componentViewTrackingThreshold = 2000
|
|
3368
|
+
componentViewTrackingThreshold = 2000,
|
|
3369
|
+
storage
|
|
3368
3370
|
} = {}) {
|
|
3369
3371
|
this.isInitialized = false;
|
|
3370
3372
|
this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3572,10 +3574,10 @@ class Ninetailed {
|
|
|
3572
3574
|
buildClientContext,
|
|
3573
3575
|
ninetailed: this
|
|
3574
3576
|
});
|
|
3575
|
-
this.instance = Analytics__default["default"]({
|
|
3577
|
+
this.instance = Analytics__default["default"](Object.assign({
|
|
3576
3578
|
app: 'ninetailed',
|
|
3577
3579
|
plugins: [...this.plugins, this.eventQueue]
|
|
3578
|
-
});
|
|
3580
|
+
}, storage ? storage : {}));
|
|
3579
3581
|
const detachOnReadyListener = this.instance.on('ready', () => {
|
|
3580
3582
|
this.isInitialized = true;
|
|
3581
3583
|
experience_jsShared.logger.info('Ninetailed Experience.js SDK is completely initialized.');
|
package/index.js
CHANGED
|
@@ -2614,7 +2614,7 @@ const ninetailedPlugin = ({
|
|
|
2614
2614
|
};
|
|
2615
2615
|
}
|
|
2616
2616
|
try {
|
|
2617
|
-
const anonymousId = _instance.storage.getItem(ANONYMOUS_ID);
|
|
2617
|
+
const anonymousId = yield _instance.storage.getItem(ANONYMOUS_ID);
|
|
2618
2618
|
const profile = yield apiClient.upsertProfile({
|
|
2619
2619
|
profileId: anonymousId,
|
|
2620
2620
|
events
|
|
@@ -2622,8 +2622,8 @@ const ninetailedPlugin = ({
|
|
|
2622
2622
|
locale,
|
|
2623
2623
|
enabledFeatures
|
|
2624
2624
|
});
|
|
2625
|
-
_instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2626
|
-
_instance.storage.setItem(PROFILE_FALLBACK_CACHE, profile);
|
|
2625
|
+
yield _instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2626
|
+
yield _instance.storage.setItem(PROFILE_FALLBACK_CACHE, profile);
|
|
2627
2627
|
logger.debug('Profile from api: ', profile);
|
|
2628
2628
|
_instance.dispatch({
|
|
2629
2629
|
type: PROFILE_CHANGE,
|
|
@@ -2635,7 +2635,7 @@ const ninetailedPlugin = ({
|
|
|
2635
2635
|
};
|
|
2636
2636
|
} catch (error) {
|
|
2637
2637
|
logger.debug('An error occurred during flushing the events: ', error);
|
|
2638
|
-
const fallbackProfile = _instance.storage.getItem(PROFILE_FALLBACK_CACHE);
|
|
2638
|
+
const fallbackProfile = yield _instance.storage.getItem(PROFILE_FALLBACK_CACHE);
|
|
2639
2639
|
if (fallbackProfile) {
|
|
2640
2640
|
logger.debug('Found a fallback profile - will use this.');
|
|
2641
2641
|
_instance.dispatch({
|
|
@@ -2676,21 +2676,21 @@ const ninetailedPlugin = ({
|
|
|
2676
2676
|
config: {},
|
|
2677
2677
|
initialize: ({
|
|
2678
2678
|
instance
|
|
2679
|
-
}) => {
|
|
2679
|
+
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2680
2680
|
_instance = instance;
|
|
2681
|
-
if (instance.storage.getItem(DEBUG_FLAG)) {
|
|
2681
|
+
if (yield instance.storage.getItem(DEBUG_FLAG)) {
|
|
2682
2682
|
logger.addSink(new ConsoleLogSink());
|
|
2683
2683
|
logger.info('Ninetailed Debug Mode is enabled.');
|
|
2684
2684
|
}
|
|
2685
2685
|
// legacy support for the old anonymousId
|
|
2686
|
-
const legacyAnonymousId = instance.storage.getItem(LEGACY_ANONYMOUS_ID);
|
|
2686
|
+
const legacyAnonymousId = yield instance.storage.getItem(LEGACY_ANONYMOUS_ID);
|
|
2687
2687
|
if (legacyAnonymousId) {
|
|
2688
2688
|
logger.debug('Found legacy anonymousId, migrating to new one.', legacyAnonymousId);
|
|
2689
|
-
instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
|
|
2690
|
-
instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
2689
|
+
yield instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
|
|
2690
|
+
yield instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
2691
2691
|
}
|
|
2692
2692
|
if (profile) {
|
|
2693
|
-
instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2693
|
+
yield instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2694
2694
|
}
|
|
2695
2695
|
instance.on(SET_ENABLED_FEATURES, ({
|
|
2696
2696
|
payload
|
|
@@ -2698,7 +2698,7 @@ const ninetailedPlugin = ({
|
|
|
2698
2698
|
enabledFeatures = payload.features || [];
|
|
2699
2699
|
});
|
|
2700
2700
|
logger.debug('Ninetailed Core plugin initialized.');
|
|
2701
|
-
},
|
|
2701
|
+
}),
|
|
2702
2702
|
flush: asyncThrottle(flush),
|
|
2703
2703
|
pageStart: params => {
|
|
2704
2704
|
return abortNonClientEvents(params);
|
|
@@ -2768,9 +2768,10 @@ const ninetailedPlugin = ({
|
|
|
2768
2768
|
instance.dispatch({
|
|
2769
2769
|
type: PROFILE_RESET
|
|
2770
2770
|
});
|
|
2771
|
-
instance.storage.removeItem(ANONYMOUS_ID);
|
|
2772
|
-
instance.storage.removeItem(PROFILE_FALLBACK_CACHE);
|
|
2771
|
+
yield instance.storage.removeItem(ANONYMOUS_ID);
|
|
2772
|
+
yield instance.storage.removeItem(PROFILE_FALLBACK_CACHE);
|
|
2773
2773
|
logger.debug('Removed old profile data from localstorage.');
|
|
2774
|
+
// TODO replace with a proper event instead of abusing the track event ssystem.
|
|
2774
2775
|
yield ninetailed.track('nt_reset');
|
|
2775
2776
|
logger.info('Profile reset successful.');
|
|
2776
2777
|
yield delay(10);
|
|
@@ -2780,11 +2781,11 @@ const ninetailedPlugin = ({
|
|
|
2780
2781
|
const instance = args[args.length - 1];
|
|
2781
2782
|
const consoleLogSink = new ConsoleLogSink();
|
|
2782
2783
|
if (enabled) {
|
|
2783
|
-
instance.storage.setItem(DEBUG_FLAG, true);
|
|
2784
|
+
yield instance.storage.setItem(DEBUG_FLAG, true);
|
|
2784
2785
|
logger.addSink(consoleLogSink);
|
|
2785
2786
|
logger.info('Debug mode enabled.');
|
|
2786
2787
|
} else {
|
|
2787
|
-
instance.storage.removeItem(DEBUG_FLAG);
|
|
2788
|
+
yield instance.storage.removeItem(DEBUG_FLAG);
|
|
2788
2789
|
logger.info('Debug mode disabled.');
|
|
2789
2790
|
logger.removeSink(consoleLogSink.name);
|
|
2790
2791
|
}
|
|
@@ -3357,7 +3358,8 @@ class Ninetailed {
|
|
|
3357
3358
|
onLog,
|
|
3358
3359
|
onError,
|
|
3359
3360
|
buildClientContext,
|
|
3360
|
-
componentViewTrackingThreshold = 2000
|
|
3361
|
+
componentViewTrackingThreshold = 2000,
|
|
3362
|
+
storage
|
|
3361
3363
|
} = {}) {
|
|
3362
3364
|
this.isInitialized = false;
|
|
3363
3365
|
this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3565,10 +3567,10 @@ class Ninetailed {
|
|
|
3565
3567
|
buildClientContext,
|
|
3566
3568
|
ninetailed: this
|
|
3567
3569
|
});
|
|
3568
|
-
this.instance = Analytics({
|
|
3570
|
+
this.instance = Analytics(Object.assign({
|
|
3569
3571
|
app: 'ninetailed',
|
|
3570
3572
|
plugins: [...this.plugins, this.eventQueue]
|
|
3571
|
-
});
|
|
3573
|
+
}, storage ? storage : {}));
|
|
3572
3574
|
const detachOnReadyListener = this.instance.on('ready', () => {
|
|
3573
3575
|
this.isInitialized = true;
|
|
3574
3576
|
logger.info('Ninetailed Experience.js SDK is completely initialized.');
|
package/lib/Ninetailed.d.ts
CHANGED
|
@@ -12,6 +12,14 @@ declare global {
|
|
|
12
12
|
} & unknown;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
+
type GetItem<T = any> = (key: string) => Promise<T>;
|
|
16
|
+
type SetItem = (key: string, value: string) => Promise<void>;
|
|
17
|
+
type RemoveItem = (key: string) => Promise<void>;
|
|
18
|
+
export type Storage = {
|
|
19
|
+
getItem: GetItem;
|
|
20
|
+
setItem: SetItem;
|
|
21
|
+
removeItem: RemoveItem;
|
|
22
|
+
};
|
|
15
23
|
type Options = {
|
|
16
24
|
url?: string;
|
|
17
25
|
locale?: Locale;
|
|
@@ -22,6 +30,7 @@ type Options = {
|
|
|
22
30
|
onError?: OnErrorHandler;
|
|
23
31
|
componentViewTrackingThreshold?: number;
|
|
24
32
|
buildClientContext?: () => NinetailedRequestContext;
|
|
33
|
+
storage?: Storage;
|
|
25
34
|
};
|
|
26
35
|
type NinetailedApiClientInstanceOrOptions = NinetailedApiClient | NinetailedApiClientOptions;
|
|
27
36
|
export declare class Ninetailed implements NinetailedInstance {
|
|
@@ -37,7 +46,7 @@ export declare class Ninetailed implements NinetailedInstance {
|
|
|
37
46
|
readonly plugins: NinetailedPlugin[];
|
|
38
47
|
readonly logger: Logger;
|
|
39
48
|
private readonly componentViewTrackingThreshold;
|
|
40
|
-
constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, profile, locale, requestTimeout, onLog, onError, buildClientContext, componentViewTrackingThreshold, }?: Options);
|
|
49
|
+
constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, profile, locale, requestTimeout, onLog, onError, buildClientContext, componentViewTrackingThreshold, storage, }?: Options);
|
|
41
50
|
page: (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
42
51
|
track: (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
43
52
|
/**
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js",
|
|
3
|
-
"version": "6.4.0-beta.
|
|
3
|
+
"version": "6.4.0-beta.5",
|
|
4
4
|
"module": "./index.js",
|
|
5
5
|
"main": "./index.cjs",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@ninetailed/experience.js-shared": "6.4.0-beta.
|
|
9
|
+
"@ninetailed/experience.js-shared": "6.4.0-beta.5",
|
|
10
10
|
"analytics": "0.8.1",
|
|
11
11
|
"zod": "3.21.4"
|
|
12
12
|
},
|