@ninetailed/experience.js 1.0.0-beta.8 → 1.0.1-beta.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.
@@ -1,10 +1,10 @@
1
1
  import { PageData, AnalyticsPlugin, DetachListeners } from 'analytics';
2
- import { Locale, Traits, Profile } from '@ninetailed/experience.js-shared';
2
+ import { Locale, Traits, Profile, Variant } from '@ninetailed/experience.js-shared';
3
3
  import { ProfileState } from './types';
4
4
  declare type Options = {
5
5
  url?: string;
6
6
  locale?: Locale;
7
- plugins?: AnalyticsPlugin[];
7
+ plugins?: (AnalyticsPlugin | AnalyticsPlugin[])[];
8
8
  profile?: Profile;
9
9
  };
10
10
  declare type EventFunctionOptions = {
@@ -16,6 +16,13 @@ declare type EventFunctionOptions = {
16
16
  declare type OnProfileChangeCallback = (profile: ProfileState) => void;
17
17
  export declare type Page = (data?: PageData, options?: EventFunctionOptions) => Promise<void>;
18
18
  export declare type Track = (event: string, payload?: unknown, options?: EventFunctionOptions) => Promise<void>;
19
+ export declare type TrackHasSeenComponent = (payload: {
20
+ variant: Variant<unknown>;
21
+ audience: {
22
+ id: string;
23
+ };
24
+ isPersonalized: boolean;
25
+ }) => Promise<void>;
19
26
  export declare type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<void>;
20
27
  export declare type Reset = () => void;
21
28
  export declare type Debug = (enable: boolean) => void;
@@ -23,6 +30,7 @@ export declare type OnProfileChange = (cb: OnProfileChangeCallback) => DetachLis
23
30
  export interface NinetailedInstance {
24
31
  page: Page;
25
32
  track: Track;
33
+ trackHasSeenComponent: TrackHasSeenComponent;
26
34
  identify: Identify;
27
35
  reset: Reset;
28
36
  debug: Debug;
@@ -36,9 +44,11 @@ export declare class Ninetailed implements NinetailedInstance {
36
44
  constructor({ clientId, environment }: {
37
45
  clientId: string;
38
46
  environment?: string;
47
+ preview?: boolean;
39
48
  }, { plugins, url, profile, locale }?: Options);
40
49
  page: (data?: PageData, options?: EventFunctionOptions) => Promise<any>;
41
50
  track: (event: string, payload?: unknown, options?: EventFunctionOptions) => Promise<any>;
51
+ trackHasSeenComponent: TrackHasSeenComponent;
42
52
  identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<any>;
43
53
  reset: () => any;
44
54
  debug: (enabled: boolean) => any;
@@ -8,6 +8,7 @@ declare global {
8
8
  declare type AnalyticsPluginNinetailedConfig = {
9
9
  clientId: string;
10
10
  environment?: string;
11
+ preview?: boolean;
11
12
  url?: string;
12
13
  profile?: Profile;
13
14
  locale?: Locale;
@@ -19,5 +20,5 @@ export declare const NINETAILED_TRACKER_EVENTS: {
19
20
  profile: string;
20
21
  };
21
22
  export declare const PLUGIN_NAME = "ninetailed";
22
- export declare const ninetailedPlugin: ({ clientId, environment, url, profile, locale, }: AnalyticsPluginNinetailedConfig) => AnalyticsPlugin;
23
+ export declare const ninetailedPlugin: ({ clientId, environment, preview, url, profile, locale, }: AnalyticsPluginNinetailedConfig) => AnalyticsPlugin;
23
24
  export {};
@@ -1,10 +1,11 @@
1
- import { ProfileState, Variant } from './types';
1
+ import { Variant } from '@ninetailed/experience.js-shared';
2
+ import { ProfileState } from './types';
2
3
  declare type Options = {
3
4
  holdout?: number;
4
5
  };
5
6
  declare type Loading<T> = {
6
7
  loading: true;
7
- variant: T;
8
+ variant: Variant<T>;
8
9
  audience: {
9
10
  id: 'baseline';
10
11
  };
@@ -13,7 +14,7 @@ declare type Loading<T> = {
13
14
  };
14
15
  declare type Success<T> = {
15
16
  loading: false;
16
- variant: T;
17
+ variant: Variant<T>;
17
18
  audience: {
18
19
  id: string;
19
20
  };
@@ -22,7 +23,7 @@ declare type Success<T> = {
22
23
  };
23
24
  declare type Fail<T> = {
24
25
  loading: false;
25
- variant: T;
26
+ variant: Variant<T>;
26
27
  audience: {
27
28
  id: 'baseline';
28
29
  };
package/lib/types.d.ts CHANGED
@@ -1,9 +1,4 @@
1
1
  import { Profile } from "@ninetailed/experience.js-shared";
2
- export declare type Variant<P> = {
3
- audience: {
4
- id: string;
5
- };
6
- } & P;
7
2
  export declare type ProfileState = {
8
3
  loading: boolean;
9
4
  profile?: Profile;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.1-beta.0",
4
4
  "main": "./index.umd.js",
5
5
  "module": "./index.esm.js",
6
6
  "typings": "./index.d.ts",
7
7
  "dependencies": {
8
- "analytics": "^0.8.0",
9
- "@ninetailed/experience.js-shared": "1.0.0-beta.8",
8
+ "@ninetailed/experience.js-shared": "1.0.1-beta.0",
10
9
  "uuid": "^8.3.2",
11
10
  "ts-toolbelt": "^9.6.0",
12
11
  "locale-enum": "^1.1.1",
13
12
  "i18n-iso-countries": "^7.3.0",
13
+ "analytics": "^0.8.0",
14
14
  "lodash": "^4.17.21"
15
15
  },
16
16
  "peerDependencies": {}