@ninetailed/experience.js-react 4.3.0-beta.3 → 5.0.0-beta.3
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 +61 -135
- package/index.js +63 -137
- package/lib/NinetailedProvider.d.ts +12 -6
- package/lib/index.d.ts +1 -1
- package/lib/useProfile.d.ts +0 -2
- package/package.json +3 -4
- package/lib/Experience/ComponentMarker.d.ts +0 -2
package/index.cjs
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var experience_js = require('@ninetailed/experience.js');
|
|
8
|
-
var reactIs = require('react-is');
|
|
9
8
|
var reactIntersectionObserver = require('react-intersection-observer');
|
|
10
9
|
var experience_jsShared = require('@ninetailed/experience.js-shared');
|
|
11
10
|
var radash = require('radash');
|
|
@@ -2054,7 +2053,7 @@ const useExperience = ({
|
|
|
2054
2053
|
}));
|
|
2055
2054
|
}
|
|
2056
2055
|
const audience = experience.audience;
|
|
2057
|
-
const variant = experience_js.
|
|
2056
|
+
const variant = experience_js.selectExperienceVariantClientSide({
|
|
2058
2057
|
baseline,
|
|
2059
2058
|
experience,
|
|
2060
2059
|
profile
|
|
@@ -2088,36 +2087,6 @@ const useJoinExperiment = () => {
|
|
|
2088
2087
|
return context.joinExperiment;
|
|
2089
2088
|
};
|
|
2090
2089
|
|
|
2091
|
-
const ComponentMarker = /*#__PURE__*/React.forwardRef((_, ref) => {
|
|
2092
|
-
const {
|
|
2093
|
-
logger
|
|
2094
|
-
} = useNinetailed();
|
|
2095
|
-
const markerRef = React.useRef(null);
|
|
2096
|
-
React.useEffect(() => {
|
|
2097
|
-
// TODO: Create a better message
|
|
2098
|
-
logger.debug('Using fallback mechanism to select component.');
|
|
2099
|
-
}, [logger]);
|
|
2100
|
-
React.useEffect(() => {
|
|
2101
|
-
if (markerRef.current) {
|
|
2102
|
-
const nextSibling = markerRef.current.nextSibling;
|
|
2103
|
-
if (ref) {
|
|
2104
|
-
if (typeof ref === 'function') {
|
|
2105
|
-
ref(nextSibling);
|
|
2106
|
-
} else {
|
|
2107
|
-
ref.current = nextSibling;
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
}, []);
|
|
2112
|
-
return jsxRuntime.jsx("div", {
|
|
2113
|
-
className: "nt-cmp-marker",
|
|
2114
|
-
style: {
|
|
2115
|
-
display: 'none !important'
|
|
2116
|
-
},
|
|
2117
|
-
ref: markerRef
|
|
2118
|
-
});
|
|
2119
|
-
});
|
|
2120
|
-
|
|
2121
2090
|
const DefaultExperienceLoadingComponent = _a => {
|
|
2122
2091
|
var {
|
|
2123
2092
|
component: Component,
|
|
@@ -2171,10 +2140,6 @@ const Experience = _a => {
|
|
|
2171
2140
|
passthroughProps
|
|
2172
2141
|
} = _a,
|
|
2173
2142
|
baseline = __rest(_a, ["experiences", "component", "loadingComponent", "passthroughProps"]);
|
|
2174
|
-
const {
|
|
2175
|
-
observeElement,
|
|
2176
|
-
unobserveElement
|
|
2177
|
-
} = useNinetailed();
|
|
2178
2143
|
// TODO we actually could hook into the experience hook here with the plugins
|
|
2179
2144
|
const {
|
|
2180
2145
|
status,
|
|
@@ -2189,10 +2154,6 @@ const Experience = _a => {
|
|
|
2189
2154
|
experiences
|
|
2190
2155
|
});
|
|
2191
2156
|
const joinExperiment = useJoinExperiment();
|
|
2192
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2193
|
-
// @ts-ignore
|
|
2194
|
-
const isComponentForwardRef = reactIs.isForwardRef(jsxRuntime.jsx(Component, {}));
|
|
2195
|
-
const componentRef = React.useRef(null);
|
|
2196
2157
|
React.useEffect(() => {
|
|
2197
2158
|
if (status === 'success' && experience && profile) {
|
|
2198
2159
|
joinExperiment({
|
|
@@ -2202,33 +2163,10 @@ const Experience = _a => {
|
|
|
2202
2163
|
});
|
|
2203
2164
|
}
|
|
2204
2165
|
}, [status, experience, profile]);
|
|
2205
|
-
React.useEffect(() => {
|
|
2206
|
-
const componentElement = componentRef.current;
|
|
2207
|
-
if (componentElement) {
|
|
2208
|
-
observeElement({
|
|
2209
|
-
element: componentElement,
|
|
2210
|
-
experienceId: experience === null || experience === void 0 ? void 0 : experience.id,
|
|
2211
|
-
variantId: variant === null || variant === void 0 ? void 0 : variant.id,
|
|
2212
|
-
baselineId: baseline.id,
|
|
2213
|
-
audienceId: audience === null || audience === void 0 ? void 0 : audience.id
|
|
2214
|
-
});
|
|
2215
|
-
}
|
|
2216
|
-
return () => {
|
|
2217
|
-
if (componentElement) {
|
|
2218
|
-
unobserveElement(componentElement);
|
|
2219
|
-
}
|
|
2220
|
-
};
|
|
2221
|
-
}, [observeElement, unobserveElement, experience, baseline, variant, audience]);
|
|
2222
2166
|
if (!hasVariants) {
|
|
2223
|
-
return
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
}), /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2227
|
-
key: baseline.id
|
|
2228
|
-
}, isComponentForwardRef ? {
|
|
2229
|
-
ref: componentRef
|
|
2230
|
-
} : {}))]
|
|
2231
|
-
});
|
|
2167
|
+
return /*#__PURE__*/React.createElement(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2168
|
+
key: baseline.id
|
|
2169
|
+
}));
|
|
2232
2170
|
}
|
|
2233
2171
|
if (status === 'loading') {
|
|
2234
2172
|
return /*#__PURE__*/React.createElement(LoadingComponent, Object.assign({}, baseline, {
|
|
@@ -2239,20 +2177,14 @@ const Experience = _a => {
|
|
|
2239
2177
|
}));
|
|
2240
2178
|
}
|
|
2241
2179
|
if (!experience) {
|
|
2242
|
-
return jsxRuntime.
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
isPersonalized: false,
|
|
2248
|
-
audience: {
|
|
2249
|
-
id: 'baseline'
|
|
2250
|
-
}
|
|
2180
|
+
return jsxRuntime.jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2181
|
+
ninetailed: {
|
|
2182
|
+
isPersonalized: false,
|
|
2183
|
+
audience: {
|
|
2184
|
+
id: 'baseline'
|
|
2251
2185
|
}
|
|
2252
|
-
}
|
|
2253
|
-
|
|
2254
|
-
} : {}))]
|
|
2255
|
-
});
|
|
2186
|
+
}
|
|
2187
|
+
}));
|
|
2256
2188
|
}
|
|
2257
2189
|
if (!variant) {
|
|
2258
2190
|
return jsxRuntime.jsx(TrackExperience, Object.assign({
|
|
@@ -2261,20 +2193,14 @@ const Experience = _a => {
|
|
|
2261
2193
|
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2262
2194
|
profile: profile
|
|
2263
2195
|
}, {
|
|
2264
|
-
children: jsxRuntime.
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
isPersonalized: false,
|
|
2270
|
-
audience: {
|
|
2271
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2272
|
-
}
|
|
2196
|
+
children: jsxRuntime.jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2197
|
+
ninetailed: {
|
|
2198
|
+
isPersonalized: false,
|
|
2199
|
+
audience: {
|
|
2200
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2273
2201
|
}
|
|
2274
|
-
}
|
|
2275
|
-
|
|
2276
|
-
} : {}))]
|
|
2277
|
-
})
|
|
2202
|
+
}
|
|
2203
|
+
}))
|
|
2278
2204
|
}), baseline.id);
|
|
2279
2205
|
}
|
|
2280
2206
|
const isVariantHidden = 'hidden' in variant && variant.hidden;
|
|
@@ -2284,21 +2210,15 @@ const Experience = _a => {
|
|
|
2284
2210
|
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2285
2211
|
profile: profile
|
|
2286
2212
|
}, {
|
|
2287
|
-
children: !isVariantHidden ?
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
isPersonalized,
|
|
2294
|
-
audience: {
|
|
2295
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2296
|
-
}
|
|
2213
|
+
children: !isVariantHidden ? /*#__PURE__*/React.createElement(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
|
|
2214
|
+
key: `${experience.id}-${variant.id}`,
|
|
2215
|
+
ninetailed: {
|
|
2216
|
+
isPersonalized,
|
|
2217
|
+
audience: {
|
|
2218
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2297
2219
|
}
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
} : {}))]
|
|
2301
|
-
}) : null
|
|
2220
|
+
}
|
|
2221
|
+
})) : null
|
|
2302
2222
|
}));
|
|
2303
2223
|
};
|
|
2304
2224
|
|
|
@@ -2460,39 +2380,45 @@ const ExperimentsProvider = ({
|
|
|
2460
2380
|
}));
|
|
2461
2381
|
};
|
|
2462
2382
|
|
|
2463
|
-
const NinetailedProvider =
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2383
|
+
const NinetailedProvider = props => {
|
|
2384
|
+
const ninetailed = React.useMemo(() => {
|
|
2385
|
+
if ('ninetailed' in props) {
|
|
2386
|
+
return props.ninetailed;
|
|
2387
|
+
}
|
|
2388
|
+
const {
|
|
2389
|
+
clientId,
|
|
2390
|
+
environment,
|
|
2391
|
+
preview,
|
|
2392
|
+
url,
|
|
2393
|
+
locale,
|
|
2394
|
+
requestTimeout,
|
|
2395
|
+
plugins = [],
|
|
2396
|
+
onLog,
|
|
2397
|
+
onError
|
|
2398
|
+
} = props;
|
|
2399
|
+
return new experience_js.Ninetailed({
|
|
2400
|
+
clientId,
|
|
2401
|
+
environment,
|
|
2402
|
+
preview
|
|
2403
|
+
}, {
|
|
2404
|
+
url,
|
|
2405
|
+
plugins,
|
|
2406
|
+
locale,
|
|
2407
|
+
requestTimeout,
|
|
2408
|
+
onLog,
|
|
2409
|
+
onError
|
|
2410
|
+
});
|
|
2411
|
+
}, []);
|
|
2412
|
+
const {
|
|
2413
|
+
experiments = [],
|
|
2414
|
+
maximumActiveExperiments,
|
|
2415
|
+
children
|
|
2416
|
+
} = props;
|
|
2491
2417
|
return jsxRuntime.jsx(NinetailedContext.Provider, Object.assign({
|
|
2492
2418
|
value: ninetailed
|
|
2493
2419
|
}, {
|
|
2494
2420
|
children: jsxRuntime.jsx(ExperimentsProvider, Object.assign({
|
|
2495
|
-
experiments:
|
|
2421
|
+
experiments: experiments,
|
|
2496
2422
|
maximumActiveExperiments: maximumActiveExperiments
|
|
2497
2423
|
}, {
|
|
2498
2424
|
children: children
|
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import React, { createContext, useContext, useEffect, useState, useRef, useMemo,
|
|
3
|
-
import { selectDistribution, makeExperienceSelectMiddleware, selectHasExperienceVariants, selectActiveExperiments, selectExperience,
|
|
4
|
-
import { isForwardRef } from 'react-is';
|
|
2
|
+
import React, { createContext, useContext, useEffect, useState, useRef, useMemo, createElement as createElement$1, useCallback } from 'react';
|
|
3
|
+
import { selectDistribution, makeExperienceSelectMiddleware, selectHasExperienceVariants, selectActiveExperiments, selectExperience, selectExperienceVariantClientSide, Ninetailed, selectVariant } from '@ninetailed/experience.js';
|
|
5
4
|
import { useInView } from 'react-intersection-observer';
|
|
6
5
|
import { isBrowser, logger } from '@ninetailed/experience.js-shared';
|
|
7
6
|
import { isEqual, debounce as debounce$1, get as get$1 } from 'radash';
|
|
@@ -2046,7 +2045,7 @@ const useExperience = ({
|
|
|
2046
2045
|
}));
|
|
2047
2046
|
}
|
|
2048
2047
|
const audience = experience.audience;
|
|
2049
|
-
const variant =
|
|
2048
|
+
const variant = selectExperienceVariantClientSide({
|
|
2050
2049
|
baseline,
|
|
2051
2050
|
experience,
|
|
2052
2051
|
profile
|
|
@@ -2080,36 +2079,6 @@ const useJoinExperiment = () => {
|
|
|
2080
2079
|
return context.joinExperiment;
|
|
2081
2080
|
};
|
|
2082
2081
|
|
|
2083
|
-
const ComponentMarker = /*#__PURE__*/forwardRef((_, ref) => {
|
|
2084
|
-
const {
|
|
2085
|
-
logger
|
|
2086
|
-
} = useNinetailed();
|
|
2087
|
-
const markerRef = useRef(null);
|
|
2088
|
-
useEffect(() => {
|
|
2089
|
-
// TODO: Create a better message
|
|
2090
|
-
logger.debug('Using fallback mechanism to select component.');
|
|
2091
|
-
}, [logger]);
|
|
2092
|
-
useEffect(() => {
|
|
2093
|
-
if (markerRef.current) {
|
|
2094
|
-
const nextSibling = markerRef.current.nextSibling;
|
|
2095
|
-
if (ref) {
|
|
2096
|
-
if (typeof ref === 'function') {
|
|
2097
|
-
ref(nextSibling);
|
|
2098
|
-
} else {
|
|
2099
|
-
ref.current = nextSibling;
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
}, []);
|
|
2104
|
-
return jsx("div", {
|
|
2105
|
-
className: "nt-cmp-marker",
|
|
2106
|
-
style: {
|
|
2107
|
-
display: 'none !important'
|
|
2108
|
-
},
|
|
2109
|
-
ref: markerRef
|
|
2110
|
-
});
|
|
2111
|
-
});
|
|
2112
|
-
|
|
2113
2082
|
const DefaultExperienceLoadingComponent = _a => {
|
|
2114
2083
|
var {
|
|
2115
2084
|
component: Component,
|
|
@@ -2163,10 +2132,6 @@ const Experience = _a => {
|
|
|
2163
2132
|
passthroughProps
|
|
2164
2133
|
} = _a,
|
|
2165
2134
|
baseline = __rest(_a, ["experiences", "component", "loadingComponent", "passthroughProps"]);
|
|
2166
|
-
const {
|
|
2167
|
-
observeElement,
|
|
2168
|
-
unobserveElement
|
|
2169
|
-
} = useNinetailed();
|
|
2170
2135
|
// TODO we actually could hook into the experience hook here with the plugins
|
|
2171
2136
|
const {
|
|
2172
2137
|
status,
|
|
@@ -2181,10 +2146,6 @@ const Experience = _a => {
|
|
|
2181
2146
|
experiences
|
|
2182
2147
|
});
|
|
2183
2148
|
const joinExperiment = useJoinExperiment();
|
|
2184
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2185
|
-
// @ts-ignore
|
|
2186
|
-
const isComponentForwardRef = isForwardRef(jsx(Component, {}));
|
|
2187
|
-
const componentRef = useRef(null);
|
|
2188
2149
|
useEffect(() => {
|
|
2189
2150
|
if (status === 'success' && experience && profile) {
|
|
2190
2151
|
joinExperiment({
|
|
@@ -2194,33 +2155,10 @@ const Experience = _a => {
|
|
|
2194
2155
|
});
|
|
2195
2156
|
}
|
|
2196
2157
|
}, [status, experience, profile]);
|
|
2197
|
-
useEffect(() => {
|
|
2198
|
-
const componentElement = componentRef.current;
|
|
2199
|
-
if (componentElement) {
|
|
2200
|
-
observeElement({
|
|
2201
|
-
element: componentElement,
|
|
2202
|
-
experienceId: experience === null || experience === void 0 ? void 0 : experience.id,
|
|
2203
|
-
variantId: variant === null || variant === void 0 ? void 0 : variant.id,
|
|
2204
|
-
baselineId: baseline.id,
|
|
2205
|
-
audienceId: audience === null || audience === void 0 ? void 0 : audience.id
|
|
2206
|
-
});
|
|
2207
|
-
}
|
|
2208
|
-
return () => {
|
|
2209
|
-
if (componentElement) {
|
|
2210
|
-
unobserveElement(componentElement);
|
|
2211
|
-
}
|
|
2212
|
-
};
|
|
2213
|
-
}, [observeElement, unobserveElement, experience, baseline, variant, audience]);
|
|
2214
2158
|
if (!hasVariants) {
|
|
2215
|
-
return
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
}), /*#__PURE__*/createElement$1(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2219
|
-
key: baseline.id
|
|
2220
|
-
}, isComponentForwardRef ? {
|
|
2221
|
-
ref: componentRef
|
|
2222
|
-
} : {}))]
|
|
2223
|
-
});
|
|
2159
|
+
return /*#__PURE__*/createElement$1(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2160
|
+
key: baseline.id
|
|
2161
|
+
}));
|
|
2224
2162
|
}
|
|
2225
2163
|
if (status === 'loading') {
|
|
2226
2164
|
return /*#__PURE__*/createElement$1(LoadingComponent, Object.assign({}, baseline, {
|
|
@@ -2231,20 +2169,14 @@ const Experience = _a => {
|
|
|
2231
2169
|
}));
|
|
2232
2170
|
}
|
|
2233
2171
|
if (!experience) {
|
|
2234
|
-
return
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
isPersonalized: false,
|
|
2240
|
-
audience: {
|
|
2241
|
-
id: 'baseline'
|
|
2242
|
-
}
|
|
2172
|
+
return jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2173
|
+
ninetailed: {
|
|
2174
|
+
isPersonalized: false,
|
|
2175
|
+
audience: {
|
|
2176
|
+
id: 'baseline'
|
|
2243
2177
|
}
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2246
|
-
} : {}))]
|
|
2247
|
-
});
|
|
2178
|
+
}
|
|
2179
|
+
}));
|
|
2248
2180
|
}
|
|
2249
2181
|
if (!variant) {
|
|
2250
2182
|
return jsx(TrackExperience, Object.assign({
|
|
@@ -2253,20 +2185,14 @@ const Experience = _a => {
|
|
|
2253
2185
|
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2254
2186
|
profile: profile
|
|
2255
2187
|
}, {
|
|
2256
|
-
children:
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
isPersonalized: false,
|
|
2262
|
-
audience: {
|
|
2263
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2264
|
-
}
|
|
2188
|
+
children: jsx(Component, Object.assign({}, passthroughProps, baseline, {
|
|
2189
|
+
ninetailed: {
|
|
2190
|
+
isPersonalized: false,
|
|
2191
|
+
audience: {
|
|
2192
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2265
2193
|
}
|
|
2266
|
-
}
|
|
2267
|
-
|
|
2268
|
-
} : {}))]
|
|
2269
|
-
})
|
|
2194
|
+
}
|
|
2195
|
+
}))
|
|
2270
2196
|
}), baseline.id);
|
|
2271
2197
|
}
|
|
2272
2198
|
const isVariantHidden = 'hidden' in variant && variant.hidden;
|
|
@@ -2276,21 +2202,15 @@ const Experience = _a => {
|
|
|
2276
2202
|
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2277
2203
|
profile: profile
|
|
2278
2204
|
}, {
|
|
2279
|
-
children: !isVariantHidden ?
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
isPersonalized,
|
|
2286
|
-
audience: {
|
|
2287
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2288
|
-
}
|
|
2205
|
+
children: !isVariantHidden ? /*#__PURE__*/createElement$1(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
|
|
2206
|
+
key: `${experience.id}-${variant.id}`,
|
|
2207
|
+
ninetailed: {
|
|
2208
|
+
isPersonalized,
|
|
2209
|
+
audience: {
|
|
2210
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2289
2211
|
}
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
} : {}))]
|
|
2293
|
-
}) : null
|
|
2212
|
+
}
|
|
2213
|
+
})) : null
|
|
2294
2214
|
}));
|
|
2295
2215
|
};
|
|
2296
2216
|
|
|
@@ -2452,39 +2372,45 @@ const ExperimentsProvider = ({
|
|
|
2452
2372
|
}));
|
|
2453
2373
|
};
|
|
2454
2374
|
|
|
2455
|
-
const NinetailedProvider =
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2375
|
+
const NinetailedProvider = props => {
|
|
2376
|
+
const ninetailed = useMemo(() => {
|
|
2377
|
+
if ('ninetailed' in props) {
|
|
2378
|
+
return props.ninetailed;
|
|
2379
|
+
}
|
|
2380
|
+
const {
|
|
2381
|
+
clientId,
|
|
2382
|
+
environment,
|
|
2383
|
+
preview,
|
|
2384
|
+
url,
|
|
2385
|
+
locale,
|
|
2386
|
+
requestTimeout,
|
|
2387
|
+
plugins = [],
|
|
2388
|
+
onLog,
|
|
2389
|
+
onError
|
|
2390
|
+
} = props;
|
|
2391
|
+
return new Ninetailed({
|
|
2392
|
+
clientId,
|
|
2393
|
+
environment,
|
|
2394
|
+
preview
|
|
2395
|
+
}, {
|
|
2396
|
+
url,
|
|
2397
|
+
plugins,
|
|
2398
|
+
locale,
|
|
2399
|
+
requestTimeout,
|
|
2400
|
+
onLog,
|
|
2401
|
+
onError
|
|
2402
|
+
});
|
|
2403
|
+
}, []);
|
|
2404
|
+
const {
|
|
2405
|
+
experiments = [],
|
|
2406
|
+
maximumActiveExperiments,
|
|
2407
|
+
children
|
|
2408
|
+
} = props;
|
|
2483
2409
|
return jsx(NinetailedContext.Provider, Object.assign({
|
|
2484
2410
|
value: ninetailed
|
|
2485
2411
|
}, {
|
|
2486
2412
|
children: jsx(ExperimentsProvider, Object.assign({
|
|
2487
|
-
experiments:
|
|
2413
|
+
experiments: experiments,
|
|
2488
2414
|
maximumActiveExperiments: maximumActiveExperiments
|
|
2489
2415
|
}, {
|
|
2490
2416
|
children: children
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { NinetailedPlugin, ExperienceConfiguration } from '@ninetailed/experience.js';
|
|
2
|
+
import { Ninetailed, NinetailedPlugin, ExperienceConfiguration } from '@ninetailed/experience.js';
|
|
3
3
|
import { Profile, Locale, OnErrorHandler, OnLogHandler } from '@ninetailed/experience.js-shared';
|
|
4
|
-
|
|
5
|
-
clientId: string;
|
|
6
|
-
environment?: string;
|
|
4
|
+
type ExperimentProviderProps = {
|
|
7
5
|
experiments?: ExperienceConfiguration<any>[];
|
|
8
6
|
maximumActiveExperiments?: number;
|
|
7
|
+
};
|
|
8
|
+
export type NinetailedProviderInstantiationProps = {
|
|
9
|
+
clientId: string;
|
|
10
|
+
environment?: string;
|
|
9
11
|
preview?: boolean;
|
|
10
12
|
url?: string;
|
|
11
13
|
plugins?: (NinetailedPlugin | NinetailedPlugin[])[];
|
|
@@ -14,5 +16,9 @@ export type NinetailedProviderProps = {
|
|
|
14
16
|
requestTimeout?: number;
|
|
15
17
|
onLog?: OnLogHandler;
|
|
16
18
|
onError?: OnErrorHandler;
|
|
17
|
-
};
|
|
18
|
-
export
|
|
19
|
+
} & ExperimentProviderProps;
|
|
20
|
+
export type NinetailedProviderProps = NinetailedProviderInstantiationProps | ({
|
|
21
|
+
ninetailed: Ninetailed;
|
|
22
|
+
} & ExperimentProviderProps);
|
|
23
|
+
export declare const NinetailedProvider: (props: React.PropsWithChildren<NinetailedProviderProps>) => JSX.Element;
|
|
24
|
+
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { Profile, Variant } from '@ninetailed/experience.js-shared';
|
|
2
2
|
export type { ExperienceConfiguration, ExperienceType, EXPERIENCE_TRAIT_PREFIX, } from '@ninetailed/experience.js';
|
|
3
3
|
export { NinetailedProvider } from './NinetailedProvider';
|
|
4
|
-
export type { NinetailedProviderProps } from './NinetailedProvider';
|
|
4
|
+
export type { NinetailedProviderProps, NinetailedProviderInstantiationProps, } from './NinetailedProvider';
|
|
5
5
|
export { useNinetailed } from './useNinetailed';
|
|
6
6
|
export { useProfile } from './useProfile';
|
|
7
7
|
export { usePersonalize } from './usePersonalize';
|
package/lib/useProfile.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare const useProfile: () => {
|
|
|
10
10
|
status: "success";
|
|
11
11
|
profile: {
|
|
12
12
|
id: string;
|
|
13
|
-
stableId: string;
|
|
14
13
|
random: number;
|
|
15
14
|
audiences: string[];
|
|
16
15
|
traits: import("@ninetailed/experience.js-shared").Properties;
|
|
@@ -29,7 +28,6 @@ export declare const useProfile: () => {
|
|
|
29
28
|
timezone?: string | undefined;
|
|
30
29
|
};
|
|
31
30
|
session: {
|
|
32
|
-
id: string;
|
|
33
31
|
isReturningVisitor: boolean;
|
|
34
32
|
landingPage: {
|
|
35
33
|
path: string;
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-beta.3",
|
|
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": "
|
|
11
|
-
"react-is": "18.2.0",
|
|
10
|
+
"@ninetailed/experience.js": "5.0.0-beta.3",
|
|
12
11
|
"react-intersection-observer": "8.34.0",
|
|
13
|
-
"@ninetailed/experience.js-shared": "
|
|
12
|
+
"@ninetailed/experience.js-shared": "5.0.0-beta.3",
|
|
14
13
|
"radash": "10.9.0",
|
|
15
14
|
"analytics": "0.8.1"
|
|
16
15
|
},
|