@ninetailed/experience.js-react 2.0.0-beta.2 → 2.0.0-beta.23

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 CHANGED
@@ -2490,7 +2490,7 @@ const useExperience = ({
2490
2490
  error: null,
2491
2491
  experience,
2492
2492
  variant: null,
2493
- audience,
2493
+ audience: audience ? audience : null,
2494
2494
  profile,
2495
2495
  isPersonalized: false
2496
2496
  });
@@ -2502,7 +2502,7 @@ const useExperience = ({
2502
2502
  error: null,
2503
2503
  experience,
2504
2504
  variant,
2505
- audience,
2505
+ audience: audience ? audience : null,
2506
2506
  profile,
2507
2507
  isPersonalized: true
2508
2508
  });
@@ -2515,7 +2515,8 @@ const useJoinExperiment = ({
2515
2515
  }) => {
2516
2516
  const {
2517
2517
  identify
2518
- } = useNinetailed();
2518
+ } = useNinetailed(); // TODO this gets called twice
2519
+
2519
2520
  return useCallback(({
2520
2521
  experiment,
2521
2522
  profile
@@ -2523,7 +2524,7 @@ const useJoinExperiment = ({
2523
2524
  const activeExperiments = selectActiveExperiments(experiences, profile);
2524
2525
 
2525
2526
  if (!activeExperiments.length && experiment.type === 'nt_experiment') {
2526
- identify('', {
2527
+ identify(profile.id, {
2527
2528
  [`${EXPERIENCE_TRAIT_PREFIX}${experiment.id}`]: true
2528
2529
  });
2529
2530
  }
@@ -2586,7 +2587,7 @@ const Experience = _a => {
2586
2587
  })));
2587
2588
  }
2588
2589
 
2589
- if (!experience) {
2590
+ if (!experience || !variant) {
2590
2591
  return /*#__PURE__*/React.createElement(TrackHasSeenComponent, {
2591
2592
  variant: {
2592
2593
  id: baseline.id,
@@ -2615,17 +2616,17 @@ const Experience = _a => {
2615
2616
  // TODO this needs to be resolved when we move away from the old standard
2616
2617
  React.createElement(TrackHasSeenComponent, {
2617
2618
  variant: {
2618
- id: (variant === null || variant === void 0 ? void 0 : variant.id) || baseline.id,
2619
+ id: variant.id,
2619
2620
  audience: {
2620
2621
  id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2621
2622
  },
2622
- hidden: (variant === null || variant === void 0 ? void 0 : variant.hidden) || false
2623
+ hidden: variant.hidden || false
2623
2624
  },
2624
2625
  audience: {
2625
2626
  id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2626
2627
  },
2627
2628
  isPersonalized: isPersonalized
2628
- }, /*#__PURE__*/React.createElement(Component, Object.assign({}, variant, {
2629
+ }, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React.createElement(Component, Object.assign({}, variant, {
2629
2630
  key: `${experience.id}-${variant.id}`,
2630
2631
  ninetailed: {
2631
2632
  isPersonalized,
package/index.umd.js CHANGED
@@ -2041,7 +2041,7 @@
2041
2041
  error: null,
2042
2042
  experience: experience,
2043
2043
  variant: null,
2044
- audience: audience,
2044
+ audience: audience ? audience : null,
2045
2045
  profile: profile,
2046
2046
  isPersonalized: false
2047
2047
  });
@@ -2053,7 +2053,7 @@
2053
2053
  error: null,
2054
2054
  experience: experience,
2055
2055
  variant: variant,
2056
- audience: audience,
2056
+ audience: audience ? audience : null,
2057
2057
  profile: profile,
2058
2058
  isPersonalized: true
2059
2059
  });
@@ -2063,7 +2063,8 @@
2063
2063
 
2064
2064
  var useJoinExperiment = function useJoinExperiment(_a) {
2065
2065
  var experiences = _a.experiences;
2066
- var identify = useNinetailed().identify;
2066
+ var identify = useNinetailed().identify; // TODO this gets called twice
2067
+
2067
2068
  return React.useCallback(function (_a) {
2068
2069
  var _b;
2069
2070
 
@@ -2072,7 +2073,7 @@
2072
2073
  var activeExperiments = experience_js.selectActiveExperiments(experiences, profile);
2073
2074
 
2074
2075
  if (!activeExperiments.length && experiment.type === 'nt_experiment') {
2075
- identify('', (_b = {}, _b["".concat(EXPERIENCE_TRAIT_PREFIX).concat(experiment.id)] = true, _b));
2076
+ identify(profile.id, (_b = {}, _b["".concat(EXPERIENCE_TRAIT_PREFIX).concat(experiment.id)] = true, _b));
2076
2077
  }
2077
2078
  }, [experiences]);
2078
2079
  };
@@ -2131,7 +2132,7 @@
2131
2132
  })));
2132
2133
  }
2133
2134
 
2134
- if (!experience) {
2135
+ if (!experience || !variant) {
2135
2136
  return /*#__PURE__*/React__default["default"].createElement(TrackHasSeenComponent, {
2136
2137
  variant: {
2137
2138
  id: baseline.id,
@@ -2160,17 +2161,17 @@
2160
2161
  // TODO this needs to be resolved when we move away from the old standard
2161
2162
  React__default["default"].createElement(TrackHasSeenComponent, {
2162
2163
  variant: {
2163
- id: (variant === null || variant === void 0 ? void 0 : variant.id) || baseline.id,
2164
+ id: variant.id,
2164
2165
  audience: {
2165
2166
  id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2166
2167
  },
2167
- hidden: (variant === null || variant === void 0 ? void 0 : variant.hidden) || false
2168
+ hidden: variant.hidden || false
2168
2169
  },
2169
2170
  audience: {
2170
2171
  id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2171
2172
  },
2172
2173
  isPersonalized: isPersonalized
2173
- }, /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, variant, {
2174
+ }, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, variant, {
2174
2175
  key: "".concat(experience.id, "-").concat(variant.id),
2175
2176
  ninetailed: {
2176
2177
  isPersonalized: isPersonalized,
@@ -1,5 +1,5 @@
1
- import { ExperienceConfiguration } from './types';
2
1
  import { Profile } from '@ninetailed/experience.js';
2
+ import { ExperienceConfiguration } from './types';
3
3
  declare type UseJoinExperimentArgs = {
4
4
  experiences: ExperienceConfiguration[];
5
5
  };
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export type { Profile, Variant } from '@ninetailed/experience.js-shared';
2
+ export type { ExperienceConfiguration, ExperienceType, } from '@ninetailed/experience.js';
2
3
  export { NinetailedProvider } from './NinetailedProvider';
3
4
  export type { NinetailedProviderProps } from './NinetailedProvider';
4
5
  export { useNinetailed } from './useNinetailed';
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.23",
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
- "@ninetailed/experience.js": "2.0.0-beta.2",
10
+ "@ninetailed/experience.js": "2.0.0-beta.23",
11
11
  "analytics": "^0.8.0",
12
- "@ninetailed/experience.js-shared": "2.0.0-beta.2",
12
+ "@ninetailed/experience.js-shared": "2.0.0-beta.23",
13
13
  "uuid": "^8.3.2",
14
14
  "ts-toolbelt": "^9.6.0",
15
15
  "locale-enum": "^1.1.1",
16
16
  "i18n-iso-countries": "^7.3.0",
17
17
  "lodash": "^4.17.21",
18
+ "loglevel": "^1.8.0",
19
+ "murmurhash-js": "^1.0.0",
18
20
  "react-intersection-observer": "^8.33.1"
19
21
  },
20
22
  "main": "./index.umd.js",
@@ -1,9 +0,0 @@
1
- export declare const useSelectActiveExperiments: () => {
2
- loading: boolean;
3
- experiments: never[];
4
- error: Error;
5
- } | {
6
- loading: boolean;
7
- experiments: ExperienceConfiguration[];
8
- error: undefined;
9
- };
@@ -1,10 +0,0 @@
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
- };
@@ -1,22 +0,0 @@
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 {};