@ninetailed/experience.js-react 3.0.0-beta.33 → 3.0.0-beta.37

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.cjs CHANGED
@@ -2472,10 +2472,16 @@ const TrackExperience = ({
2472
2472
  experience,
2473
2473
  profile
2474
2474
  });
2475
- ninetailed.trackExperience({
2476
- experience,
2477
- component: variant,
2478
- variant: distribution.index
2475
+ ninetailed.trackHasSeenExperience({
2476
+ experience: {
2477
+ id: experience.id,
2478
+ type: experience.type,
2479
+ name: '',
2480
+ description: ''
2481
+ },
2482
+ audience: experience.audience,
2483
+ selectedVariant: variant,
2484
+ selectedVariantIndex: distribution.index
2479
2485
  });
2480
2486
  }
2481
2487
  }, [inView]);
@@ -2798,7 +2804,7 @@ const Experience = _a => {
2798
2804
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2799
2805
  profile: profile
2800
2806
  }, {
2801
- children: (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, variant, {
2807
+ children: 'hidden' in variant && variant.hidden ? null : /*#__PURE__*/React.createElement(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2802
2808
  key: `${experience.id}-${variant.id}`,
2803
2809
  ninetailed: {
2804
2810
  isPersonalized,
@@ -2899,10 +2905,15 @@ exports.DefaultExperienceLoadingComponent = DefaultExperienceLoadingComponent;
2899
2905
  exports.ESRLoadingComponent = ESRLoadingComponent;
2900
2906
  exports.ESRProvider = ESRProvider;
2901
2907
  exports.Experience = Experience;
2908
+ exports.ExperimentsProvider = ExperimentsProvider;
2902
2909
  exports.MergeTag = MergeTag;
2903
2910
  exports.NinetailedProvider = NinetailedProvider;
2904
2911
  exports.Personalize = Personalize;
2912
+ exports.TrackExperience = TrackExperience;
2905
2913
  exports.TrackHasSeenComponent = TrackHasSeenComponent;
2914
+ exports.useExperience = useExperience;
2915
+ exports.useExperiments = useExperiments;
2916
+ exports.useJoinExperiment = useJoinExperiment;
2906
2917
  exports.useNinetailed = useNinetailed;
2907
2918
  exports.usePersonalize = usePersonalize;
2908
2919
  exports.useProfile = useProfile;
package/index.js CHANGED
@@ -2461,10 +2461,16 @@ const TrackExperience = ({
2461
2461
  experience,
2462
2462
  profile
2463
2463
  });
2464
- ninetailed.trackExperience({
2465
- experience,
2466
- component: variant,
2467
- variant: distribution.index
2464
+ ninetailed.trackHasSeenExperience({
2465
+ experience: {
2466
+ id: experience.id,
2467
+ type: experience.type,
2468
+ name: '',
2469
+ description: ''
2470
+ },
2471
+ audience: experience.audience,
2472
+ selectedVariant: variant,
2473
+ selectedVariantIndex: distribution.index
2468
2474
  });
2469
2475
  }
2470
2476
  }, [inView]);
@@ -2787,7 +2793,7 @@ const Experience = _a => {
2787
2793
  // the profile is definitely defined, otherwise there wouldn't be an experience selected
2788
2794
  profile: profile
2789
2795
  }, {
2790
- children: (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/createElement$1(Component, Object.assign({}, passthroughProps, variant, {
2796
+ children: 'hidden' in variant && variant.hidden ? null : /*#__PURE__*/createElement$1(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
2791
2797
  key: `${experience.id}-${variant.id}`,
2792
2798
  ninetailed: {
2793
2799
  isPersonalized,
@@ -2884,4 +2890,4 @@ const ESRLoadingComponent = _a => {
2884
2890
  }));
2885
2891
  };
2886
2892
 
2887
- export { DefaultExperienceLoadingComponent, ESRLoadingComponent, ESRProvider, Experience, MergeTag, NinetailedProvider, Personalize, TrackHasSeenComponent, useNinetailed, usePersonalize, useProfile };
2893
+ export { DefaultExperienceLoadingComponent, ESRLoadingComponent, ESRProvider, Experience, ExperimentsProvider, MergeTag, NinetailedProvider, Personalize, TrackExperience, TrackHasSeenComponent, useExperience, useExperiments, useJoinExperiment, useNinetailed, usePersonalize, useProfile };
@@ -1,5 +1,6 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
2
  import { ExperienceBaseProps } from './Experience';
3
+ import { Reference } from '@ninetailed/experience.js';
3
4
  declare type ESRContextValue = {
4
5
  experienceVariantsMap: Record<string, number>;
5
6
  };
@@ -11,5 +12,5 @@ export declare const ESRProvider: React.FC<PropsWithChildren<ESRProviderProps>>;
11
12
  export declare const useESR: () => {
12
13
  experienceVariantsMap: Record<string, number>;
13
14
  };
14
- export declare const ESRLoadingComponent: <P extends Record<string, unknown>>({ experiences, component: Component, passthroughProps, ...baseline }: ExperienceBaseProps<P, Partial<P>>) => JSX.Element;
15
+ export declare const ESRLoadingComponent: <P extends Record<string, unknown> & Reference>({ experiences, component: Component, passthroughProps, ...baseline }: ExperienceBaseProps<P, Partial<P>, Pick<P, Exclude<keyof P, keyof P>> & Reference>) => JSX.Element;
15
16
  export {};
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Baseline, ExperienceConfiguration } from '@ninetailed/experience.js';
2
+ import { Baseline, ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
3
3
  export declare type ExperienceComponent<P> = React.ComponentType<Omit<P, 'id'> & {
4
4
  ninetailed?: {
5
5
  isPersonalized: boolean;
@@ -8,20 +8,20 @@ export declare type ExperienceComponent<P> = React.ComponentType<Omit<P, 'id'> &
8
8
  };
9
9
  };
10
10
  }>;
11
- export declare type ExperienceBaseProps<P, PassThroughProps extends Partial<P>> = Baseline<Pick<P, Exclude<keyof P, keyof PassThroughProps>>> & {
12
- experiences: ExperienceConfiguration[];
13
- component: ExperienceComponent<P> | React.ComponentType<P>;
11
+ export declare type ExperienceBaseProps<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = Baseline<Pick<P, Exclude<keyof P, keyof PassThroughProps>>> & {
12
+ experiences: ExperienceConfiguration<Variant>[];
13
+ component: React.ComponentType<P>;
14
14
  passthroughProps?: PassThroughProps;
15
15
  };
16
- export declare type ExperienceLoadingComponent<P, PassThroughProps extends Partial<P>> = React.ComponentType<ExperienceBaseProps<P, PassThroughProps>>;
17
- export declare type ExperienceProps<P, PassThroughProps extends Partial<P>> = ExperienceBaseProps<P, PassThroughProps> & {
18
- experiences: ExperienceConfiguration[];
19
- component: ExperienceComponent<P> | React.ComponentType<P>;
20
- loadingComponent?: ExperienceLoadingComponent<P, PassThroughProps>;
16
+ export declare type ExperienceLoadingComponent<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = React.ComponentType<ExperienceBaseProps<P, PassThroughProps, Variant>>;
17
+ export declare type ExperienceProps<P, PassThroughProps extends Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference> = ExperienceBaseProps<P, PassThroughProps, Variant> & {
18
+ experiences: ExperienceConfiguration<Variant>[];
19
+ component: React.ComponentType<P>;
20
+ loadingComponent?: ExperienceLoadingComponent<P, PassThroughProps, Variant>;
21
21
  };
22
- declare type DefaultExperienceLoadingComponentProps = ExperienceBaseProps<Record<string, unknown>, Record<string, unknown>> & {
22
+ declare type DefaultExperienceLoadingComponentProps = ExperienceBaseProps<Record<string, unknown>, Record<string, unknown>, Record<string, unknown> & Reference> & {
23
23
  unhideAfterMs?: number;
24
24
  };
25
25
  export declare const DefaultExperienceLoadingComponent: React.FC<DefaultExperienceLoadingComponentProps>;
26
- export declare const Experience: <P extends Record<string, unknown>, PassThroughProps extends Partial<P> = Partial<P>>({ experiences, component: Component, loadingComponent: LoadingComponent, passthroughProps, ...baseline }: ExperienceProps<P, PassThroughProps>) => JSX.Element;
26
+ export declare const Experience: <P, PassThroughProps extends Partial<P> = Partial<P>, Variant extends Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference = Pick<P, Exclude<keyof P, keyof PassThroughProps>> & Reference>({ experiences, component: Component, loadingComponent: LoadingComponent, passthroughProps, ...baseline }: ExperienceProps<P, PassThroughProps, Variant>) => JSX.Element;
27
27
  export {};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import { ExperienceConfiguration } from '@ninetailed/experience.js';
3
- declare type ExperimentsContextValue = {
4
- experiments: ExperienceConfiguration[];
2
+ import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
3
+ declare type ExperimentsContextValue<Variant extends Reference> = {
4
+ experiments: ExperienceConfiguration<Variant>[];
5
5
  };
6
- export declare const ExperimentsContext: import("react").Context<ExperimentsContextValue | undefined>;
6
+ export declare const ExperimentsContext: import("react").Context<ExperimentsContextValue<any> | undefined>;
7
7
  export {};
@@ -1,7 +1,7 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- import { ExperienceConfiguration } from '@ninetailed/experience.js';
3
- declare type ExperimentsProviderProps = {
4
- experiments: ExperienceConfiguration[];
5
- };
6
- export declare const ExperimentsProvider: React.FC<PropsWithChildren<ExperimentsProviderProps>>;
2
+ import { ExperienceConfiguration, Reference } from '@ninetailed/experience.js';
3
+ declare type ExperimentsProviderProps<Variant extends Reference> = React.PropsWithChildren<{
4
+ experiments: ExperienceConfiguration<Variant>[];
5
+ }>;
6
+ export declare const ExperimentsProvider: <Variant extends Reference>({ experiments, children, }: React.PropsWithChildren<ExperimentsProviderProps<Variant>>) => JSX.Element;
7
7
  export {};
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Profile } from '@ninetailed/experience.js-shared';
3
3
  import { ExperienceConfiguration } from '@ninetailed/experience.js';
4
4
  declare type TrackExperienceProps = {
5
- experience: ExperienceConfiguration;
5
+ experience: ExperienceConfiguration<any>;
6
6
  variant: {
7
7
  id: string;
8
8
  };
@@ -1,3 +1,8 @@
1
1
  export { Experience, DefaultExperienceLoadingComponent } from './Experience';
2
2
  export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
3
3
  export { ESRProvider, ESRLoadingComponent } from './ESRLoadingComponent';
4
+ export { useExperience } from './useExperience';
5
+ export { ExperimentsProvider } from './ExperimentsProvider';
6
+ export { useExperiments } from './useExperiments';
7
+ export { useJoinExperiment } from './useJoinExperiment';
8
+ export { TrackExperience } from './TrackExperience';
@@ -1,4 +1,3 @@
1
1
  export declare type Variant<P> = P & {
2
2
  id: string;
3
- hidden: boolean;
4
3
  };
@@ -1,4 +1,4 @@
1
- import { Baseline, Variant, ExperienceConfiguration, Profile } from '@ninetailed/experience.js';
1
+ import { Baseline, ExperienceConfiguration, Profile, Reference, VariantRef } from '@ninetailed/experience.js';
2
2
  declare type Load = {
3
3
  status: 'loading';
4
4
  loading: boolean;
@@ -11,12 +11,12 @@ declare type Load = {
11
11
  profile: null;
12
12
  error: null;
13
13
  };
14
- declare type Success = {
14
+ declare type Success<Variant extends Reference> = {
15
15
  status: 'success';
16
16
  loading: boolean;
17
17
  hasVariants: boolean;
18
18
  baseline: Baseline;
19
- experience: ExperienceConfiguration | null;
19
+ experience: ExperienceConfiguration<Variant> | null;
20
20
  variant: Variant | null;
21
21
  audience: {
22
22
  id: string;
@@ -37,10 +37,10 @@ declare type Fail = {
37
37
  profile: null;
38
38
  error: Error;
39
39
  };
40
- declare type UseExperienceArgs = {
40
+ declare type UseExperienceArgs<Variant extends Reference> = {
41
41
  baseline: Baseline;
42
- experiences: ExperienceConfiguration[];
42
+ experiences: ExperienceConfiguration<Variant>[];
43
43
  };
44
- declare type UseExperienceResponse = Load | Success | Fail;
45
- export declare const useExperience: ({ baseline, experiences, }: UseExperienceArgs) => UseExperienceResponse;
44
+ declare type UseExperienceResponse<Variant extends Reference> = Load | Success<Variant | VariantRef> | Fail;
45
+ export declare const useExperience: <Variant extends Reference>({ baseline, experiences, }: UseExperienceArgs<Variant>) => UseExperienceResponse<Variant>;
46
46
  export {};
@@ -1,10 +1,10 @@
1
- import { Profile, ExperienceConfiguration } from '@ninetailed/experience.js';
2
- declare type UseJoinExperimentArgs = {
3
- experiences: ExperienceConfiguration[];
1
+ import { Profile, ExperienceConfiguration, Reference, VariantRef } from '@ninetailed/experience.js';
2
+ declare type UseJoinExperimentArgs<Variant extends Reference> = {
3
+ experiences: ExperienceConfiguration<Variant>[];
4
4
  };
5
- declare type JoinExperimentArgs = {
6
- experiment: ExperienceConfiguration;
5
+ declare type JoinExperimentArgs<Variant extends Reference> = {
6
+ experiment: ExperienceConfiguration<Variant | VariantRef>;
7
7
  profile: Profile;
8
8
  };
9
- export declare const useJoinExperiment: ({ experiences }: UseJoinExperimentArgs) => ({ experiment, profile }: JoinExperimentArgs) => void;
9
+ export declare const useJoinExperiment: <Variant extends Reference>({ experiences, }: UseJoinExperimentArgs<Variant>) => ({ experiment, profile }: JoinExperimentArgs<Variant>) => void;
10
10
  export {};
@@ -5,7 +5,7 @@ import { Profile, Locale, OnErrorHandler, OnLogHandler } from '@ninetailed/exper
5
5
  export declare type NinetailedProviderProps = {
6
6
  clientId: string;
7
7
  environment?: string;
8
- experiments?: ExperienceConfiguration[];
8
+ experiments?: ExperienceConfiguration<any>[];
9
9
  preview?: boolean;
10
10
  url?: string;
11
11
  plugins?: (AnalyticsPlugin | AnalyticsPlugin[])[];
@@ -15,4 +15,4 @@ export declare type NinetailedProviderProps = {
15
15
  onLog?: OnLogHandler;
16
16
  onError?: OnErrorHandler;
17
17
  };
18
- export declare const NinetailedProvider: React.FC<React.PropsWithChildren<NinetailedProviderProps>>;
18
+ export declare const NinetailedProvider: ({ children, clientId, experiments, environment, preview, url, profile, locale, requestTimeout, plugins, onLog, onError, }: React.PropsWithChildren<NinetailedProviderProps>) => JSX.Element;
package/lib/index.d.ts CHANGED
@@ -9,5 +9,5 @@ export { Personalize } from './Personalize';
9
9
  export type { PersonalizedComponent } from './Personalize';
10
10
  export { MergeTag } from './MergeTag';
11
11
  export { TrackHasSeenComponent } from './TrackHasSeenComponent';
12
- export { Experience, ESRProvider, ESRLoadingComponent, DefaultExperienceLoadingComponent, } from './Experience';
12
+ export { ExperimentsProvider, Experience, ESRProvider, ESRLoadingComponent, DefaultExperienceLoadingComponent, TrackExperience, useExperience, useExperiments, useJoinExperiment, } from './Experience';
13
13
  export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
@@ -12,7 +12,7 @@ export declare const useProfile: () => {
12
12
  id: string;
13
13
  random: number;
14
14
  audiences: string[];
15
- traits: import("@ninetailed/experience.js-shared").Traits;
15
+ traits: import("@ninetailed/experience.js-shared").Properties;
16
16
  location: {
17
17
  coordinates?: {
18
18
  latitude: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "3.0.0-beta.33",
3
+ "version": "3.0.0-beta.37",
4
4
  "peerDependencies": {
5
5
  "react": ">=16.8.0"
6
6
  },
@@ -8,9 +8,9 @@
8
8
  "@analytics/google-analytics": "0.5.3",
9
9
  "react-visibility-sensor": "5.1.1",
10
10
  "lodash": "4.17.21",
11
- "@ninetailed/experience.js": "3.0.0-beta.33",
11
+ "@ninetailed/experience.js": "3.0.0-beta.37",
12
12
  "react-intersection-observer": "8.34.0",
13
- "@ninetailed/experience.js-shared": "3.0.0-beta.33",
13
+ "@ninetailed/experience.js-shared": "3.0.0-beta.37",
14
14
  "analytics": "0.8.1"
15
15
  },
16
16
  "module": "./index.js",