@ninetailed/experience.js 7.5.0-beta.1 → 7.5.0-beta.3
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
CHANGED
|
@@ -194,7 +194,7 @@ const ninetailedCorePlugin = ({
|
|
|
194
194
|
config: {},
|
|
195
195
|
initialize: ({
|
|
196
196
|
instance
|
|
197
|
-
}) => {
|
|
197
|
+
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
198
198
|
_instance = instance;
|
|
199
199
|
if (instance.storage.getItem(DEBUG_FLAG)) {
|
|
200
200
|
experience_jsShared.logger.addSink(new experience_jsShared.ConsoleLogSink());
|
|
@@ -208,7 +208,7 @@ const ninetailedCorePlugin = ({
|
|
|
208
208
|
instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
209
209
|
}
|
|
210
210
|
if (typeof onInitProfileId === 'function') {
|
|
211
|
-
const profileId = onInitProfileId(instance.storage.getItem(ANONYMOUS_ID));
|
|
211
|
+
const profileId = yield onInitProfileId(instance.storage.getItem(ANONYMOUS_ID));
|
|
212
212
|
if (typeof profileId === 'string') {
|
|
213
213
|
instance.storage.setItem(ANONYMOUS_ID, profileId);
|
|
214
214
|
}
|
|
@@ -219,7 +219,7 @@ const ninetailedCorePlugin = ({
|
|
|
219
219
|
enabledFeatures = payload.features || [];
|
|
220
220
|
});
|
|
221
221
|
experience_jsShared.logger.debug('Ninetailed Core plugin initialized.');
|
|
222
|
-
},
|
|
222
|
+
}),
|
|
223
223
|
flush: asyncThrottle(flush),
|
|
224
224
|
pageStart: params => {
|
|
225
225
|
return abortNonClientEvents(params);
|
|
@@ -292,6 +292,12 @@ const ninetailedCorePlugin = ({
|
|
|
292
292
|
instance.storage.removeItem(PROFILE_FALLBACK_CACHE);
|
|
293
293
|
instance.storage.removeItem(EXPERIENCES_FALLBACK_CACHE);
|
|
294
294
|
experience_jsShared.logger.debug('Removed old profile data from localstorage.');
|
|
295
|
+
if (typeof onInitProfileId === 'function') {
|
|
296
|
+
const profileId = yield onInitProfileId(undefined);
|
|
297
|
+
if (typeof profileId === 'string') {
|
|
298
|
+
instance.storage.setItem(ANONYMOUS_ID, profileId);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
295
301
|
yield ninetailed.track('nt_reset');
|
|
296
302
|
experience_jsShared.logger.info('Profile reset successful.');
|
|
297
303
|
yield delay(10);
|
package/index.js
CHANGED
|
@@ -187,7 +187,7 @@ const ninetailedCorePlugin = ({
|
|
|
187
187
|
config: {},
|
|
188
188
|
initialize: ({
|
|
189
189
|
instance
|
|
190
|
-
}) => {
|
|
190
|
+
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
191
|
_instance = instance;
|
|
192
192
|
if (instance.storage.getItem(DEBUG_FLAG)) {
|
|
193
193
|
logger.addSink(new ConsoleLogSink());
|
|
@@ -201,7 +201,7 @@ const ninetailedCorePlugin = ({
|
|
|
201
201
|
instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
202
202
|
}
|
|
203
203
|
if (typeof onInitProfileId === 'function') {
|
|
204
|
-
const profileId = onInitProfileId(instance.storage.getItem(ANONYMOUS_ID));
|
|
204
|
+
const profileId = yield onInitProfileId(instance.storage.getItem(ANONYMOUS_ID));
|
|
205
205
|
if (typeof profileId === 'string') {
|
|
206
206
|
instance.storage.setItem(ANONYMOUS_ID, profileId);
|
|
207
207
|
}
|
|
@@ -212,7 +212,7 @@ const ninetailedCorePlugin = ({
|
|
|
212
212
|
enabledFeatures = payload.features || [];
|
|
213
213
|
});
|
|
214
214
|
logger.debug('Ninetailed Core plugin initialized.');
|
|
215
|
-
},
|
|
215
|
+
}),
|
|
216
216
|
flush: asyncThrottle(flush),
|
|
217
217
|
pageStart: params => {
|
|
218
218
|
return abortNonClientEvents(params);
|
|
@@ -285,6 +285,12 @@ const ninetailedCorePlugin = ({
|
|
|
285
285
|
instance.storage.removeItem(PROFILE_FALLBACK_CACHE);
|
|
286
286
|
instance.storage.removeItem(EXPERIENCES_FALLBACK_CACHE);
|
|
287
287
|
logger.debug('Removed old profile data from localstorage.');
|
|
288
|
+
if (typeof onInitProfileId === 'function') {
|
|
289
|
+
const profileId = yield onInitProfileId(undefined);
|
|
290
|
+
if (typeof profileId === 'string') {
|
|
291
|
+
instance.storage.setItem(ANONYMOUS_ID, profileId);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
288
294
|
yield ninetailed.track('nt_reset');
|
|
289
295
|
logger.info('Profile reset successful.');
|
|
290
296
|
yield delay(10);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js",
|
|
3
|
-
"version": "7.5.0-beta.
|
|
3
|
+
"version": "7.5.0-beta.3",
|
|
4
4
|
"license": "BSL-1.1",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "./src/index.d.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@ninetailed/experience.js-shared": "7.5.0-beta.
|
|
10
|
+
"@ninetailed/experience.js-shared": "7.5.0-beta.3",
|
|
11
11
|
"analytics": "0.8.1",
|
|
12
12
|
"zod": "3.21.4"
|
|
13
13
|
},
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Locale, NinetailedApiClient, NinetailedRequestContext } from '@ninetailed/experience.js-shared';
|
|
2
2
|
import { NinetailedInstance, FlushResult, NinetailedPlugin } from '../types';
|
|
3
|
+
export type OnInitProfileId = (profileId?: string) => Promise<string | undefined> | string | undefined;
|
|
3
4
|
type AnalyticsPluginNinetailedConfig = {
|
|
4
5
|
apiClient: NinetailedApiClient;
|
|
5
6
|
locale?: Locale;
|
|
6
7
|
requestTimeout?: number;
|
|
7
|
-
onInitProfileId?:
|
|
8
|
+
onInitProfileId?: OnInitProfileId;
|
|
8
9
|
buildClientContext?: () => NinetailedRequestContext;
|
|
9
10
|
ninetailed: NinetailedInstance;
|
|
10
11
|
};
|