@ninetailed/experience.js 1.8.1-beta.0 → 2.0.0-beta.10

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.
@@ -51,7 +51,7 @@ export declare class Ninetailed implements NinetailedInstance {
51
51
  private readonly instance;
52
52
  private readonly plugins;
53
53
  private _profileState;
54
- constructor({ clientId, environment }: {
54
+ constructor({ clientId, environment, }: {
55
55
  clientId: string;
56
56
  environment?: string;
57
57
  preview?: boolean;
@@ -0,0 +1 @@
1
+ export declare const EXPERIENCE_TRAIT_PREFIX = "nt_experiment_";
@@ -0,0 +1,8 @@
1
+ export * from './types';
2
+ export { selectBaselineWithVariants as selectExperienceBaselineWithVariants } from './selectBaselineWithVariants';
3
+ export { selectVariants as selectExperienceVariants } from './selectVariants';
4
+ export { selectHasVariants as selectHasExperienceVariants } from './selectHasVariants';
5
+ export { selectActiveExperiments } from './selectActiveExperiments';
6
+ export { selectEglibleExperiences } from './selectEglibleExperiences';
7
+ export { selectExperience } from './selectExperience';
8
+ export { selectVariant as selectExperienceVariant } from './selectVariant';
@@ -0,0 +1,3 @@
1
+ import { Profile } from '@ninetailed/experience.js-shared';
2
+ import { ExperienceConfiguration } from './types';
3
+ export declare const selectActiveExperiments: (experiments: ExperienceConfiguration[], profile: Profile) => ExperienceConfiguration[];
@@ -0,0 +1,2 @@
1
+ import { Baseline, BaselineWithVariants, ExperienceConfiguration } from './types';
2
+ export declare const selectBaselineWithVariants: (experience: ExperienceConfiguration, baseline: Baseline) => BaselineWithVariants | null;
@@ -0,0 +1,12 @@
1
+ import { ExperienceConfiguration } from './types';
2
+ declare type SelectEglibleExperiencesArgs = {
3
+ experiences: ExperienceConfiguration[];
4
+ activeExperiments: ExperienceConfiguration[];
5
+ };
6
+ /**
7
+ * We can use any personalization as eglible experience
8
+ * When going for an experiment we can only select a active experiment when 1 or more experiments are active
9
+ * If the profile is not in any active experiments, we can select any expermiment
10
+ */
11
+ export declare const selectEglibleExperiences: ({ experiences, activeExperiments, }: SelectEglibleExperiencesArgs) => ExperienceConfiguration[];
12
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Profile } from '@ninetailed/experience.js-shared';
2
+ import { ExperienceConfiguration } from './types';
3
+ declare type SelectExprienceArgs = {
4
+ experiences: ExperienceConfiguration[];
5
+ activeExperiments: ExperienceConfiguration[];
6
+ profile: Profile;
7
+ };
8
+ export declare const selectExperience: ({ experiences, activeExperiments, profile, }: SelectExprienceArgs) => ExperienceConfiguration | null;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Baseline, ExperienceConfiguration } from "./types";
2
+ export declare const selectHasVariants: (experience: ExperienceConfiguration, baseline: Baseline) => boolean;
@@ -0,0 +1,10 @@
1
+ import { Profile } from '@ninetailed/experience.js-shared';
2
+ import { Variant } from './types';
3
+ import { Baseline, ExperienceConfiguration } from './types';
4
+ declare type SelectVariantArgs = {
5
+ baseline: Baseline;
6
+ experience: ExperienceConfiguration;
7
+ profile: Profile;
8
+ };
9
+ export declare const selectVariant: ({ baseline, experience, profile, }: SelectVariantArgs) => Variant;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Baseline, Variant, ExperienceConfiguration } from './types';
2
+ export declare const selectVariants: (experience: ExperienceConfiguration, baseline: Baseline) => Variant[];
@@ -0,0 +1,3 @@
1
+ export declare type Baseline<P = unknown> = P & {
2
+ id: string;
3
+ };
@@ -0,0 +1,6 @@
1
+ import { Baseline } from './Baseline';
2
+ import { Variant } from './Variant';
3
+ export declare type BaselineWithVariants = {
4
+ baseline: Baseline<{}>;
5
+ variants: Variant<{}>[];
6
+ };
@@ -0,0 +1,5 @@
1
+ export declare type Distribution = {
2
+ index: number;
3
+ start: number;
4
+ end: number;
5
+ };
@@ -0,0 +1,13 @@
1
+ import { BaselineWithVariants } from './BaselineWithVariants';
2
+ import { Distribution } from './Distribution';
3
+ export declare type ExperienceType = 'nt_personalization' | 'nt_experiment';
4
+ export declare type ExperienceConfiguration = {
5
+ id: string;
6
+ type: ExperienceType;
7
+ audience?: {
8
+ id: string;
9
+ };
10
+ trafficAllocation: number;
11
+ distribution: Distribution[];
12
+ components: BaselineWithVariants[];
13
+ };
@@ -0,0 +1,4 @@
1
+ export declare type Variant<P = unknown> = P & {
2
+ id: string;
3
+ hidden: boolean;
4
+ };
@@ -0,0 +1,5 @@
1
+ export type { Baseline } from './Baseline';
2
+ export type { Variant } from './Variant';
3
+ export type { BaselineWithVariants } from './BaselineWithVariants';
4
+ export type { Distribution } from './Distribution';
5
+ export type { ExperienceConfiguration, ExperienceType, } from './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;
@@ -33,5 +33,5 @@ declare type Fail<T> = {
33
33
  declare type Result<T> = Loading<T> | Success<T> | Fail<T>;
34
34
  export declare const selectVariant: <T extends {
35
35
  id: string;
36
- }>(baseline: T, variants: Variant<T>[], { loading, profile, error }: ProfileState, options?: Options) => Result<T>;
36
+ }>(baseline: T, variants: Variant<T>[], { status, profile, error }: ProfileState, options?: Options) => Result<T>;
37
37
  export {};
package/lib/types.d.ts CHANGED
@@ -1,7 +1,20 @@
1
- import { Profile } from "@ninetailed/experience.js-shared";
1
+ import { Profile } from '@ninetailed/experience.js-shared';
2
+ declare type Loading = {
3
+ status: 'loading';
4
+ profile: null;
5
+ error: null;
6
+ };
7
+ declare type Success = {
8
+ status: 'success';
9
+ profile: Profile;
10
+ error: null;
11
+ };
12
+ declare type Fail = {
13
+ status: 'error';
14
+ profile: null;
15
+ error: Error;
16
+ };
2
17
  export declare type ProfileState = {
3
- loading: boolean;
4
- profile?: Profile;
5
- error?: Error;
6
18
  from: 'api' | 'hydrated';
7
- };
19
+ } & (Loading | Success | Fail);
20
+ export {};
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "1.8.1-beta.0",
3
+ "version": "2.0.0-beta.10",
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": "1.8.1-beta.0",
9
+ "@ninetailed/experience.js-shared": "2.0.0-beta.10",
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
+ "murmurhash-js": "^1.0.0"
15
16
  },
16
17
  "peerDependencies": {}
17
18
  }