@ninetailed/experience.js-react 2.0.0-beta.35 → 2.0.0-beta.39
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 +31 -9
- package/index.umd.js +30 -8
- package/lib/Experience/TrackExperience.d.ts +11 -2
- package/package.json +3 -3
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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';
|
|
@@ -2337,7 +2337,8 @@ const MergeTag = ({
|
|
|
2337
2337
|
const TrackExperience = ({
|
|
2338
2338
|
children,
|
|
2339
2339
|
experience,
|
|
2340
|
-
variant
|
|
2340
|
+
variant,
|
|
2341
|
+
profile
|
|
2341
2342
|
}) => {
|
|
2342
2343
|
const ninetailed = useNinetailed();
|
|
2343
2344
|
const {
|
|
@@ -2348,9 +2349,14 @@ const TrackExperience = ({
|
|
|
2348
2349
|
});
|
|
2349
2350
|
useEffect(() => {
|
|
2350
2351
|
if (isBrowser() && inView) {
|
|
2352
|
+
const distribution = selectDistribution({
|
|
2353
|
+
experience,
|
|
2354
|
+
profile
|
|
2355
|
+
});
|
|
2351
2356
|
ninetailed.trackExperience({
|
|
2352
2357
|
experience,
|
|
2353
|
-
variant
|
|
2358
|
+
component: variant,
|
|
2359
|
+
variant: distribution.index
|
|
2354
2360
|
});
|
|
2355
2361
|
}
|
|
2356
2362
|
}, [inView]);
|
|
@@ -2616,7 +2622,7 @@ const Experience = _a => {
|
|
|
2616
2622
|
})));
|
|
2617
2623
|
}
|
|
2618
2624
|
|
|
2619
|
-
if (!experience
|
|
2625
|
+
if (!experience) {
|
|
2620
2626
|
return /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
|
|
2621
2627
|
key: baseline.id,
|
|
2622
2628
|
ninetailed: {
|
|
@@ -2628,18 +2634,34 @@ const Experience = _a => {
|
|
|
2628
2634
|
}));
|
|
2629
2635
|
}
|
|
2630
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
|
|
2643
|
+
}, /*#__PURE__*/React.createElement(Component, Object.assign({}, baseline, {
|
|
2644
|
+
key: baseline.id,
|
|
2645
|
+
ninetailed: {
|
|
2646
|
+
isPersonalized: false,
|
|
2647
|
+
audience: {
|
|
2648
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
})));
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2631
2654
|
return /*#__PURE__*/React.createElement(TrackExperience, {
|
|
2632
2655
|
experience: experience,
|
|
2633
|
-
variant:
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
}
|
|
2656
|
+
variant: variant,
|
|
2657
|
+
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2658
|
+
profile: profile
|
|
2637
2659
|
}, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React.createElement(Component, Object.assign({}, variant, {
|
|
2638
2660
|
key: `${experience.id}-${variant.id}`,
|
|
2639
2661
|
ninetailed: {
|
|
2640
2662
|
isPersonalized,
|
|
2641
2663
|
audience: {
|
|
2642
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || '
|
|
2664
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2643
2665
|
}
|
|
2644
2666
|
}
|
|
2645
2667
|
})));
|
package/index.umd.js
CHANGED
|
@@ -1887,7 +1887,8 @@
|
|
|
1887
1887
|
var TrackExperience = function TrackExperience(_a) {
|
|
1888
1888
|
var children = _a.children,
|
|
1889
1889
|
experience = _a.experience,
|
|
1890
|
-
variant = _a.variant
|
|
1890
|
+
variant = _a.variant,
|
|
1891
|
+
profile = _a.profile;
|
|
1891
1892
|
var ninetailed = useNinetailed();
|
|
1892
1893
|
|
|
1893
1894
|
var _b = reactIntersectionObserver.useInView({
|
|
@@ -1898,9 +1899,14 @@
|
|
|
1898
1899
|
|
|
1899
1900
|
React.useEffect(function () {
|
|
1900
1901
|
if (experience_jsShared.isBrowser() && inView) {
|
|
1902
|
+
var distribution = experience_js.selectDistribution({
|
|
1903
|
+
experience: experience,
|
|
1904
|
+
profile: profile
|
|
1905
|
+
});
|
|
1901
1906
|
ninetailed.trackExperience({
|
|
1902
1907
|
experience: experience,
|
|
1903
|
-
|
|
1908
|
+
component: variant,
|
|
1909
|
+
variant: distribution.index
|
|
1904
1910
|
});
|
|
1905
1911
|
}
|
|
1906
1912
|
}, [inView]);
|
|
@@ -2161,7 +2167,7 @@
|
|
|
2161
2167
|
})));
|
|
2162
2168
|
}
|
|
2163
2169
|
|
|
2164
|
-
if (!experience
|
|
2170
|
+
if (!experience) {
|
|
2165
2171
|
return /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
|
|
2166
2172
|
key: baseline.id,
|
|
2167
2173
|
ninetailed: {
|
|
@@ -2173,18 +2179,34 @@
|
|
|
2173
2179
|
}));
|
|
2174
2180
|
}
|
|
2175
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
|
|
2188
|
+
}, /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, baseline, {
|
|
2189
|
+
key: baseline.id,
|
|
2190
|
+
ninetailed: {
|
|
2191
|
+
isPersonalized: false,
|
|
2192
|
+
audience: {
|
|
2193
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
})));
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2176
2199
|
return /*#__PURE__*/React__default["default"].createElement(TrackExperience, {
|
|
2177
2200
|
experience: experience,
|
|
2178
|
-
variant:
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
}
|
|
2201
|
+
variant: variant,
|
|
2202
|
+
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2203
|
+
profile: profile
|
|
2182
2204
|
}, (variant === null || variant === void 0 ? void 0 : variant.hidden) ? null : /*#__PURE__*/React__default["default"].createElement(Component, __assign({}, variant, {
|
|
2183
2205
|
key: "".concat(experience.id, "-").concat(variant.id),
|
|
2184
2206
|
ninetailed: {
|
|
2185
2207
|
isPersonalized: isPersonalized,
|
|
2186
2208
|
audience: {
|
|
2187
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || '
|
|
2209
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2188
2210
|
}
|
|
2189
2211
|
}
|
|
2190
2212
|
})));
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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 {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.39",
|
|
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": "2.0.0-beta.
|
|
11
|
+
"@ninetailed/experience.js": "2.0.0-beta.39",
|
|
12
12
|
"analytics": "^0.8.0",
|
|
13
|
-
"@ninetailed/experience.js-shared": "2.0.0-beta.
|
|
13
|
+
"@ninetailed/experience.js-shared": "2.0.0-beta.39",
|
|
14
14
|
"uuid": "^8.3.2",
|
|
15
15
|
"ts-toolbelt": "^9.6.0",
|
|
16
16
|
"locale-enum": "^1.1.1",
|