@ninetailed/experience.js-react 2.0.0-beta.4 → 2.0.0-beta.42

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
@@ -1,8 +1,9 @@
1
1
  import React, { createContext, useMemo, useContext, useState, useEffect, useCallback } from 'react';
2
- import { Ninetailed, selectVariant, selectHasExperienceVariants, selectActiveExperiments, selectExperience, selectExperienceVariant } from '@ninetailed/experience.js';
2
+ import { Ninetailed, selectVariant, selectDistribution, selectHasExperienceVariants, selectActiveExperiments, selectExperience, selectExperienceVariant } from '@ninetailed/experience.js';
3
3
  import { useInView } from 'react-intersection-observer';
4
4
  import { isBrowser } from '@ninetailed/experience.js-shared';
5
5
  import get$1 from 'lodash/get';
6
+ import has$1 from 'lodash/has';
6
7
 
7
8
  const NinetailedContext = /*#__PURE__*/createContext(undefined);
8
9
 
@@ -2333,6 +2334,37 @@ const MergeTag = ({
2333
2334
  return /*#__PURE__*/React.createElement(React.Fragment, null, value);
2334
2335
  };
2335
2336
 
2337
+ const TrackExperience = ({
2338
+ children,
2339
+ experience,
2340
+ variant,
2341
+ profile
2342
+ }) => {
2343
+ const ninetailed = useNinetailed();
2344
+ const {
2345
+ ref,
2346
+ inView
2347
+ } = useInView({
2348
+ triggerOnce: true
2349
+ });
2350
+ useEffect(() => {
2351
+ if (isBrowser() && inView) {
2352
+ const distribution = selectDistribution({
2353
+ experience,
2354
+ profile
2355
+ });
2356
+ ninetailed.trackExperience({
2357
+ experience,
2358
+ component: variant,
2359
+ variant: distribution.index
2360
+ });
2361
+ }
2362
+ }, [inView]);
2363
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
2364
+ ref: ref
2365
+ }), children);
2366
+ };
2367
+
2336
2368
  var global$2 = global$w;
2337
2369
  var aCallable = aCallable$2;
2338
2370
  var toObject = toObject$5;
@@ -2515,7 +2547,8 @@ const useJoinExperiment = ({
2515
2547
  }) => {
2516
2548
  const {
2517
2549
  identify
2518
- } = useNinetailed();
2550
+ } = useNinetailed(); // TODO this gets called twice
2551
+
2519
2552
  return useCallback(({
2520
2553
  experiment,
2521
2554
  profile
@@ -2523,7 +2556,7 @@ const useJoinExperiment = ({
2523
2556
  const activeExperiments = selectActiveExperiments(experiences, profile);
2524
2557
 
2525
2558
  if (!activeExperiments.length && experiment.type === 'nt_experiment') {
2526
- identify('', {
2559
+ identify(profile.id, {
2527
2560
  [`${EXPERIENCE_TRAIT_PREFIX}${experiment.id}`]: true
2528
2561
  });
2529
2562
  }
@@ -2568,7 +2601,10 @@ const Experience = _a => {
2568
2601
 
2569
2602
  if (status === 'loading') {
2570
2603
  if (LoadingComponent) {
2571
- return /*#__PURE__*/React.createElement(LoadingComponent, null);
2604
+ return /*#__PURE__*/React.createElement(LoadingComponent, Object.assign({}, baseline, {
2605
+ experiences: experiences,
2606
+ component: Component
2607
+ }));
2572
2608
  }
2573
2609
 
2574
2610
  return /*#__PURE__*/React.createElement("div", {
@@ -2586,55 +2622,106 @@ const Experience = _a => {
2586
2622
  })));
2587
2623
  }
2588
2624
 
2589
- if (!experience || !variant) {
2590
- return /*#__PURE__*/React.createElement(TrackHasSeenComponent, {
2591
- variant: {
2592
- id: baseline.id,
2625
+ if (!experience) {
2626
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
2627
+ key: baseline.id,
2628
+ ninetailed: {
2629
+ isPersonalized: false,
2593
2630
  audience: {
2594
2631
  id: 'baseline'
2595
- },
2596
- hidden: false
2597
- },
2598
- audience: {
2599
- id: 'baseline'
2600
- },
2601
- isPersonalized: false
2632
+ }
2633
+ }
2634
+ }));
2635
+ }
2636
+
2637
+ if (!variant) {
2638
+ return /*#__PURE__*/React.createElement(TrackExperience, {
2639
+ experience: experience,
2640
+ variant: baseline,
2641
+ // the profile is definitely defined, otherwise there wouldn't be an experience selected
2642
+ profile: profile
2602
2643
  }, /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
2603
2644
  key: baseline.id,
2604
2645
  ninetailed: {
2605
2646
  isPersonalized: false,
2606
2647
  audience: {
2607
- id: 'baseline'
2648
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2608
2649
  }
2609
2650
  }
2610
2651
  })));
2611
2652
  }
2612
2653
 
2613
- return (
2614
- /*#__PURE__*/
2615
- // TODO this needs to be resolved when we move away from the old standard
2616
- React.createElement(TrackHasSeenComponent, {
2617
- variant: {
2618
- id: variant.id,
2619
- audience: {
2620
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2621
- },
2622
- hidden: variant.hidden || false
2623
- },
2654
+ return /*#__PURE__*/React.createElement(TrackExperience, {
2655
+ experience: experience,
2656
+ variant: variant,
2657
+ // the profile is definitely defined, otherwise there wouldn't be an experience selected
2658
+ profile: profile
2659
+ }, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React.createElement(Component, Object.assign({}, variant, {
2660
+ key: `${experience.id}-${variant.id}`,
2661
+ ninetailed: {
2662
+ isPersonalized,
2624
2663
  audience: {
2625
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2626
- },
2627
- isPersonalized: isPersonalized
2628
- }, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React.createElement(Component, Object.assign({}, variant, {
2629
- key: `${experience.id}-${variant.id}`,
2630
- ninetailed: {
2631
- isPersonalized,
2632
- audience: {
2633
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2634
- }
2664
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2635
2665
  }
2636
- })))
2637
- );
2666
+ }
2667
+ })));
2668
+ };
2669
+
2670
+ const ESRContext = /*#__PURE__*/React.createContext(undefined);
2671
+ const ESRProvider = ({
2672
+ experienceVariantsMap,
2673
+ children
2674
+ }) => {
2675
+ return /*#__PURE__*/React.createElement(ESRContext.Provider, {
2676
+ value: {
2677
+ experienceVariantsMap
2678
+ }
2679
+ }, children);
2680
+ };
2681
+ const useESR = () => {
2682
+ const context = React.useContext(ESRContext);
2683
+
2684
+ if (context === undefined) {
2685
+ throw new Error('The component using the the context must be a descendant of the ESRProvider');
2686
+ }
2687
+
2688
+ return {
2689
+ experienceVariantsMap: context.experienceVariantsMap
2690
+ };
2691
+ };
2692
+ const ESRLoadingComponent = _a => {
2693
+ var {
2694
+ experiences,
2695
+ component: Component
2696
+ } = _a,
2697
+ baseline = __rest(_a, ["experiences", "component"]);
2698
+
2699
+ const {
2700
+ experienceVariantsMap
2701
+ } = useESR();
2702
+ const experience = experiences.find(experience => has$1(experienceVariantsMap, experience.id));
2703
+
2704
+ if (!experience) {
2705
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline));
2706
+ }
2707
+
2708
+ const component = experience.components.find(component => component.baseline.id === baseline.id);
2709
+
2710
+ if (!component) {
2711
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline));
2712
+ }
2713
+
2714
+ if (experienceVariantsMap[experience.id] === 0) {
2715
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline));
2716
+ }
2717
+
2718
+ const variant = component.variants[experienceVariantsMap[experience.id] - 1];
2719
+
2720
+ if (!variant) {
2721
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline));
2722
+ }
2723
+
2724
+ return /*#__PURE__*/React.createElement(Component, Object.assign({}, variant));
2638
2725
  };
2639
2726
 
2640
- export { Experience, MergeTag, NinetailedProvider, Personalize, TrackHasSeenComponent, useNinetailed, usePersonalize, useProfile };
2727
+ export { ESRLoadingComponent, ESRProvider, Experience, MergeTag, NinetailedProvider, Personalize, TrackHasSeenComponent, useNinetailed, usePersonalize, useProfile };
package/index.umd.js CHANGED
@@ -1,13 +1,14 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@ninetailed/experience.js'), require('react-intersection-observer'), require('@ninetailed/experience.js-shared'), require('lodash/get')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@ninetailed/experience.js', 'react-intersection-observer', '@ninetailed/experience.js-shared', 'lodash/get'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.React, global.experience_js, global.reactIntersectionObserver, global.experience_jsShared, global.get$1));
5
- })(this, (function (exports, React, experience_js, reactIntersectionObserver, experience_jsShared, get$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@ninetailed/experience.js'), require('react-intersection-observer'), require('@ninetailed/experience.js-shared'), require('lodash/get'), require('lodash/has')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', '@ninetailed/experience.js', 'react-intersection-observer', '@ninetailed/experience.js-shared', 'lodash/get', 'lodash/has'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.React = {}, global.React, global.experience_js, global.reactIntersectionObserver, global.experience_jsShared, global.get$1, global.has$1));
5
+ })(this, (function (exports, React, experience_js, reactIntersectionObserver, experience_jsShared, get$1, has$1) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
10
  var get__default = /*#__PURE__*/_interopDefaultLegacy(get$1);
11
+ var has__default = /*#__PURE__*/_interopDefaultLegacy(has$1);
11
12
 
12
13
  var NinetailedContext = /*#__PURE__*/React.createContext(undefined);
13
14
 
@@ -1883,6 +1884,37 @@
1883
1884
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, value);
1884
1885
  };
1885
1886
 
1887
+ var TrackExperience = function TrackExperience(_a) {
1888
+ var children = _a.children,
1889
+ experience = _a.experience,
1890
+ variant = _a.variant,
1891
+ profile = _a.profile;
1892
+ var ninetailed = useNinetailed();
1893
+
1894
+ var _b = reactIntersectionObserver.useInView({
1895
+ triggerOnce: true
1896
+ }),
1897
+ ref = _b.ref,
1898
+ inView = _b.inView;
1899
+
1900
+ React.useEffect(function () {
1901
+ if (experience_jsShared.isBrowser() && inView) {
1902
+ var distribution = experience_js.selectDistribution({
1903
+ experience: experience,
1904
+ profile: profile
1905
+ });
1906
+ ninetailed.trackExperience({
1907
+ experience: experience,
1908
+ component: variant,
1909
+ variant: distribution.index
1910
+ });
1911
+ }
1912
+ }, [inView]);
1913
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
1914
+ ref: ref
1915
+ }), children);
1916
+ };
1917
+
1886
1918
  var global$2 = global$t;
1887
1919
  var aCallable = aCallable$2;
1888
1920
  var toObject = toObject$3;
@@ -2063,7 +2095,8 @@
2063
2095
 
2064
2096
  var useJoinExperiment = function useJoinExperiment(_a) {
2065
2097
  var experiences = _a.experiences;
2066
- var identify = useNinetailed().identify;
2098
+ var identify = useNinetailed().identify; // TODO this gets called twice
2099
+
2067
2100
  return React.useCallback(function (_a) {
2068
2101
  var _b;
2069
2102
 
@@ -2072,7 +2105,7 @@
2072
2105
  var activeExperiments = experience_js.selectActiveExperiments(experiences, profile);
2073
2106
 
2074
2107
  if (!activeExperiments.length && experiment.type === 'nt_experiment') {
2075
- identify('', (_b = {}, _b["".concat(EXPERIENCE_TRAIT_PREFIX).concat(experiment.id)] = true, _b));
2108
+ identify(profile.id, (_b = {}, _b["".concat(EXPERIENCE_TRAIT_PREFIX).concat(experiment.id)] = true, _b));
2076
2109
  }
2077
2110
  }, [experiences]);
2078
2111
  };
@@ -2113,7 +2146,10 @@
2113
2146
 
2114
2147
  if (status === 'loading') {
2115
2148
  if (LoadingComponent) {
2116
- return /*#__PURE__*/React__default["default"].createElement(LoadingComponent, null);
2149
+ return /*#__PURE__*/React__default["default"].createElement(LoadingComponent, __assign({}, baseline, {
2150
+ experiences: experiences,
2151
+ component: Component
2152
+ }));
2117
2153
  }
2118
2154
 
2119
2155
  return /*#__PURE__*/React__default["default"].createElement("div", {
@@ -2131,57 +2167,109 @@
2131
2167
  })));
2132
2168
  }
2133
2169
 
2134
- if (!experience || !variant) {
2135
- return /*#__PURE__*/React__default["default"].createElement(TrackHasSeenComponent, {
2136
- variant: {
2137
- id: baseline.id,
2170
+ if (!experience) {
2171
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
2172
+ key: baseline.id,
2173
+ ninetailed: {
2174
+ isPersonalized: false,
2138
2175
  audience: {
2139
2176
  id: 'baseline'
2140
- },
2141
- hidden: false
2142
- },
2143
- audience: {
2144
- id: 'baseline'
2145
- },
2146
- isPersonalized: false
2177
+ }
2178
+ }
2179
+ }));
2180
+ }
2181
+
2182
+ if (!variant) {
2183
+ return /*#__PURE__*/React__default["default"].createElement(TrackExperience, {
2184
+ experience: experience,
2185
+ variant: baseline,
2186
+ // the profile is definitely defined, otherwise there wouldn't be an experience selected
2187
+ profile: profile
2147
2188
  }, /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
2148
2189
  key: baseline.id,
2149
2190
  ninetailed: {
2150
2191
  isPersonalized: false,
2151
2192
  audience: {
2152
- id: 'baseline'
2193
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2153
2194
  }
2154
2195
  }
2155
2196
  })));
2156
2197
  }
2157
2198
 
2158
- return (
2159
- /*#__PURE__*/
2160
- // TODO this needs to be resolved when we move away from the old standard
2161
- React__default["default"].createElement(TrackHasSeenComponent, {
2162
- variant: {
2163
- id: variant.id,
2164
- audience: {
2165
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2166
- },
2167
- hidden: variant.hidden || false
2168
- },
2199
+ return /*#__PURE__*/React__default["default"].createElement(TrackExperience, {
2200
+ experience: experience,
2201
+ variant: variant,
2202
+ // the profile is definitely defined, otherwise there wouldn't be an experience selected
2203
+ profile: profile
2204
+ }, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, variant, {
2205
+ key: "".concat(experience.id, "-").concat(variant.id),
2206
+ ninetailed: {
2207
+ isPersonalized: isPersonalized,
2169
2208
  audience: {
2170
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2171
- },
2172
- isPersonalized: isPersonalized
2173
- }, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, variant, {
2174
- key: "".concat(experience.id, "-").concat(variant.id),
2175
- ninetailed: {
2176
- isPersonalized: isPersonalized,
2177
- audience: {
2178
- id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'baseline'
2179
- }
2209
+ id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
2180
2210
  }
2181
- })))
2182
- );
2211
+ }
2212
+ })));
2213
+ };
2214
+
2215
+ var ESRContext = /*#__PURE__*/React__default["default"].createContext(undefined);
2216
+ var ESRProvider = function ESRProvider(_a) {
2217
+ var experienceVariantsMap = _a.experienceVariantsMap,
2218
+ children = _a.children;
2219
+ return /*#__PURE__*/React__default["default"].createElement(ESRContext.Provider, {
2220
+ value: {
2221
+ experienceVariantsMap: experienceVariantsMap
2222
+ }
2223
+ }, children);
2224
+ };
2225
+ var useESR = function useESR() {
2226
+ var context = React__default["default"].useContext(ESRContext);
2227
+
2228
+ if (context === undefined) {
2229
+ throw new Error('The component using the the context must be a descendant of the ESRProvider');
2230
+ }
2231
+
2232
+ return {
2233
+ experienceVariantsMap: context.experienceVariantsMap
2234
+ };
2235
+ };
2236
+ var ESRLoadingComponent = function ESRLoadingComponent(_a) {
2237
+ var experiences = _a.experiences,
2238
+ Component = _a.component,
2239
+ baseline = __rest(_a, ["experiences", "component"]);
2240
+
2241
+ var experienceVariantsMap = useESR().experienceVariantsMap;
2242
+ var experience = experiences.find(function (experience) {
2243
+ return has__default["default"](experienceVariantsMap, experience.id);
2244
+ });
2245
+
2246
+ if (!experience) {
2247
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline));
2248
+ }
2249
+
2250
+ var component = experience.components.find(function (component) {
2251
+ return component.baseline.id === baseline.id;
2252
+ });
2253
+
2254
+ if (!component) {
2255
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline));
2256
+ }
2257
+
2258
+ if (experienceVariantsMap[experience.id] === 0) {
2259
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline));
2260
+ }
2261
+
2262
+ var variant = component.variants[experienceVariantsMap[experience.id] - 1];
2263
+
2264
+ if (!variant) {
2265
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline));
2266
+ }
2267
+
2268
+ return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, variant));
2183
2269
  };
2184
2270
 
2271
+ exports.ESRLoadingComponent = ESRLoadingComponent;
2272
+ exports.ESRProvider = ESRProvider;
2185
2273
  exports.Experience = Experience;
2186
2274
  exports.MergeTag = MergeTag;
2187
2275
  exports.NinetailedProvider = NinetailedProvider;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ExperienceLoadingComponent } from './Experience';
3
+ declare type ESRContextValue = {
4
+ experienceVariantsMap: Record<string, number>;
5
+ };
6
+ export declare const ESRContext: React.Context<ESRContextValue | undefined>;
7
+ declare type ESRProviderProps = {
8
+ experienceVariantsMap: Record<string, number>;
9
+ };
10
+ export declare const ESRProvider: React.FC<ESRProviderProps>;
11
+ export declare const useESR: () => {
12
+ experienceVariantsMap: Record<string, number>;
13
+ };
14
+ export declare const ESRLoadingComponent: ExperienceLoadingComponent;
15
+ export {};
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Baseline, ExperienceConfiguration } from '@ninetailed/experience.js';
3
- declare type ExperienceComponent<P extends Baseline> = React.ComponentType<Omit<P, 'id'> & {
3
+ export declare type ExperienceComponent<P extends Baseline> = React.ComponentType<Omit<P, 'id'> & {
4
4
  ninetailed?: {
5
5
  isPersonalized: boolean;
6
6
  audience: {
@@ -8,12 +8,16 @@ declare type ExperienceComponent<P extends Baseline> = React.ComponentType<Omit<
8
8
  };
9
9
  };
10
10
  }>;
11
- declare type ExperienceProps<P extends Baseline> = P & {
11
+ export declare type ExperienceBaseProps<P extends Baseline = Baseline> = P & {
12
12
  experiences: ExperienceConfiguration[];
13
13
  component: ExperienceComponent<P> | React.ComponentType<P>;
14
- loadingComponent?: React.ComponentType;
14
+ };
15
+ export declare type ExperienceLoadingComponent<P extends Baseline = Baseline> = React.ComponentType<ExperienceBaseProps<P>>;
16
+ export declare type ExperienceProps<P extends Baseline> = ExperienceBaseProps<P> & {
17
+ experiences: ExperienceConfiguration[];
18
+ component: ExperienceComponent<P> | React.ComponentType<P>;
19
+ loadingComponent?: ExperienceLoadingComponent<P>;
15
20
  };
16
21
  export declare const Experience: <P extends {
17
22
  id: string;
18
23
  }>({ experiences, component: Component, loadingComponent: LoadingComponent, ...baseline }: ExperienceProps<P>) => JSX.Element;
19
- export {};
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { Profile } from '@ninetailed/experience.js-shared';
3
+ import { ExperienceConfiguration } from '@ninetailed/experience.js';
4
+ declare type TrackExperienceProps = {
5
+ experience: ExperienceConfiguration;
6
+ variant: {
7
+ id: string;
8
+ };
9
+ profile: Profile;
10
+ };
11
+ export declare const TrackExperience: React.FC<React.PropsWithChildren<TrackExperienceProps>>;
12
+ export {};
@@ -1 +1,3 @@
1
1
  export { Experience } from './Experience';
2
+ export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
3
+ export { ESRProvider, ESRLoadingComponent } from './ESRLoadingComponent';
@@ -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,5 +1,5 @@
1
1
  export type { Profile, Variant } from '@ninetailed/experience.js-shared';
2
- export type { ExperienceConfiguration, ExperienceType, } from '@ninetailed/experience.js';
2
+ export type { ExperienceConfiguration, ExperienceType, EXPERIENCE_TRAIT_PREFIX, } from '@ninetailed/experience.js';
3
3
  export { NinetailedProvider } from './NinetailedProvider';
4
4
  export type { NinetailedProviderProps } from './NinetailedProvider';
5
5
  export { useNinetailed } from './useNinetailed';
@@ -9,4 +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 } from './Experience';
12
+ export { Experience, ESRProvider, ESRLoadingComponent } from './Experience';
13
+ export type { ExperienceProps, ExperienceBaseProps, ExperienceComponent, ExperienceLoadingComponent, } from './Experience';
package/package.json CHANGED
@@ -1,20 +1,22 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js-react",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.42",
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.4",
10
+ "lodash": "^4.17.21",
11
+ "@ninetailed/experience.js": "2.0.0-beta.42",
11
12
  "analytics": "^0.8.0",
12
- "@ninetailed/experience.js-shared": "2.0.0-beta.4",
13
+ "@ninetailed/experience.js-shared": "2.0.0-beta.42",
13
14
  "uuid": "^8.3.2",
14
15
  "ts-toolbelt": "^9.6.0",
15
16
  "locale-enum": "^1.1.1",
16
17
  "i18n-iso-countries": "^7.3.0",
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 {};