@ninetailed/experience.js 2.0.0-beta.4 → 2.0.0-beta.40

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,6 +1,7 @@
1
1
  import { PageData, AnalyticsPlugin, DetachListeners } from 'analytics';
2
2
  import { Locale, Traits, Profile, Variant } from '@ninetailed/experience.js-shared';
3
3
  import { ProfileState } from './types';
4
+ import { ExperienceConfiguration } from './experience';
4
5
  declare global {
5
6
  interface Window {
6
7
  ninetailed?: {
@@ -33,6 +34,14 @@ export declare type TrackHasSeenComponent = (payload: {
33
34
  };
34
35
  isPersonalized: boolean;
35
36
  }) => Promise<void>;
37
+ export declare type TrackExperiencePayload = {
38
+ experience: ExperienceConfiguration;
39
+ variant: number;
40
+ component: {
41
+ id: string;
42
+ };
43
+ };
44
+ export declare type TrackExperience = (payload: TrackExperiencePayload) => Promise<void>;
36
45
  export declare type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<void>;
37
46
  export declare type Reset = () => void;
38
47
  export declare type Debug = (enable: boolean) => void;
@@ -41,16 +50,18 @@ export interface NinetailedInstance {
41
50
  page: Page;
42
51
  track: Track;
43
52
  trackHasSeenComponent: TrackHasSeenComponent;
53
+ trackExperience: TrackExperience;
44
54
  identify: Identify;
45
55
  reset: Reset;
46
56
  debug: Debug;
47
57
  profileState: ProfileState;
48
58
  onProfileChange: OnProfileChange;
59
+ plugins: AnalyticsPlugin[];
49
60
  }
50
61
  export declare class Ninetailed implements NinetailedInstance {
51
62
  private readonly instance;
52
- private readonly plugins;
53
63
  private _profileState;
64
+ readonly plugins: AnalyticsPlugin[];
54
65
  constructor({ clientId, environment, }: {
55
66
  clientId: string;
56
67
  environment?: string;
@@ -59,6 +70,7 @@ export declare class Ninetailed implements NinetailedInstance {
59
70
  page: (data?: PageData, options?: EventFunctionOptions) => Promise<any>;
60
71
  track: (event: string, payload?: unknown, options?: EventFunctionOptions) => Promise<any>;
61
72
  trackHasSeenComponent: TrackHasSeenComponent;
73
+ trackExperience: TrackExperience;
62
74
  identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<any>;
63
75
  reset: () => any;
64
76
  debug: (enabled: boolean) => any;
@@ -1 +1,2 @@
1
1
  export * from './get-analytics-plugin';
2
+ export * as Cache from './Cache';
@@ -1,3 +1,3 @@
1
- export declare const log: any;
2
1
  export declare const enable: () => void;
3
- export declare const disable: () => any;
2
+ export declare const disable: () => void;
3
+ export declare const log: (...msg: any[]) => void;
@@ -0,0 +1 @@
1
+ export declare const decodeExperienceVariantsMap: (encodedExperienceVariantsMap: string) => Record<string, number>;
@@ -1,8 +1,12 @@
1
1
  export * from './types';
2
+ export { EXPERIENCE_TRAIT_PREFIX } from './constants';
2
3
  export { selectBaselineWithVariants as selectExperienceBaselineWithVariants } from './selectBaselineWithVariants';
3
4
  export { selectVariants as selectExperienceVariants } from './selectVariants';
4
5
  export { selectHasVariants as selectHasExperienceVariants } from './selectHasVariants';
5
6
  export { selectActiveExperiments } from './selectActiveExperiments';
6
- export { selectEglibleExperiences } from './selectEglibleExperiences';
7
+ export { selectEligibleExperiences } from './selectEligibleExperiences';
7
8
  export { selectExperience } from './selectExperience';
8
9
  export { selectVariant as selectExperienceVariant } from './selectVariant';
10
+ export { isExperienceMatch } from './isExperienceMatch';
11
+ export { selectDistribution } from './selectDistribution';
12
+ export { decodeExperienceVariantsMap } from './decodeExperienceVariantsMap';
@@ -0,0 +1,9 @@
1
+ import { Profile } from '@ninetailed/experience.js-shared';
2
+ import { ExperienceConfiguration } from './types';
3
+ declare type IsExperienceMatchArgs = {
4
+ experience: ExperienceConfiguration;
5
+ activeExperiments: ExperienceConfiguration[];
6
+ profile: Profile;
7
+ };
8
+ export declare const isExperienceMatch: ({ experience, activeExperiments, profile }: IsExperienceMatchArgs) => boolean;
9
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Profile } from '@ninetailed/experience.js-shared';
2
+ import { Distribution, ExperienceConfiguration } from './types';
3
+ declare type SelectDistributionArgs = {
4
+ experience: ExperienceConfiguration;
5
+ profile: Profile;
6
+ };
7
+ export declare const selectDistribution: ({ experience, profile, }: SelectDistributionArgs) => Distribution;
8
+ export {};
@@ -1,12 +1,12 @@
1
1
  import { ExperienceConfiguration } from './types';
2
- declare type SelectEglibleExperiencesArgs = {
2
+ declare type SelectEligibleExperiencesArgs = {
3
3
  experiences: ExperienceConfiguration[];
4
4
  activeExperiments: ExperienceConfiguration[];
5
5
  };
6
6
  /**
7
- * We can use any personalization as eglible experience
7
+ * We can use any personalization as eligible experience
8
8
  * When going for an experiment we can only select a active experiment when 1 or more experiments are active
9
9
  * If the profile is not in any active experiments, we can select any expermiment
10
10
  */
11
- export declare const selectEglibleExperiences: ({ experiences, activeExperiments, }: SelectEglibleExperiencesArgs) => ExperienceConfiguration[];
11
+ export declare const selectEligibleExperiences: ({ experiences, activeExperiments, }: SelectEligibleExperiencesArgs) => ExperienceConfiguration[];
12
12
  export {};
@@ -1,6 +1,5 @@
1
1
  import { Profile } from '@ninetailed/experience.js-shared';
2
- import { Variant } from './types';
3
- import { Baseline, ExperienceConfiguration } from './types';
2
+ import { Baseline, ExperienceConfiguration, Variant } from './types';
4
3
  declare type SelectVariantArgs = {
5
4
  baseline: Baseline;
6
5
  experience: ExperienceConfiguration;
@@ -0,0 +1,4 @@
1
+ import { Profile } from '@ninetailed/experience.js-shared';
2
+ import { ExperienceConfiguration } from './types';
3
+ export declare const getTrafficRandom: (profile: Profile, experience: ExperienceConfiguration) => number;
4
+ export declare const getDistributionRandom: (profile: Profile, experience: ExperienceConfiguration) => number;
package/package.json CHANGED
@@ -1,17 +1,19 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.40",
4
4
  "main": "./index.umd.js",
5
5
  "module": "./index.esm.js",
6
6
  "typings": "./index.d.ts",
7
7
  "dependencies": {
8
8
  "analytics": "^0.8.0",
9
- "@ninetailed/experience.js-shared": "2.0.0-beta.4",
9
+ "@ninetailed/experience.js-shared": "2.0.0-beta.40",
10
10
  "uuid": "^8.3.2",
11
11
  "ts-toolbelt": "^9.6.0",
12
12
  "locale-enum": "^1.1.1",
13
13
  "i18n-iso-countries": "^7.3.0",
14
- "lodash": "^4.17.21"
14
+ "lodash": "^4.17.21",
15
+ "loglevel": "^1.8.0",
16
+ "murmurhash-js": "^1.0.0"
15
17
  },
16
18
  "peerDependencies": {}
17
19
  }