@ninetailed/experience.js 3.0.2 → 3.0.3-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.
@@ -10,7 +10,7 @@ declare global {
10
10
  } & unknown;
11
11
  }
12
12
  }
13
- declare type Options = {
13
+ type Options = {
14
14
  url?: string;
15
15
  locale?: Locale;
16
16
  plugins?: (AnalyticsPlugin | AnalyticsPlugin[])[];
@@ -19,7 +19,7 @@ declare type Options = {
19
19
  onLog?: OnLogHandler;
20
20
  onError?: OnErrorHandler;
21
21
  };
22
- declare type NinetailedApiClientInstanceOrOptions = NinetailedApiClient | NinetailedApiClientOptions;
22
+ type NinetailedApiClientInstanceOrOptions = NinetailedApiClient | NinetailedApiClientOptions;
23
23
  export declare class Ninetailed implements NinetailedInstance {
24
24
  private readonly instance;
25
25
  private _profileState;
@@ -1,7 +1,7 @@
1
1
  import { AnalyticsPlugin } from 'analytics';
2
2
  import { Profile, Locale, NinetailedApiClient } from '@ninetailed/experience.js-shared';
3
3
  import { NinetailedInstance, FlushResult } from '../types';
4
- declare type AnalyticsPluginNinetailedConfig = {
4
+ type AnalyticsPluginNinetailedConfig = {
5
5
  apiClient: NinetailedApiClient;
6
6
  profile?: Profile;
7
7
  locale?: Locale;
@@ -1,6 +1,6 @@
1
1
  import { Profile } from '@ninetailed/experience.js-shared';
2
2
  import { ExperienceConfiguration } from './types';
3
- declare type IsExperienceMatchArgs = {
3
+ type IsExperienceMatchArgs = {
4
4
  experience: ExperienceConfiguration<any>;
5
5
  activeExperiments: ExperienceConfiguration<any>[];
6
6
  profile: Profile;
@@ -1,6 +1,6 @@
1
1
  import { Profile } from '@ninetailed/experience.js-shared';
2
2
  import { Distribution, ExperienceConfiguration, Reference } from './types';
3
- declare type SelectDistributionArgs<Variant extends Reference> = {
3
+ type SelectDistributionArgs<Variant extends Reference> = {
4
4
  experience: ExperienceConfiguration<Variant>;
5
5
  profile: Profile;
6
6
  };
@@ -1,5 +1,5 @@
1
1
  import { ExperienceConfiguration, Reference } from './types';
2
- declare type SelectEligibleExperiencesArgs<Variant extends Reference> = {
2
+ type SelectEligibleExperiencesArgs<Variant extends Reference> = {
3
3
  experiences: ExperienceConfiguration<Variant>[];
4
4
  activeExperiments: ExperienceConfiguration<Variant>[];
5
5
  };
@@ -1,6 +1,6 @@
1
1
  import { Profile } from '@ninetailed/experience.js-shared';
2
2
  import { ExperienceConfiguration, Reference } from './types';
3
- declare type SelectExprienceArgs<Variant extends Reference> = {
3
+ type SelectExprienceArgs<Variant extends Reference> = {
4
4
  experiences: ExperienceConfiguration<Variant>[];
5
5
  activeExperiments: ExperienceConfiguration<Variant>[];
6
6
  profile: Profile;
@@ -1,6 +1,6 @@
1
1
  import { Profile } from '@ninetailed/experience.js-shared';
2
2
  import { Baseline, ExperienceConfiguration, Reference, VariantRef } from './types';
3
- declare type SelectVariantArgs<Variant extends Reference> = {
3
+ type SelectVariantArgs<Variant extends Reference> = {
4
4
  baseline: Baseline;
5
5
  experience: ExperienceConfiguration<Variant>;
6
6
  profile: Profile;
@@ -1,2 +1,2 @@
1
1
  import { Reference } from './Reference';
2
- export declare type Baseline<P = unknown> = P & Reference;
2
+ export type Baseline<P = unknown> = P & Reference;
@@ -1,7 +1,7 @@
1
1
  import { Baseline } from './Baseline';
2
2
  import { Reference } from './Reference';
3
3
  import { VariantRef } from './VariantRef';
4
- export declare type BaselineWithVariants<Variant extends Reference> = {
4
+ export type BaselineWithVariants<Variant extends Reference> = {
5
5
  baseline: Baseline;
6
6
  variants: (Variant | VariantRef)[];
7
7
  };
@@ -1,4 +1,4 @@
1
- export declare type Distribution = {
1
+ export type Distribution = {
2
2
  index: number;
3
3
  start: number;
4
4
  end: number;
@@ -1,8 +1,8 @@
1
1
  import { BaselineWithVariants } from './BaselineWithVariants';
2
2
  import { Distribution } from './Distribution';
3
3
  import { Reference } from './Reference';
4
- export declare type ExperienceType = 'nt_personalization' | 'nt_experiment';
5
- export declare type ExperienceConfiguration<Variant extends Reference = Reference> = {
4
+ export type ExperienceType = 'nt_personalization' | 'nt_experiment';
5
+ export type ExperienceConfiguration<Variant extends Reference = Reference> = {
6
6
  id: string;
7
7
  type: ExperienceType;
8
8
  audience?: {
@@ -1,3 +1,3 @@
1
- export declare type Reference = {
1
+ export type Reference = {
2
2
  id: string;
3
3
  };
@@ -1,4 +1,4 @@
1
- export declare type VariantRef = {
1
+ export type VariantRef = {
2
2
  id: string;
3
3
  hidden: boolean;
4
4
  };
@@ -1,9 +1,9 @@
1
1
  import { Variant } from '@ninetailed/experience.js-shared';
2
2
  import { ProfileState } from './types';
3
- declare type Options = {
3
+ type Options = {
4
4
  holdout?: number;
5
5
  };
6
- declare type Loading<T> = {
6
+ type Loading<T> = {
7
7
  loading: true;
8
8
  variant: Variant<T>;
9
9
  audience: {
@@ -12,7 +12,7 @@ declare type Loading<T> = {
12
12
  isPersonalized: false;
13
13
  error: null;
14
14
  };
15
- declare type Success<T> = {
15
+ type Success<T> = {
16
16
  loading: false;
17
17
  variant: Variant<T>;
18
18
  audience: {
@@ -21,7 +21,7 @@ declare type Success<T> = {
21
21
  isPersonalized: boolean;
22
22
  error: null;
23
23
  };
24
- declare type Fail<T> = {
24
+ type Fail<T> = {
25
25
  loading: false;
26
26
  variant: Variant<T>;
27
27
  audience: {
@@ -30,7 +30,7 @@ declare type Fail<T> = {
30
30
  isPersonalized: false;
31
31
  error: Error;
32
32
  };
33
- declare type Result<T> = Loading<T> | Success<T> | Fail<T>;
33
+ type Result<T> = Loading<T> | Success<T> | Fail<T>;
34
34
  export declare const selectVariant: <T extends {
35
35
  id: string;
36
36
  }>(baseline: T, variants: Variant<T>[], { status, profile, error }: ProfileState, options?: Options) => Result<T>;
package/lib/types.d.ts CHANGED
@@ -1,44 +1,44 @@
1
1
  import { TrackComponentProperties, TrackExperienceProperties } from '@ninetailed/experience.js-plugin-analytics';
2
2
  import { Logger, PageviewProperties, Profile, Properties, Traits } from '@ninetailed/experience.js-shared';
3
3
  import { AnalyticsPlugin, DetachListeners } from 'analytics';
4
- declare type Loading = {
4
+ type Loading = {
5
5
  status: 'loading';
6
6
  profile: null;
7
7
  error: null;
8
8
  };
9
- declare type Success = {
9
+ type Success = {
10
10
  status: 'success';
11
11
  profile: Profile;
12
12
  error: null;
13
13
  };
14
- declare type Fail = {
14
+ type Fail = {
15
15
  status: 'error';
16
16
  profile: null;
17
17
  error: Error;
18
18
  };
19
- export declare type ProfileState = {
19
+ export type ProfileState = {
20
20
  from: 'api' | 'hydrated';
21
21
  } & (Loading | Success | Fail);
22
- export declare type OnIsInitializedCallback = () => void;
23
- export declare type OnIsInitialized = (cb: OnIsInitializedCallback) => void;
24
- export declare type EventFunctionOptions = {
22
+ export type OnIsInitializedCallback = () => void;
23
+ export type OnIsInitialized = (cb: OnIsInitializedCallback) => void;
24
+ export type EventFunctionOptions = {
25
25
  plugins?: {
26
26
  all: boolean;
27
27
  [key: string]: boolean;
28
28
  };
29
29
  };
30
- export declare type FlushResult = {
30
+ export type FlushResult = {
31
31
  success: boolean;
32
32
  };
33
- export declare type OnProfileChangeCallback = (profile: ProfileState) => void;
34
- export declare type Page = (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<FlushResult>;
35
- export declare type Track = (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<FlushResult>;
36
- export declare type TrackHasSeenComponent = (properties: TrackComponentProperties) => Promise<void>;
37
- export declare type TrackHasSeenExperience = (properties: TrackExperienceProperties) => Promise<void>;
38
- export declare type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<FlushResult>;
39
- export declare type Reset = () => void;
40
- export declare type Debug = (enable: boolean) => void;
41
- export declare type OnProfileChange = (cb: OnProfileChangeCallback) => DetachListeners;
33
+ export type OnProfileChangeCallback = (profile: ProfileState) => void;
34
+ export type Page = (data?: Partial<PageviewProperties>, options?: EventFunctionOptions) => Promise<FlushResult>;
35
+ export type Track = (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<FlushResult>;
36
+ export type TrackHasSeenComponent = (properties: TrackComponentProperties) => Promise<void>;
37
+ export type TrackHasSeenExperience = (properties: TrackExperienceProperties) => Promise<void>;
38
+ export type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<FlushResult>;
39
+ export type Reset = () => void;
40
+ export type Debug = (enable: boolean) => void;
41
+ export type OnProfileChange = (cb: OnProfileChangeCallback) => DetachListeners;
42
42
  export interface NinetailedInstance {
43
43
  page: Page;
44
44
  track: Track;
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "3.0.2",
3
+ "version": "3.0.3-beta.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": "3.0.2",
9
+ "@ninetailed/experience.js-shared": "3.0.3-beta.0",
10
10
  "analytics": "0.8.1",
11
11
  "lodash": "4.17.21",
12
12
  "murmurhash-js": "1.0.0",
13
- "@ninetailed/experience.js-plugin-analytics": "3.0.2"
13
+ "@ninetailed/experience.js-plugin-analytics": "3.0.3-beta.0"
14
14
  },
15
15
  "peerDependencies": {}
16
16
  }