@ninetailed/experience.js-react 1.8.1 → 2.0.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.esm.js +493 -171
- package/index.umd.js +472 -154
- package/lib/Experience/Experience.d.ts +19 -0
- package/lib/Experience/ExperimentsContext.d.ts +6 -0
- package/lib/Experience/ExperimentsProvider.d.ts +7 -0
- package/lib/Experience/constants.d.ts +1 -0
- package/lib/Experience/index.d.ts +1 -0
- package/lib/Experience/types/Baseline.d.ts +3 -0
- package/lib/Experience/types/BaselineWithVariants.d.ts +6 -0
- package/lib/Experience/types/Variant.d.ts +4 -0
- package/lib/Experience/types/index.d.ts +4 -0
- package/lib/Experience/useExperience.d.ts +46 -0
- package/lib/Experience/useExperiments.d.ts +3 -0
- package/lib/Experience/useJoinExperiment.d.ts +11 -0
- package/lib/Experience/useSelectActiveExperiments.d.ts +9 -0
- package/lib/Experience/useSelectExperience.d.ts +10 -0
- package/lib/Experience/useSelectVariant.d.ts +22 -0
- package/lib/NinetailedProvider.d.ts +2 -0
- package/lib/TrackHasSeenComponent.d.ts +1 -1
- package/lib/Variant.d.ts +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/useProfile.d.ts +19 -2
- package/package.json +4 -4
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Baseline, ExperienceConfiguration } from '@ninetailed/experience.js';
|
|
3
|
+
declare type ExperienceComponent<P extends Baseline> = React.ComponentType<Omit<P, 'id'> & {
|
|
4
|
+
ninetailed?: {
|
|
5
|
+
isPersonalized: boolean;
|
|
6
|
+
audience: {
|
|
7
|
+
id: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
declare type ExperienceProps<P extends Baseline> = P & {
|
|
12
|
+
experiences: ExperienceConfiguration[];
|
|
13
|
+
component: ExperienceComponent<P> | React.ComponentType<P>;
|
|
14
|
+
loadingComponent?: React.ComponentType;
|
|
15
|
+
};
|
|
16
|
+
export declare const Experience: <P extends {
|
|
17
|
+
id: string;
|
|
18
|
+
}>({ experiences, component: Component, loadingComponent: LoadingComponent, ...baseline }: ExperienceProps<P>) => JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EXPERIENCE_TRAIT_PREFIX = "nt_experiment_";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Experience } from './Experience';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Baseline, Variant, ExperienceConfiguration, Profile } from '@ninetailed/experience.js';
|
|
2
|
+
declare type Load = {
|
|
3
|
+
status: 'loading';
|
|
4
|
+
loading: boolean;
|
|
5
|
+
hasVariants: boolean;
|
|
6
|
+
baseline: Baseline;
|
|
7
|
+
experience: null;
|
|
8
|
+
variant: null;
|
|
9
|
+
audience: null;
|
|
10
|
+
isPersonalized: boolean;
|
|
11
|
+
profile: null;
|
|
12
|
+
error: null;
|
|
13
|
+
};
|
|
14
|
+
declare type Success = {
|
|
15
|
+
status: 'success';
|
|
16
|
+
loading: boolean;
|
|
17
|
+
hasVariants: boolean;
|
|
18
|
+
baseline: Baseline;
|
|
19
|
+
experience: ExperienceConfiguration | null;
|
|
20
|
+
variant: Variant | null;
|
|
21
|
+
audience: {
|
|
22
|
+
id: string;
|
|
23
|
+
} | null;
|
|
24
|
+
isPersonalized: boolean;
|
|
25
|
+
profile: Profile;
|
|
26
|
+
error: null;
|
|
27
|
+
};
|
|
28
|
+
declare type Fail = {
|
|
29
|
+
status: 'error';
|
|
30
|
+
loading: boolean;
|
|
31
|
+
hasVariants: boolean;
|
|
32
|
+
baseline: Baseline;
|
|
33
|
+
experience: null;
|
|
34
|
+
variant: null;
|
|
35
|
+
audience: null;
|
|
36
|
+
isPersonalized: boolean;
|
|
37
|
+
profile: null;
|
|
38
|
+
error: Error;
|
|
39
|
+
};
|
|
40
|
+
declare type UseExperienceArgs = {
|
|
41
|
+
baseline: Baseline;
|
|
42
|
+
experiences: ExperienceConfiguration[];
|
|
43
|
+
};
|
|
44
|
+
declare type UseExperienceResponse = Load | Success | Fail;
|
|
45
|
+
export declare const useExperience: ({ baseline, experiences, }: UseExperienceArgs) => UseExperienceResponse;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExperienceConfiguration } from './types';
|
|
2
|
+
import { Profile } from '@ninetailed/experience.js';
|
|
3
|
+
declare type UseJoinExperimentArgs = {
|
|
4
|
+
experiences: ExperienceConfiguration[];
|
|
5
|
+
};
|
|
6
|
+
declare type JoinExperimentArgs = {
|
|
7
|
+
experiment: ExperienceConfiguration;
|
|
8
|
+
profile: Profile;
|
|
9
|
+
};
|
|
10
|
+
export declare const useJoinExperiment: ({ experiences }: UseJoinExperimentArgs) => ({ experiment, profile }: JoinExperimentArgs) => void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExperienceConfiguration } from './types';
|
|
2
|
+
export declare const useSelectExperience: (experiences: ExperienceConfiguration[]) => {
|
|
3
|
+
loading: boolean;
|
|
4
|
+
experience: undefined;
|
|
5
|
+
error: Error;
|
|
6
|
+
} | {
|
|
7
|
+
loading: boolean;
|
|
8
|
+
experience: any;
|
|
9
|
+
error: undefined;
|
|
10
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Baseline, ExperienceConfiguration, Variant } from './types';
|
|
2
|
+
declare type Loading<T> = {
|
|
3
|
+
loading: true;
|
|
4
|
+
variant?: never;
|
|
5
|
+
experience?: never;
|
|
6
|
+
error: null;
|
|
7
|
+
};
|
|
8
|
+
declare type Success<T> = {
|
|
9
|
+
loading: false;
|
|
10
|
+
variant: Variant<T>;
|
|
11
|
+
experience: ExperienceConfiguration | undefined;
|
|
12
|
+
error: null;
|
|
13
|
+
};
|
|
14
|
+
declare type Fail<T> = {
|
|
15
|
+
loading: false;
|
|
16
|
+
variant?: never;
|
|
17
|
+
experience?: never;
|
|
18
|
+
error: Error;
|
|
19
|
+
};
|
|
20
|
+
declare type SelectVariantResult<T> = Loading<T> | Success<T> | Fail<T>;
|
|
21
|
+
export declare const useSelectVariant: <T extends Baseline<Object>>(experiences: ExperienceConfiguration[], baseline: T) => SelectVariantResult<T>;
|
|
22
|
+
export {};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnalyticsPlugin } from 'analytics';
|
|
3
3
|
import { Profile, Locale } from '@ninetailed/experience.js-shared';
|
|
4
|
+
import { ExperienceConfiguration } from './Experience/types';
|
|
4
5
|
export declare type NinetailedProviderProps = {
|
|
5
6
|
clientId: string;
|
|
6
7
|
environment?: string;
|
|
8
|
+
experiments?: ExperienceConfiguration[];
|
|
7
9
|
preview?: boolean;
|
|
8
10
|
url?: string;
|
|
9
11
|
plugins?: (AnalyticsPlugin | AnalyticsPlugin[])[];
|
package/lib/Variant.d.ts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/useProfile.d.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const useProfile: () => {
|
|
2
|
+
loading: boolean;
|
|
3
|
+
from: "api" | "hydrated";
|
|
4
|
+
status: "loading";
|
|
5
|
+
profile: null;
|
|
6
|
+
error: null;
|
|
7
|
+
} | {
|
|
8
|
+
loading: boolean;
|
|
9
|
+
from: "api" | "hydrated";
|
|
10
|
+
status: "success";
|
|
11
|
+
profile: import("@ninetailed/experience.js").Profile;
|
|
12
|
+
error: null;
|
|
13
|
+
} | {
|
|
14
|
+
loading: boolean;
|
|
15
|
+
from: "api" | "hydrated";
|
|
16
|
+
status: "error";
|
|
17
|
+
profile: null;
|
|
18
|
+
error: Error;
|
|
19
|
+
};
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=16.8.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@analytics/google-analytics": "0.5.3",
|
|
9
9
|
"react-visibility-sensor": "5.1.1",
|
|
10
|
-
"
|
|
11
|
-
"@ninetailed/experience.js": "1.8.1",
|
|
10
|
+
"@ninetailed/experience.js": "2.0.0-beta.2",
|
|
12
11
|
"analytics": "^0.8.0",
|
|
13
|
-
"@ninetailed/experience.js-shared": "
|
|
12
|
+
"@ninetailed/experience.js-shared": "2.0.0-beta.2",
|
|
14
13
|
"uuid": "^8.3.2",
|
|
15
14
|
"ts-toolbelt": "^9.6.0",
|
|
16
15
|
"locale-enum": "^1.1.1",
|
|
17
16
|
"i18n-iso-countries": "^7.3.0",
|
|
17
|
+
"lodash": "^4.17.21",
|
|
18
18
|
"react-intersection-observer": "^8.33.1"
|
|
19
19
|
},
|
|
20
20
|
"main": "./index.umd.js",
|