@ninetailed/experience.js 6.4.0-beta.7 → 6.4.0-beta.8
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 +15 -16
- package/index.js +15 -16
- package/lib/Ninetailed.d.ts +3 -3
- 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 =
|
|
2624
|
+
const anonymousId = _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
|
-
|
|
2633
|
-
|
|
2632
|
+
_instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2633
|
+
_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 =
|
|
2645
|
+
const fallbackProfile = _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
|
+
}) => {
|
|
2687
2687
|
_instance = instance;
|
|
2688
|
-
if (
|
|
2688
|
+
if (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 =
|
|
2693
|
+
const legacyAnonymousId = 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
|
-
|
|
2697
|
-
|
|
2696
|
+
instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
|
|
2697
|
+
instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
2698
2698
|
}
|
|
2699
2699
|
if (profile) {
|
|
2700
|
-
|
|
2700
|
+
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,10 +2775,9 @@ const ninetailedPlugin = ({
|
|
|
2775
2775
|
instance.dispatch({
|
|
2776
2776
|
type: PROFILE_RESET
|
|
2777
2777
|
});
|
|
2778
|
-
|
|
2779
|
-
|
|
2778
|
+
instance.storage.removeItem(ANONYMOUS_ID);
|
|
2779
|
+
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.
|
|
2782
2781
|
yield ninetailed.track('nt_reset');
|
|
2783
2782
|
experience_jsShared.logger.info('Profile reset successful.');
|
|
2784
2783
|
yield delay(10);
|
|
@@ -2788,11 +2787,11 @@ const ninetailedPlugin = ({
|
|
|
2788
2787
|
const instance = args[args.length - 1];
|
|
2789
2788
|
const consoleLogSink = new experience_jsShared.ConsoleLogSink();
|
|
2790
2789
|
if (enabled) {
|
|
2791
|
-
|
|
2790
|
+
instance.storage.setItem(DEBUG_FLAG, true);
|
|
2792
2791
|
experience_jsShared.logger.addSink(consoleLogSink);
|
|
2793
2792
|
experience_jsShared.logger.info('Debug mode enabled.');
|
|
2794
2793
|
} else {
|
|
2795
|
-
|
|
2794
|
+
instance.storage.removeItem(DEBUG_FLAG);
|
|
2796
2795
|
experience_jsShared.logger.info('Debug mode disabled.');
|
|
2797
2796
|
experience_jsShared.logger.removeSink(consoleLogSink.name);
|
|
2798
2797
|
}
|
package/index.js
CHANGED
|
@@ -2614,7 +2614,7 @@ const ninetailedPlugin = ({
|
|
|
2614
2614
|
};
|
|
2615
2615
|
}
|
|
2616
2616
|
try {
|
|
2617
|
-
const anonymousId =
|
|
2617
|
+
const anonymousId = _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
|
-
|
|
2626
|
-
|
|
2625
|
+
_instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2626
|
+
_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 =
|
|
2638
|
+
const fallbackProfile = _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
|
+
}) => {
|
|
2680
2680
|
_instance = instance;
|
|
2681
|
-
if (
|
|
2681
|
+
if (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 =
|
|
2686
|
+
const legacyAnonymousId = instance.storage.getItem(LEGACY_ANONYMOUS_ID);
|
|
2687
2687
|
if (legacyAnonymousId) {
|
|
2688
2688
|
logger.debug('Found legacy anonymousId, migrating to new one.', legacyAnonymousId);
|
|
2689
|
-
|
|
2690
|
-
|
|
2689
|
+
instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
|
|
2690
|
+
instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
2691
2691
|
}
|
|
2692
2692
|
if (profile) {
|
|
2693
|
-
|
|
2693
|
+
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,10 +2768,9 @@ const ninetailedPlugin = ({
|
|
|
2768
2768
|
instance.dispatch({
|
|
2769
2769
|
type: PROFILE_RESET
|
|
2770
2770
|
});
|
|
2771
|
-
|
|
2772
|
-
|
|
2771
|
+
instance.storage.removeItem(ANONYMOUS_ID);
|
|
2772
|
+
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.
|
|
2775
2774
|
yield ninetailed.track('nt_reset');
|
|
2776
2775
|
logger.info('Profile reset successful.');
|
|
2777
2776
|
yield delay(10);
|
|
@@ -2781,11 +2780,11 @@ const ninetailedPlugin = ({
|
|
|
2781
2780
|
const instance = args[args.length - 1];
|
|
2782
2781
|
const consoleLogSink = new ConsoleLogSink();
|
|
2783
2782
|
if (enabled) {
|
|
2784
|
-
|
|
2783
|
+
instance.storage.setItem(DEBUG_FLAG, true);
|
|
2785
2784
|
logger.addSink(consoleLogSink);
|
|
2786
2785
|
logger.info('Debug mode enabled.');
|
|
2787
2786
|
} else {
|
|
2788
|
-
|
|
2787
|
+
instance.storage.removeItem(DEBUG_FLAG);
|
|
2789
2788
|
logger.info('Debug mode disabled.');
|
|
2790
2789
|
logger.removeSink(consoleLogSink.name);
|
|
2791
2790
|
}
|
package/lib/Ninetailed.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ declare global {
|
|
|
12
12
|
} & unknown;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
type GetItem<T = any> = (key: string) =>
|
|
16
|
-
type SetItem = (key: string, value:
|
|
17
|
-
type RemoveItem = (key: string) =>
|
|
15
|
+
type GetItem<T = any> = (key: string) => T;
|
|
16
|
+
type SetItem<T = any> = (key: string, value: T) => void;
|
|
17
|
+
type RemoveItem = (key: string) => void;
|
|
18
18
|
export type Storage = {
|
|
19
19
|
getItem: GetItem;
|
|
20
20
|
setItem: SetItem;
|
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.8",
|
|
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.8",
|
|
10
10
|
"analytics": "0.8.1",
|
|
11
11
|
"zod": "3.21.4"
|
|
12
12
|
},
|