@ninetailed/experience.js 6.4.0-beta.9 → 6.4.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/index.cjs +7 -14
- package/index.js +7 -14
- package/lib/Ninetailed.d.ts +2 -12
- package/lib/analytics/get-analytics-plugin.d.ts +2 -3
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -2604,13 +2604,11 @@ const ninetailedPlugin = ({
|
|
|
2604
2604
|
apiClient,
|
|
2605
2605
|
profile,
|
|
2606
2606
|
locale,
|
|
2607
|
-
ninetailed
|
|
2608
|
-
buildClientContext
|
|
2607
|
+
ninetailed
|
|
2609
2608
|
}) => {
|
|
2610
2609
|
let _instance;
|
|
2611
2610
|
let queue = [];
|
|
2612
2611
|
let enabledFeatures = Object.values(experience_jsShared.FEATURES);
|
|
2613
|
-
const buildContext = buildClientContext || buildClientNinetailedRequestContext;
|
|
2614
2612
|
const flush = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2615
2613
|
const events = Object.assign([], queue);
|
|
2616
2614
|
experience_jsShared.logger.info('Start flushing events.');
|
|
@@ -2714,7 +2712,7 @@ const ninetailedPlugin = ({
|
|
|
2714
2712
|
payload
|
|
2715
2713
|
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2716
2714
|
experience_jsShared.logger.info('Sending Page event.');
|
|
2717
|
-
const ctx =
|
|
2715
|
+
const ctx = buildClientNinetailedRequestContext();
|
|
2718
2716
|
return enqueueEvent(experience_jsShared.buildPageEvent({
|
|
2719
2717
|
messageId: payload.meta.rid,
|
|
2720
2718
|
timestamp: payload.meta.ts,
|
|
@@ -2729,7 +2727,7 @@ const ninetailedPlugin = ({
|
|
|
2729
2727
|
payload
|
|
2730
2728
|
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2731
2729
|
experience_jsShared.logger.info('Sending Track event.');
|
|
2732
|
-
const ctx =
|
|
2730
|
+
const ctx = buildClientNinetailedRequestContext();
|
|
2733
2731
|
return enqueueEvent(experience_jsShared.buildTrackEvent({
|
|
2734
2732
|
messageId: payload.meta.rid,
|
|
2735
2733
|
timestamp: payload.meta.ts,
|
|
@@ -2745,7 +2743,7 @@ const ninetailedPlugin = ({
|
|
|
2745
2743
|
payload
|
|
2746
2744
|
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2747
2745
|
experience_jsShared.logger.info('Sending Identify event.');
|
|
2748
|
-
const ctx =
|
|
2746
|
+
const ctx = buildClientNinetailedRequestContext();
|
|
2749
2747
|
if (payload.userId === EMPTY_MERGE_ID && (!payload.traits || typeof payload.traits === 'object' && Object.keys(payload.traits).length === 0)) {
|
|
2750
2748
|
experience_jsShared.logger.info('Skipping Identify event as no userId and no traits are set.');
|
|
2751
2749
|
return;
|
|
@@ -3363,9 +3361,7 @@ class Ninetailed {
|
|
|
3363
3361
|
requestTimeout,
|
|
3364
3362
|
onLog,
|
|
3365
3363
|
onError,
|
|
3366
|
-
|
|
3367
|
-
componentViewTrackingThreshold = 2000,
|
|
3368
|
-
storageImpl
|
|
3364
|
+
componentViewTrackingThreshold = 2000
|
|
3369
3365
|
} = {}) {
|
|
3370
3366
|
this.isInitialized = false;
|
|
3371
3367
|
this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3570,15 +3566,12 @@ class Ninetailed {
|
|
|
3570
3566
|
profile,
|
|
3571
3567
|
locale,
|
|
3572
3568
|
requestTimeout,
|
|
3573
|
-
buildClientContext,
|
|
3574
3569
|
ninetailed: this
|
|
3575
3570
|
});
|
|
3576
|
-
this.instance = Analytics__default["default"](
|
|
3571
|
+
this.instance = Analytics__default["default"]({
|
|
3577
3572
|
app: 'ninetailed',
|
|
3578
3573
|
plugins: [...this.plugins, this.eventQueue]
|
|
3579
|
-
}
|
|
3580
|
-
storage: storageImpl
|
|
3581
|
-
} : {}));
|
|
3574
|
+
});
|
|
3582
3575
|
const detachOnReadyListener = this.instance.on('ready', () => {
|
|
3583
3576
|
this.isInitialized = true;
|
|
3584
3577
|
experience_jsShared.logger.info('Ninetailed Experience.js SDK is completely initialized.');
|
package/index.js
CHANGED
|
@@ -2597,13 +2597,11 @@ const ninetailedPlugin = ({
|
|
|
2597
2597
|
apiClient,
|
|
2598
2598
|
profile,
|
|
2599
2599
|
locale,
|
|
2600
|
-
ninetailed
|
|
2601
|
-
buildClientContext
|
|
2600
|
+
ninetailed
|
|
2602
2601
|
}) => {
|
|
2603
2602
|
let _instance;
|
|
2604
2603
|
let queue = [];
|
|
2605
2604
|
let enabledFeatures = Object.values(FEATURES);
|
|
2606
|
-
const buildContext = buildClientContext || buildClientNinetailedRequestContext;
|
|
2607
2605
|
const flush = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2608
2606
|
const events = Object.assign([], queue);
|
|
2609
2607
|
logger.info('Start flushing events.');
|
|
@@ -2707,7 +2705,7 @@ const ninetailedPlugin = ({
|
|
|
2707
2705
|
payload
|
|
2708
2706
|
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2709
2707
|
logger.info('Sending Page event.');
|
|
2710
|
-
const ctx =
|
|
2708
|
+
const ctx = buildClientNinetailedRequestContext();
|
|
2711
2709
|
return enqueueEvent(buildPageEvent({
|
|
2712
2710
|
messageId: payload.meta.rid,
|
|
2713
2711
|
timestamp: payload.meta.ts,
|
|
@@ -2722,7 +2720,7 @@ const ninetailedPlugin = ({
|
|
|
2722
2720
|
payload
|
|
2723
2721
|
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2724
2722
|
logger.info('Sending Track event.');
|
|
2725
|
-
const ctx =
|
|
2723
|
+
const ctx = buildClientNinetailedRequestContext();
|
|
2726
2724
|
return enqueueEvent(buildTrackEvent({
|
|
2727
2725
|
messageId: payload.meta.rid,
|
|
2728
2726
|
timestamp: payload.meta.ts,
|
|
@@ -2738,7 +2736,7 @@ const ninetailedPlugin = ({
|
|
|
2738
2736
|
payload
|
|
2739
2737
|
}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2740
2738
|
logger.info('Sending Identify event.');
|
|
2741
|
-
const ctx =
|
|
2739
|
+
const ctx = buildClientNinetailedRequestContext();
|
|
2742
2740
|
if (payload.userId === EMPTY_MERGE_ID && (!payload.traits || typeof payload.traits === 'object' && Object.keys(payload.traits).length === 0)) {
|
|
2743
2741
|
logger.info('Skipping Identify event as no userId and no traits are set.');
|
|
2744
2742
|
return;
|
|
@@ -3356,9 +3354,7 @@ class Ninetailed {
|
|
|
3356
3354
|
requestTimeout,
|
|
3357
3355
|
onLog,
|
|
3358
3356
|
onError,
|
|
3359
|
-
|
|
3360
|
-
componentViewTrackingThreshold = 2000,
|
|
3361
|
-
storageImpl
|
|
3357
|
+
componentViewTrackingThreshold = 2000
|
|
3362
3358
|
} = {}) {
|
|
3363
3359
|
this.isInitialized = false;
|
|
3364
3360
|
this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3563,15 +3559,12 @@ class Ninetailed {
|
|
|
3563
3559
|
profile,
|
|
3564
3560
|
locale,
|
|
3565
3561
|
requestTimeout,
|
|
3566
|
-
buildClientContext,
|
|
3567
3562
|
ninetailed: this
|
|
3568
3563
|
});
|
|
3569
|
-
this.instance = Analytics(
|
|
3564
|
+
this.instance = Analytics({
|
|
3570
3565
|
app: 'ninetailed',
|
|
3571
3566
|
plugins: [...this.plugins, this.eventQueue]
|
|
3572
|
-
}
|
|
3573
|
-
storage: storageImpl
|
|
3574
|
-
} : {}));
|
|
3567
|
+
});
|
|
3575
3568
|
const detachOnReadyListener = this.instance.on('ready', () => {
|
|
3576
3569
|
this.isInitialized = true;
|
|
3577
3570
|
logger.info('Ninetailed Experience.js SDK is completely initialized.');
|
package/lib/Ninetailed.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="analytics" />
|
|
2
|
-
import { Locale, Traits, Profile, OnLogHandler, OnErrorHandler, Logger, PageviewProperties, Properties, NinetailedApiClient, NinetailedApiClientOptions
|
|
2
|
+
import { Locale, Traits, Profile, OnLogHandler, OnErrorHandler, Logger, PageviewProperties, Properties, NinetailedApiClient, NinetailedApiClientOptions } from '@ninetailed/experience.js-shared';
|
|
3
3
|
import { EventFunctionOptions, NinetailedInstance, NinetailedPlugin, OnIsInitializedCallback, OnProfileChangeCallback, ProfileState, TrackHasSeenComponent, ElementSeenPayload, TrackComponentView } from './types';
|
|
4
4
|
import { ObserveOptions } from './ElementSeenObserver';
|
|
5
5
|
declare global {
|
|
@@ -12,14 +12,6 @@ declare global {
|
|
|
12
12
|
} & unknown;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
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
|
-
export type Storage = {
|
|
19
|
-
getItem: GetItem;
|
|
20
|
-
setItem: SetItem;
|
|
21
|
-
removeItem: RemoveItem;
|
|
22
|
-
};
|
|
23
15
|
type Options = {
|
|
24
16
|
url?: string;
|
|
25
17
|
locale?: Locale;
|
|
@@ -29,8 +21,6 @@ type Options = {
|
|
|
29
21
|
onLog?: OnLogHandler;
|
|
30
22
|
onError?: OnErrorHandler;
|
|
31
23
|
componentViewTrackingThreshold?: number;
|
|
32
|
-
buildClientContext?: () => NinetailedRequestContext;
|
|
33
|
-
storageImpl?: Storage;
|
|
34
24
|
};
|
|
35
25
|
type NinetailedApiClientInstanceOrOptions = NinetailedApiClient | NinetailedApiClientOptions;
|
|
36
26
|
export declare class Ninetailed implements NinetailedInstance {
|
|
@@ -46,7 +36,7 @@ export declare class Ninetailed implements NinetailedInstance {
|
|
|
46
36
|
readonly plugins: NinetailedPlugin[];
|
|
47
37
|
readonly logger: Logger;
|
|
48
38
|
private readonly componentViewTrackingThreshold;
|
|
49
|
-
constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, profile, locale, requestTimeout, onLog, onError,
|
|
39
|
+
constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, profile, locale, requestTimeout, onLog, onError, componentViewTrackingThreshold, }?: Options);
|
|
50
40
|
page: (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
51
41
|
track: (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
52
42
|
/**
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { AnalyticsPlugin } from 'analytics';
|
|
2
|
-
import { Profile, Locale, NinetailedApiClient
|
|
2
|
+
import { Profile, Locale, NinetailedApiClient } from '@ninetailed/experience.js-shared';
|
|
3
3
|
import { NinetailedInstance, FlushResult } from '../types';
|
|
4
4
|
type AnalyticsPluginNinetailedConfig = {
|
|
5
5
|
apiClient: NinetailedApiClient;
|
|
6
6
|
profile?: Profile;
|
|
7
7
|
locale?: Locale;
|
|
8
8
|
requestTimeout?: number;
|
|
9
|
-
buildClientContext?: () => NinetailedRequestContext;
|
|
10
9
|
ninetailed: NinetailedInstance;
|
|
11
10
|
};
|
|
12
11
|
export declare const PLUGIN_NAME = "ninetailed";
|
|
13
12
|
export interface NinetailedEventQueue extends AnalyticsPlugin {
|
|
14
13
|
flush: () => Promise<FlushResult>;
|
|
15
14
|
}
|
|
16
|
-
export declare const ninetailedPlugin: ({ apiClient, profile, locale, ninetailed,
|
|
15
|
+
export declare const ninetailedPlugin: ({ apiClient, profile, locale, ninetailed, }: AnalyticsPluginNinetailedConfig) => NinetailedEventQueue;
|
|
17
16
|
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js",
|
|
3
|
-
"version": "6.4.0
|
|
3
|
+
"version": "6.4.0",
|
|
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
|
|
9
|
+
"@ninetailed/experience.js-shared": "6.4.0",
|
|
10
10
|
"analytics": "0.8.1",
|
|
11
11
|
"zod": "3.21.4"
|
|
12
12
|
},
|