@ninetailed/experience.js 7.5.3 → 7.6.0-beta.2
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.d.ts +1 -0
- package/{index.cjs → index.cjs.js} +697 -375
- package/index.esm.js +1203 -0
- package/package.json +6 -9
- package/src/index.d.ts +1 -1
- package/src/lib/ElementSeenObserver.d.ts +1 -1
- package/src/lib/Ninetailed.d.ts +19 -5
- package/src/lib/NinetailedCorePlugin/NinetailedCorePlugin.d.ts +69 -0
- package/src/lib/{ninetailedCorePlugin → NinetailedCorePlugin}/index.d.ts +1 -1
- package/src/lib/constants.d.ts +1 -2
- package/src/lib/experience/makeExperienceSelectMiddleware.d.ts +9 -9
- package/src/lib/guards/hasComponentViewTrackingThreshold.d.ts +3 -0
- package/src/lib/guards/hasExperienceSelectionMiddleware.d.ts +1 -1
- package/src/lib/plugins/selectPluginsHavingExperienceSelectionMiddleware.d.ts +2 -2
- package/src/lib/plugins/selectPluginsHavingOnChangeEmitter.d.ts +1 -1
- package/src/lib/types/OnSelectVariant.d.ts +51 -0
- package/src/lib/types/index.d.ts +9 -9
- package/src/lib/types/interfaces/HasComponentViewTrackingThreshold.d.ts +3 -0
- package/src/lib/types/interfaces/HasExperienceSelectionMiddleware.d.ts +10 -10
- package/src/lib/types/interfaces/InterestedInHiddenPage.d.ts +1 -1
- package/src/lib/types/interfaces/InterestedInProfileChange.d.ts +1 -1
- package/src/lib/types/interfaces/InterestedInSeenElements.d.ts +1 -3
- package/src/lib/utils/EventBuilder.d.ts +221 -0
- package/src/lib/utils/noop.d.ts +1 -0
- package/index.js +0 -886
- package/src/lib/ninetailedCorePlugin/ninetailedCorePlugin.d.ts +0 -17
- package/src/lib/test-helpers/intersection-observer-test-helper.d.ts +0 -2
- package/src/lib/types/ElementSeenPayload.d.ts +0 -82
- package/src/lib/types/EventHandler.d.ts +0 -6
- package/src/lib/types/NinetailedPlugin.d.ts +0 -11
- package/src/lib/types/TrackingProperties.d.ts +0 -35
- /package/src/lib/{ninetailedCorePlugin → NinetailedCorePlugin}/Events/build-context.d.ts +0 -0
- /package/src/lib/{ninetailedCorePlugin → NinetailedCorePlugin}/Events/build-locale.d.ts +0 -0
- /package/src/lib/{ninetailedCorePlugin → NinetailedCorePlugin}/Events/index.d.ts +0 -0
- /package/src/lib/{ninetailedCorePlugin → NinetailedCorePlugin}/constants.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0-beta.2",
|
|
4
4
|
"description": "Ninetailed SDK for javascript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -8,15 +8,12 @@
|
|
|
8
8
|
"url": "https://github.com/ninetailed-inc/experience.js.git",
|
|
9
9
|
"directory": "packages/sdks/javascript"
|
|
10
10
|
},
|
|
11
|
-
"module": "./index.js",
|
|
12
|
-
"main": "./index.cjs",
|
|
13
|
-
"type": "module",
|
|
14
|
-
"types": "./src/index.d.ts",
|
|
15
11
|
"dependencies": {
|
|
16
|
-
"@jest/globals": "27.5.1",
|
|
17
|
-
"@ninetailed/experience.js-shared": "7.5.3",
|
|
18
12
|
"analytics": "0.8.1",
|
|
19
|
-
"
|
|
13
|
+
"@ninetailed/experience.js-plugin-analytics": "*",
|
|
14
|
+
"@ninetailed/experience.js-shared": "*",
|
|
15
|
+
"uuid": "9.0.0"
|
|
20
16
|
},
|
|
21
|
-
"
|
|
17
|
+
"module": "./index.esm.js",
|
|
18
|
+
"main": "./index.cjs.js"
|
|
22
19
|
}
|
package/src/index.d.ts
CHANGED
package/src/lib/Ninetailed.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/// <reference types="analytics" />
|
|
2
|
-
import { Locale, Traits, OnLogHandler, OnErrorHandler, Logger, PageviewProperties, Properties, NinetailedApiClient, NinetailedApiClientOptions, NinetailedRequestContext } from '@ninetailed/experience.js-shared';
|
|
3
|
-
import { OnInitProfileId } from './
|
|
4
|
-
import { EventFunctionOptions, NinetailedInstance,
|
|
2
|
+
import { Locale, Traits, OnLogHandler, OnErrorHandler, Logger, PageviewProperties, Properties, NinetailedApiClient, NinetailedApiClientOptions, NinetailedRequestContext, Reference, Event } from '@ninetailed/experience.js-shared';
|
|
3
|
+
import { OnInitProfileId } from './NinetailedCorePlugin';
|
|
4
|
+
import { EventFunctionOptions, NinetailedInstance, OnIsInitializedCallback, OnProfileChangeCallback, ProfileState, TrackHasSeenComponent, TrackComponentView } from './types';
|
|
5
5
|
import { ObserveOptions } from './ElementSeenObserver';
|
|
6
|
+
import { OnSelectVariantArgs, OnSelectVariantCallback } from './types/OnSelectVariant';
|
|
7
|
+
import { ElementSeenPayload, NinetailedPlugin } from '@ninetailed/experience.js-plugin-analytics';
|
|
8
|
+
import { EventBuilder } from './utils/EventBuilder';
|
|
6
9
|
declare global {
|
|
7
10
|
interface Window {
|
|
8
11
|
ninetailed?: {
|
|
@@ -32,6 +35,7 @@ type Options = {
|
|
|
32
35
|
onInitProfileId?: OnInitProfileId;
|
|
33
36
|
buildClientContext?: () => NinetailedRequestContext;
|
|
34
37
|
storageImpl?: Storage;
|
|
38
|
+
useClientSideEvaluation?: boolean;
|
|
35
39
|
};
|
|
36
40
|
type NinetailedApiClientInstanceOrOptions = NinetailedApiClient | NinetailedApiClientOptions;
|
|
37
41
|
export declare class Ninetailed implements NinetailedInstance {
|
|
@@ -47,22 +51,32 @@ export declare class Ninetailed implements NinetailedInstance {
|
|
|
47
51
|
readonly plugins: NinetailedPlugin[];
|
|
48
52
|
readonly logger: Logger;
|
|
49
53
|
private readonly componentViewTrackingThreshold;
|
|
50
|
-
|
|
54
|
+
private readonly useClientSideEvaluation;
|
|
55
|
+
readonly eventBuilder: EventBuilder;
|
|
56
|
+
constructor(ninetailedApiClientInstanceOrOptions: NinetailedApiClientInstanceOrOptions, { plugins, url, locale, requestTimeout, onLog, onError, buildClientContext, onInitProfileId, componentViewTrackingThreshold, storageImpl, useClientSideEvaluation, }?: Options);
|
|
51
57
|
page: (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
52
58
|
track: (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
59
|
+
identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
60
|
+
batch: (events: Event[]) => Promise<import("./types").FlushResult>;
|
|
61
|
+
trackStickyComponentView: ({ experienceId, componentId, variantIndex, }: {
|
|
62
|
+
experienceId: string;
|
|
63
|
+
componentId: string;
|
|
64
|
+
variantIndex: number;
|
|
65
|
+
}) => Promise<import("./types").FlushResult>;
|
|
53
66
|
/**
|
|
54
67
|
* @deprecated The legacy datamodel is not recommended anymore
|
|
55
68
|
* Will be removed in the next version of the SDK
|
|
56
69
|
*/
|
|
57
70
|
trackHasSeenComponent: TrackHasSeenComponent;
|
|
58
71
|
trackComponentView: TrackComponentView;
|
|
72
|
+
private get pluginsWithCustomComponentViewThreshold();
|
|
59
73
|
observeElement: (payload: ElementSeenPayload, options?: ObserveOptions) => void;
|
|
60
74
|
unobserveElement: (element: Element) => void;
|
|
61
75
|
private onElementSeen;
|
|
62
|
-
identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
|
|
63
76
|
reset: () => Promise<void>;
|
|
64
77
|
debug: (enabled: boolean) => Promise<void>;
|
|
65
78
|
onProfileChange: (cb: OnProfileChangeCallback) => import("analytics").DetachListeners;
|
|
79
|
+
onSelectVariant: <Baseline extends Reference, Variant extends Reference>({ baseline, experiences }: OnSelectVariantArgs<Baseline, Variant>, cb: OnSelectVariantCallback<Baseline, Variant>) => () => void;
|
|
66
80
|
onIsInitialized: (onIsInitialized: OnIsInitializedCallback) => void;
|
|
67
81
|
private waitUntilInitialized;
|
|
68
82
|
get profileState(): ProfileState;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AnalyticsInstance } from 'analytics';
|
|
2
|
+
import { Locale, NinetailedApiClient, NinetailedRequestContext } from '@ninetailed/experience.js-shared';
|
|
3
|
+
import { NinetailedAnalyticsPlugin, NinetailedPlugin, SanitizedElementSeenPayload } from '@ninetailed/experience.js-plugin-analytics';
|
|
4
|
+
import { NinetailedInstance, FlushResult } from '../types';
|
|
5
|
+
import { HAS_SEEN_STICKY_COMPONENT } from '../constants';
|
|
6
|
+
import { HasComponentViewTrackingThreshold } from '../types/interfaces/HasComponentViewTrackingThreshold';
|
|
7
|
+
export type OnInitProfileId = (profileId?: string) => Promise<string | undefined> | string | undefined;
|
|
8
|
+
type AnalyticsPluginNinetailedConfig = {
|
|
9
|
+
apiClient: NinetailedApiClient;
|
|
10
|
+
locale?: Locale;
|
|
11
|
+
requestTimeout?: number;
|
|
12
|
+
onInitProfileId?: OnInitProfileId;
|
|
13
|
+
buildClientContext?: () => NinetailedRequestContext;
|
|
14
|
+
ninetailed: NinetailedInstance;
|
|
15
|
+
};
|
|
16
|
+
export declare const PLUGIN_NAME = "ninetailed:core";
|
|
17
|
+
type EventFn = {
|
|
18
|
+
payload: any;
|
|
19
|
+
instance: InternalAnalyticsInstance;
|
|
20
|
+
};
|
|
21
|
+
type AbortableFnParams = {
|
|
22
|
+
abort: () => void;
|
|
23
|
+
payload: unknown;
|
|
24
|
+
};
|
|
25
|
+
type InternalAnalyticsInstance = AnalyticsInstance & {
|
|
26
|
+
dispatch: (action: any) => void;
|
|
27
|
+
};
|
|
28
|
+
export interface NinetailedCorePlugin extends NinetailedPlugin {
|
|
29
|
+
flush: (args: void) => Promise<FlushResult>;
|
|
30
|
+
}
|
|
31
|
+
export declare class NinetailedCorePlugin extends NinetailedAnalyticsPlugin implements NinetailedCorePlugin, HasComponentViewTrackingThreshold {
|
|
32
|
+
name: string;
|
|
33
|
+
private _instance?;
|
|
34
|
+
private queue;
|
|
35
|
+
private enabledFeatures;
|
|
36
|
+
private readonly buildContext;
|
|
37
|
+
private readonly onInitProfileId?;
|
|
38
|
+
private readonly apiClient;
|
|
39
|
+
private readonly locale?;
|
|
40
|
+
private readonly ninetailed;
|
|
41
|
+
constructor({ apiClient, locale, ninetailed, onInitProfileId, buildClientContext, }: AnalyticsPluginNinetailedConfig);
|
|
42
|
+
initialize({ instance, }: {
|
|
43
|
+
instance: InternalAnalyticsInstance;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
pageStart(params: AbortableFnParams): unknown;
|
|
46
|
+
page({ payload }: EventFn): Promise<void>;
|
|
47
|
+
trackStart(params: AbortableFnParams): unknown;
|
|
48
|
+
track({ payload }: EventFn): Promise<void>;
|
|
49
|
+
identifyStart(params: AbortableFnParams): unknown;
|
|
50
|
+
identify({ payload }: EventFn): Promise<void>;
|
|
51
|
+
getComponentViewTrackingThreshold(): number;
|
|
52
|
+
protected onTrackExperience(properties: SanitizedElementSeenPayload): Promise<void>;
|
|
53
|
+
protected onTrackComponent(): Promise<void>;
|
|
54
|
+
[HAS_SEEN_STICKY_COMPONENT]: ({ payload }: EventFn) => Promise<void>;
|
|
55
|
+
setItemStart({ abort, payload }: {
|
|
56
|
+
abort: any;
|
|
57
|
+
payload: any;
|
|
58
|
+
}): any;
|
|
59
|
+
methods: {
|
|
60
|
+
reset: (...args: any[]) => Promise<void>;
|
|
61
|
+
debug: (...args: any[]) => Promise<void>;
|
|
62
|
+
};
|
|
63
|
+
private enqueueEvent;
|
|
64
|
+
private abortNonClientEvents;
|
|
65
|
+
private get instance();
|
|
66
|
+
flush: (args: void) => Promise<FlushResult>;
|
|
67
|
+
private _flush;
|
|
68
|
+
}
|
|
69
|
+
export {};
|
package/src/lib/constants.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export declare const HAS_SEEN_COMPONENT = "has_seen_component";
|
|
2
|
-
export declare const HAS_SEEN_ELEMENT = "has_seen_element";
|
|
3
1
|
export declare const COMPONENT = "component";
|
|
4
2
|
export declare const COMPONENT_START = "componentStart";
|
|
5
3
|
export declare const PAGE_HIDDEN = "page_hidden";
|
|
4
|
+
export declare const HAS_SEEN_STICKY_COMPONENT = "sticky_component_view";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { ExperienceConfiguration, Profile, Reference
|
|
2
|
-
import { NinetailedPlugin } from '
|
|
3
|
-
import {
|
|
4
|
-
type MakeExperienceSelectMiddlewareArg<Variant extends Reference> = {
|
|
1
|
+
import { ExperienceConfiguration, Profile, Reference } from '@ninetailed/experience.js-shared';
|
|
2
|
+
import { NinetailedPlugin } from '@ninetailed/experience.js-plugin-analytics';
|
|
3
|
+
import { ExperienceSelectionMiddleware, ExperienceSelectionMiddlewareArg } from '../types/interfaces/HasExperienceSelectionMiddleware';
|
|
4
|
+
type MakeExperienceSelectMiddlewareArg<Baseline extends Reference, Variant extends Reference> = {
|
|
5
5
|
plugins: NinetailedPlugin[];
|
|
6
6
|
experiences: ExperienceConfiguration<Variant>[];
|
|
7
7
|
baseline: Reference;
|
|
8
8
|
profile: Profile | null;
|
|
9
|
-
onChange: () => void;
|
|
9
|
+
onChange: (middleware: ExperienceSelectionMiddleware<Baseline, Variant>) => void;
|
|
10
10
|
};
|
|
11
|
-
export declare const makeExperienceSelectMiddleware: <
|
|
11
|
+
export declare const makeExperienceSelectMiddleware: <TBaseline extends Reference, TVariant extends Reference>({ plugins, onChange, experiences, baseline, profile, }: MakeExperienceSelectMiddlewareArg<TBaseline, TVariant>) => {
|
|
12
12
|
addListeners: () => void;
|
|
13
13
|
removeListeners: () => void;
|
|
14
|
-
middleware: ({ experience, variant, variantIndex, }:
|
|
15
|
-
experience: ExperienceConfiguration<
|
|
16
|
-
variant:
|
|
14
|
+
middleware: ({ experience, variant, variantIndex, }: ExperienceSelectionMiddlewareArg<TBaseline, TVariant>) => {
|
|
15
|
+
experience: ExperienceConfiguration<TVariant> | null;
|
|
16
|
+
variant: TBaseline | TVariant | import("@ninetailed/experience.js-shared").VariantRef;
|
|
17
17
|
variantIndex: number;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { NinetailedPlugin } from '@ninetailed/experience.js-plugin-analytics';
|
|
2
|
+
import type { HasComponentViewTrackingThreshold } from '../types/interfaces/HasComponentViewTrackingThreshold';
|
|
3
|
+
export declare const hasComponentViewTrackingThreshold: (arg: NinetailedPlugin) => arg is NinetailedPlugin & HasComponentViewTrackingThreshold;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Reference } from '@ninetailed/experience.js-shared';
|
|
2
2
|
import { HasExperienceSelectionMiddleware } from '../types/interfaces/HasExperienceSelectionMiddleware';
|
|
3
|
-
export declare const hasExperienceSelectionMiddleware: <
|
|
3
|
+
export declare const hasExperienceSelectionMiddleware: <TBaseline extends Reference, TVariant extends Reference>(arg: unknown) => arg is HasExperienceSelectionMiddleware<TBaseline, TVariant>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Reference } from '@ninetailed/experience.js-shared';
|
|
2
|
+
import { NinetailedPlugin } from '@ninetailed/experience.js-plugin-analytics';
|
|
2
3
|
import { HasExperienceSelectionMiddleware } from '../types/interfaces/HasExperienceSelectionMiddleware';
|
|
3
|
-
|
|
4
|
-
export declare const selectPluginsHavingExperienceSelectionMiddleware: <Variant extends Reference>(plugins: NinetailedPlugin[]) => HasExperienceSelectionMiddleware<Variant>[];
|
|
4
|
+
export declare const selectPluginsHavingExperienceSelectionMiddleware: <Baseline extends Reference, Variant extends Reference>(plugins: NinetailedPlugin[]) => HasExperienceSelectionMiddleware<Baseline, Variant>[];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NinetailedPlugin } from '
|
|
1
|
+
import { NinetailedPlugin } from '@ninetailed/experience.js-plugin-analytics';
|
|
2
2
|
import { HasOnChangeEmitter } from '../types/interfaces/HasOnChangeEmitter';
|
|
3
3
|
export declare const selectPluginsHavingOnChangeEmitter: (plugins: NinetailedPlugin[]) => HasOnChangeEmitter[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Profile, ExperienceConfiguration, Reference, VariantRef } from '@ninetailed/experience.js-shared';
|
|
2
|
+
import type { DetachListeners } from 'analytics';
|
|
3
|
+
type Loading<TBaseline extends Reference> = {
|
|
4
|
+
status: 'loading';
|
|
5
|
+
loading: boolean;
|
|
6
|
+
hasVariants: boolean;
|
|
7
|
+
baseline: TBaseline;
|
|
8
|
+
experience: null;
|
|
9
|
+
variant: TBaseline;
|
|
10
|
+
variantIndex: number;
|
|
11
|
+
audience: null;
|
|
12
|
+
isPersonalized: boolean;
|
|
13
|
+
profile: null;
|
|
14
|
+
error: null;
|
|
15
|
+
};
|
|
16
|
+
type Success<TBaseline extends Reference, TVariant extends Reference> = {
|
|
17
|
+
status: 'success';
|
|
18
|
+
loading: boolean;
|
|
19
|
+
hasVariants: boolean;
|
|
20
|
+
baseline: TBaseline;
|
|
21
|
+
experience: ExperienceConfiguration<TVariant> | null;
|
|
22
|
+
variant: TBaseline | TVariant | VariantRef;
|
|
23
|
+
variantIndex: number;
|
|
24
|
+
audience: {
|
|
25
|
+
id: string;
|
|
26
|
+
} | null;
|
|
27
|
+
isPersonalized: boolean;
|
|
28
|
+
profile: Profile;
|
|
29
|
+
error: null;
|
|
30
|
+
};
|
|
31
|
+
type Fail<TBaseline extends Reference> = {
|
|
32
|
+
status: 'error';
|
|
33
|
+
loading: boolean;
|
|
34
|
+
hasVariants: boolean;
|
|
35
|
+
baseline: TBaseline;
|
|
36
|
+
experience: null;
|
|
37
|
+
variant: TBaseline;
|
|
38
|
+
variantIndex: number;
|
|
39
|
+
audience: null;
|
|
40
|
+
isPersonalized: boolean;
|
|
41
|
+
profile: null;
|
|
42
|
+
error: Error;
|
|
43
|
+
};
|
|
44
|
+
export type OnSelectVariantArgs<TBaseline extends Reference, TVariant extends Reference> = {
|
|
45
|
+
baseline: TBaseline;
|
|
46
|
+
experiences: ExperienceConfiguration<TVariant>[];
|
|
47
|
+
};
|
|
48
|
+
export type OnSelectVariantCallbackArgs<TBaseline extends Reference, TVariant extends Reference> = Loading<TBaseline> | Success<TBaseline, TVariant> | Fail<TBaseline>;
|
|
49
|
+
export type OnSelectVariantCallback<TBaseline extends Reference, TVariant extends Reference> = (state: OnSelectVariantCallbackArgs<TBaseline, TVariant>) => void;
|
|
50
|
+
export type OnSelectVariant<TBaseline extends Reference = Reference, TVariant extends Reference = Reference> = (args: OnSelectVariantArgs<TBaseline, TVariant>, cb: OnSelectVariantCallback<TBaseline, TVariant>) => DetachListeners;
|
|
51
|
+
export {};
|
package/src/lib/types/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Logger, PageviewProperties, Profile, Properties, Traits, SelectedVariantInfo } from '@ninetailed/experience.js-shared';
|
|
2
1
|
import { DetachListeners } from 'analytics';
|
|
3
|
-
import {
|
|
4
|
-
import { NinetailedPlugin } from '
|
|
2
|
+
import { Logger, PageviewProperties, Profile, Properties, Traits, SelectedVariantInfo, Reference, Event } from '@ninetailed/experience.js-shared';
|
|
3
|
+
import { ElementSeenPayload, NinetailedPlugin, TrackComponentProperties } from '@ninetailed/experience.js-plugin-analytics';
|
|
5
4
|
import { type Ninetailed } from '../Ninetailed';
|
|
6
|
-
import {
|
|
5
|
+
import { OnSelectVariant } from './OnSelectVariant';
|
|
6
|
+
import { EventBuilder } from '../utils/EventBuilder';
|
|
7
7
|
type Loading = {
|
|
8
8
|
status: 'loading';
|
|
9
9
|
profile: null;
|
|
@@ -42,12 +42,13 @@ export type Track = (event: string, properties?: Properties, options?: EventFunc
|
|
|
42
42
|
export type TrackHasSeenComponent = (properties: TrackComponentProperties) => Promise<void>;
|
|
43
43
|
export type TrackComponentView = (properties: ElementSeenPayload) => Promise<void>;
|
|
44
44
|
export type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<FlushResult>;
|
|
45
|
+
export type Batch = (events: Event[]) => Promise<FlushResult>;
|
|
45
46
|
export type Reset = () => void;
|
|
46
47
|
export type Debug = (enable: boolean) => void;
|
|
47
48
|
export type OnProfileChange = (cb: OnProfileChangeCallback) => DetachListeners;
|
|
48
49
|
type ObserveElement = Ninetailed['observeElement'];
|
|
49
50
|
type UnObserveElement = Ninetailed['unobserveElement'];
|
|
50
|
-
export interface NinetailedInstance {
|
|
51
|
+
export interface NinetailedInstance<TBaseline extends Reference = Reference, TVariant extends Reference = Reference> {
|
|
51
52
|
page: Page;
|
|
52
53
|
track: Track;
|
|
53
54
|
/**
|
|
@@ -56,20 +57,19 @@ export interface NinetailedInstance {
|
|
|
56
57
|
trackHasSeenComponent: TrackHasSeenComponent;
|
|
57
58
|
trackComponentView: TrackComponentView;
|
|
58
59
|
identify: Identify;
|
|
60
|
+
batch: Batch;
|
|
59
61
|
reset: Reset;
|
|
60
62
|
debug: Debug;
|
|
61
63
|
profileState: ProfileState;
|
|
62
64
|
onProfileChange: OnProfileChange;
|
|
63
65
|
plugins: NinetailedPlugin[];
|
|
64
66
|
logger: Logger;
|
|
67
|
+
eventBuilder: EventBuilder;
|
|
65
68
|
onIsInitialized: OnIsInitialized;
|
|
66
69
|
observeElement: ObserveElement;
|
|
67
70
|
unobserveElement: UnObserveElement;
|
|
71
|
+
onSelectVariant: OnSelectVariant<TBaseline, TVariant>;
|
|
68
72
|
}
|
|
69
|
-
export { NinetailedPlugin, TrackComponentProperties };
|
|
70
|
-
export type { EventHandler } from './EventHandler';
|
|
71
73
|
export type { AnalyticsInstance } from './AnalyticsInstance';
|
|
72
|
-
export { ElementSeenPayloadSchema } from './ElementSeenPayload';
|
|
73
|
-
export type { ElementSeenPayload } from './ElementSeenPayload';
|
|
74
74
|
export type { ProfileChangedPayload } from './ProfileChangedPayload';
|
|
75
75
|
export type { Credentials } from './Credentials';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js-shared';
|
|
2
|
-
export type
|
|
3
|
-
experience: ExperienceConfiguration<
|
|
4
|
-
variant:
|
|
1
|
+
import { ExperienceConfiguration, Reference, VariantRef } from '@ninetailed/experience.js-shared';
|
|
2
|
+
export type ExperienceSelectionMiddlewareArg<TBaseline extends Reference, TVariant extends Reference> = {
|
|
3
|
+
experience: ExperienceConfiguration<TVariant> | null;
|
|
4
|
+
variant: TBaseline | TVariant | VariantRef;
|
|
5
5
|
variantIndex: number;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
experiences: ExperienceConfiguration<
|
|
7
|
+
export type ExperienceSelectionMiddleware<TBaseline extends Reference, TVariant extends Reference> = (arg: ExperienceSelectionMiddlewareArg<TBaseline, TVariant>) => ExperienceSelectionMiddlewareArg<TBaseline, TVariant>;
|
|
8
|
+
type BuildExperienceSelectionMiddlewareArg<TVariant extends Reference> = {
|
|
9
|
+
experiences: ExperienceConfiguration<TVariant>[];
|
|
10
10
|
baseline: Reference;
|
|
11
11
|
};
|
|
12
|
-
export type
|
|
13
|
-
export interface HasExperienceSelectionMiddleware<
|
|
14
|
-
getExperienceSelectionMiddleware:
|
|
12
|
+
export type BuildExperienceSelectionMiddleware<TBaseline extends Reference, TVariant extends Reference> = (arg: BuildExperienceSelectionMiddlewareArg<TVariant>) => ExperienceSelectionMiddleware<TBaseline, TVariant>;
|
|
13
|
+
export interface HasExperienceSelectionMiddleware<TBaseline extends Reference, TVariant extends Reference> {
|
|
14
|
+
getExperienceSelectionMiddleware: BuildExperienceSelectionMiddleware<TBaseline, TVariant>;
|
|
15
15
|
}
|
|
16
16
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PROFILE_CHANGE } from '@ninetailed/experience.js-shared';
|
|
2
|
-
import { EventHandler } from '
|
|
2
|
+
import { EventHandler } from '@ninetailed/experience.js-plugin-analytics';
|
|
3
3
|
import { ProfileChangedPayload } from '../ProfileChangedPayload';
|
|
4
4
|
export interface InterestedInProfileChange {
|
|
5
5
|
[PROFILE_CHANGE]: EventHandler<ProfileChangedPayload>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { HAS_SEEN_ELEMENT } from '
|
|
2
|
-
import { ElementSeenPayload } from '../ElementSeenPayload';
|
|
3
|
-
import { EventHandler } from '../EventHandler';
|
|
1
|
+
import { EventHandler, ElementSeenPayload, HAS_SEEN_ELEMENT } from '@ninetailed/experience.js-plugin-analytics';
|
|
4
2
|
export interface InterestedInSeenElements {
|
|
5
3
|
[HAS_SEEN_ELEMENT]: EventHandler<ElementSeenPayload>;
|
|
6
4
|
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { BuildPageEventArgs, BuildTrackEventArgs, IdentifyEventArgs, NinetailedRequestContext, Properties } from '@ninetailed/experience.js-shared';
|
|
2
|
+
export declare class EventBuilder {
|
|
3
|
+
private readonly buildRequestContext;
|
|
4
|
+
constructor(buildRequestContext?: () => NinetailedRequestContext);
|
|
5
|
+
page(properties?: Properties, data?: Partial<Omit<BuildPageEventArgs, 'ctx' | 'properties'>>): {
|
|
6
|
+
channel: import("@ninetailed/experience.js-shared").EventChanel;
|
|
7
|
+
context: {
|
|
8
|
+
app?: {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
campaign: {
|
|
13
|
+
name?: string | undefined;
|
|
14
|
+
source?: string | undefined;
|
|
15
|
+
medium?: string | undefined;
|
|
16
|
+
term?: string | undefined;
|
|
17
|
+
content?: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
library: {
|
|
20
|
+
name: string;
|
|
21
|
+
version: string;
|
|
22
|
+
};
|
|
23
|
+
locale: string;
|
|
24
|
+
page: {
|
|
25
|
+
path: string;
|
|
26
|
+
url: string;
|
|
27
|
+
query: Record<string, string>;
|
|
28
|
+
referrer: string;
|
|
29
|
+
search: string;
|
|
30
|
+
};
|
|
31
|
+
userAgent?: string | undefined;
|
|
32
|
+
gdpr: {
|
|
33
|
+
isConsentGiven: boolean;
|
|
34
|
+
};
|
|
35
|
+
location?: {
|
|
36
|
+
coordinates?: {
|
|
37
|
+
latitude: number;
|
|
38
|
+
longitude: number;
|
|
39
|
+
} | undefined;
|
|
40
|
+
city?: string | undefined;
|
|
41
|
+
postalCode?: string | undefined;
|
|
42
|
+
region?: string | undefined;
|
|
43
|
+
regionCode?: string | undefined;
|
|
44
|
+
country?: string | undefined;
|
|
45
|
+
countryCode?: string | undefined;
|
|
46
|
+
continent?: string | undefined;
|
|
47
|
+
timezone?: string | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
};
|
|
50
|
+
messageId: string;
|
|
51
|
+
originalTimestamp: string;
|
|
52
|
+
timestamp: string;
|
|
53
|
+
sentAt: string;
|
|
54
|
+
type: import("@ninetailed/experience.js-shared").EventType;
|
|
55
|
+
userId?: string | undefined;
|
|
56
|
+
name?: string | undefined;
|
|
57
|
+
properties: import("@ninetailed/experience.js-shared").PageviewProperties;
|
|
58
|
+
};
|
|
59
|
+
track(event: string, properties?: Properties, data?: Partial<Omit<BuildTrackEventArgs, 'ctx' | 'event' | 'properties'>>): {
|
|
60
|
+
channel: import("@ninetailed/experience.js-shared").EventChanel;
|
|
61
|
+
context: {
|
|
62
|
+
app?: {
|
|
63
|
+
name: string;
|
|
64
|
+
version: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
campaign: {
|
|
67
|
+
name?: string | undefined;
|
|
68
|
+
source?: string | undefined;
|
|
69
|
+
medium?: string | undefined;
|
|
70
|
+
term?: string | undefined;
|
|
71
|
+
content?: string | undefined;
|
|
72
|
+
};
|
|
73
|
+
library: {
|
|
74
|
+
name: string;
|
|
75
|
+
version: string;
|
|
76
|
+
};
|
|
77
|
+
locale: string;
|
|
78
|
+
page: {
|
|
79
|
+
path: string;
|
|
80
|
+
url: string;
|
|
81
|
+
query: Record<string, string>;
|
|
82
|
+
referrer: string;
|
|
83
|
+
search: string;
|
|
84
|
+
};
|
|
85
|
+
userAgent?: string | undefined;
|
|
86
|
+
gdpr: {
|
|
87
|
+
isConsentGiven: boolean;
|
|
88
|
+
};
|
|
89
|
+
location?: {
|
|
90
|
+
coordinates?: {
|
|
91
|
+
latitude: number;
|
|
92
|
+
longitude: number;
|
|
93
|
+
} | undefined;
|
|
94
|
+
city?: string | undefined;
|
|
95
|
+
postalCode?: string | undefined;
|
|
96
|
+
region?: string | undefined;
|
|
97
|
+
regionCode?: string | undefined;
|
|
98
|
+
country?: string | undefined;
|
|
99
|
+
countryCode?: string | undefined;
|
|
100
|
+
continent?: string | undefined;
|
|
101
|
+
timezone?: string | undefined;
|
|
102
|
+
} | undefined;
|
|
103
|
+
};
|
|
104
|
+
messageId: string;
|
|
105
|
+
originalTimestamp: string;
|
|
106
|
+
timestamp: string;
|
|
107
|
+
sentAt: string;
|
|
108
|
+
type: import("@ninetailed/experience.js-shared").EventType;
|
|
109
|
+
userId?: string | undefined;
|
|
110
|
+
event: string;
|
|
111
|
+
properties: Properties;
|
|
112
|
+
};
|
|
113
|
+
identify(userId: string, traits?: Properties, data?: Partial<Omit<IdentifyEventArgs, 'ctx' | 'userId' | 'traits'>>): {
|
|
114
|
+
channel: import("@ninetailed/experience.js-shared").EventChanel;
|
|
115
|
+
context: {
|
|
116
|
+
app?: {
|
|
117
|
+
name: string;
|
|
118
|
+
version: string;
|
|
119
|
+
} | undefined;
|
|
120
|
+
campaign: {
|
|
121
|
+
name?: string | undefined;
|
|
122
|
+
source?: string | undefined;
|
|
123
|
+
medium?: string | undefined;
|
|
124
|
+
term?: string | undefined;
|
|
125
|
+
content?: string | undefined;
|
|
126
|
+
};
|
|
127
|
+
library: {
|
|
128
|
+
name: string;
|
|
129
|
+
version: string;
|
|
130
|
+
};
|
|
131
|
+
locale: string;
|
|
132
|
+
page: {
|
|
133
|
+
path: string;
|
|
134
|
+
url: string;
|
|
135
|
+
query: Record<string, string>;
|
|
136
|
+
referrer: string;
|
|
137
|
+
search: string;
|
|
138
|
+
};
|
|
139
|
+
userAgent?: string | undefined;
|
|
140
|
+
gdpr: {
|
|
141
|
+
isConsentGiven: boolean;
|
|
142
|
+
};
|
|
143
|
+
location?: {
|
|
144
|
+
coordinates?: {
|
|
145
|
+
latitude: number;
|
|
146
|
+
longitude: number;
|
|
147
|
+
} | undefined;
|
|
148
|
+
city?: string | undefined;
|
|
149
|
+
postalCode?: string | undefined;
|
|
150
|
+
region?: string | undefined;
|
|
151
|
+
regionCode?: string | undefined;
|
|
152
|
+
country?: string | undefined;
|
|
153
|
+
countryCode?: string | undefined;
|
|
154
|
+
continent?: string | undefined;
|
|
155
|
+
timezone?: string | undefined;
|
|
156
|
+
} | undefined;
|
|
157
|
+
};
|
|
158
|
+
messageId: string;
|
|
159
|
+
originalTimestamp: string;
|
|
160
|
+
timestamp: string;
|
|
161
|
+
sentAt: string;
|
|
162
|
+
type: import("@ninetailed/experience.js-shared").EventType;
|
|
163
|
+
userId?: string | undefined;
|
|
164
|
+
traits: Properties;
|
|
165
|
+
};
|
|
166
|
+
component(componentId: string, experienceId?: string, variantIndex?: number, data?: Partial<Omit<BuildPageEventArgs, 'ctx' | 'componentId' | 'experienceId' | 'variantIndex'>>): {
|
|
167
|
+
channel: import("@ninetailed/experience.js-shared").EventChanel;
|
|
168
|
+
context: {
|
|
169
|
+
app?: {
|
|
170
|
+
name: string;
|
|
171
|
+
version: string;
|
|
172
|
+
} | undefined;
|
|
173
|
+
campaign: {
|
|
174
|
+
name?: string | undefined;
|
|
175
|
+
source?: string | undefined;
|
|
176
|
+
medium?: string | undefined;
|
|
177
|
+
term?: string | undefined;
|
|
178
|
+
content?: string | undefined;
|
|
179
|
+
};
|
|
180
|
+
library: {
|
|
181
|
+
name: string;
|
|
182
|
+
version: string;
|
|
183
|
+
};
|
|
184
|
+
locale: string;
|
|
185
|
+
page: {
|
|
186
|
+
path: string;
|
|
187
|
+
url: string;
|
|
188
|
+
query: Record<string, string>;
|
|
189
|
+
referrer: string;
|
|
190
|
+
search: string;
|
|
191
|
+
};
|
|
192
|
+
userAgent?: string | undefined;
|
|
193
|
+
gdpr: {
|
|
194
|
+
isConsentGiven: boolean;
|
|
195
|
+
};
|
|
196
|
+
location?: {
|
|
197
|
+
coordinates?: {
|
|
198
|
+
latitude: number;
|
|
199
|
+
longitude: number;
|
|
200
|
+
} | undefined;
|
|
201
|
+
city?: string | undefined;
|
|
202
|
+
postalCode?: string | undefined;
|
|
203
|
+
region?: string | undefined;
|
|
204
|
+
regionCode?: string | undefined;
|
|
205
|
+
country?: string | undefined;
|
|
206
|
+
countryCode?: string | undefined;
|
|
207
|
+
continent?: string | undefined;
|
|
208
|
+
timezone?: string | undefined;
|
|
209
|
+
} | undefined;
|
|
210
|
+
};
|
|
211
|
+
messageId: string;
|
|
212
|
+
originalTimestamp: string;
|
|
213
|
+
timestamp: string;
|
|
214
|
+
sentAt: string;
|
|
215
|
+
type: import("@ninetailed/experience.js-shared").EventType;
|
|
216
|
+
userId?: string | undefined;
|
|
217
|
+
componentId: string;
|
|
218
|
+
experienceId?: string | undefined;
|
|
219
|
+
variantIndex?: number | undefined;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const noop: () => void;
|