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