@ninetailed/experience.js-react 4.1.0-beta.3 → 4.2.0-beta.1
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 +9 -33
- package/index.js +9 -33
- package/lib/Experience/useExperiementsContext.d.ts +1 -1
- package/lib/Experience/useExperienceSelectionMiddleware.d.ts +5 -5
- package/lib/Experience/useExperiments.d.ts +1 -1
- package/lib/useProfile.d.ts +6 -1
- package/package.json +3 -3
- package/lib/Experience/ConditionalComponentRenderer.d.ts +0 -7
package/index.cjs
CHANGED
|
@@ -2042,29 +2042,6 @@ const useJoinExperiment = () => {
|
|
|
2042
2042
|
return context.joinExperiment;
|
|
2043
2043
|
};
|
|
2044
2044
|
|
|
2045
|
-
/**
|
|
2046
|
-
* This component is used to conditionally render Experiences which may include empty variants.
|
|
2047
|
-
* It is essential to intercept the props within the ComponentWrapper to be able to get the current variant.
|
|
2048
|
-
* Note: the passed props can be altered by the render plugins.
|
|
2049
|
-
*/
|
|
2050
|
-
const ConditionalRenderComponent = _a => {
|
|
2051
|
-
var {
|
|
2052
|
-
children
|
|
2053
|
-
} = _a,
|
|
2054
|
-
props = __rest(_a, ["children"]);
|
|
2055
|
-
if ('hidden' in props && props.hidden) {
|
|
2056
|
-
return null;
|
|
2057
|
-
}
|
|
2058
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
2059
|
-
children: React__default["default"].Children.map(children, child => {
|
|
2060
|
-
if ( /*#__PURE__*/React__default["default"].isValidElement(child)) {
|
|
2061
|
-
return /*#__PURE__*/React__default["default"].cloneElement(child, props);
|
|
2062
|
-
}
|
|
2063
|
-
return null;
|
|
2064
|
-
})
|
|
2065
|
-
});
|
|
2066
|
-
};
|
|
2067
|
-
|
|
2068
2045
|
const useExperienceSelectionMiddleware = ({
|
|
2069
2046
|
experiences,
|
|
2070
2047
|
baseline,
|
|
@@ -2222,23 +2199,22 @@ const Experience = _a => {
|
|
|
2222
2199
|
}))
|
|
2223
2200
|
}), baseline.id);
|
|
2224
2201
|
}
|
|
2202
|
+
const isVariantHidden = 'hidden' in variant && variant.hidden;
|
|
2225
2203
|
return jsxRuntime.jsx(TrackExperience, Object.assign({
|
|
2226
2204
|
experience: experience,
|
|
2227
2205
|
variant: variant,
|
|
2228
2206
|
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2229
2207
|
profile: profile
|
|
2230
2208
|
}, {
|
|
2231
|
-
children:
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
audience:
|
|
2237
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2238
|
-
}
|
|
2209
|
+
children: !isVariantHidden ? /*#__PURE__*/React.createElement(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
|
|
2210
|
+
key: `${experience.id}-${variant.id}`,
|
|
2211
|
+
ninetailed: {
|
|
2212
|
+
isPersonalized,
|
|
2213
|
+
audience: {
|
|
2214
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2239
2215
|
}
|
|
2240
|
-
}
|
|
2241
|
-
})
|
|
2216
|
+
}
|
|
2217
|
+
})) : null
|
|
2242
2218
|
}));
|
|
2243
2219
|
};
|
|
2244
2220
|
|
package/index.js
CHANGED
|
@@ -2029,29 +2029,6 @@ const useJoinExperiment = () => {
|
|
|
2029
2029
|
return context.joinExperiment;
|
|
2030
2030
|
};
|
|
2031
2031
|
|
|
2032
|
-
/**
|
|
2033
|
-
* This component is used to conditionally render Experiences which may include empty variants.
|
|
2034
|
-
* It is essential to intercept the props within the ComponentWrapper to be able to get the current variant.
|
|
2035
|
-
* Note: the passed props can be altered by the render plugins.
|
|
2036
|
-
*/
|
|
2037
|
-
const ConditionalRenderComponent = _a => {
|
|
2038
|
-
var {
|
|
2039
|
-
children
|
|
2040
|
-
} = _a,
|
|
2041
|
-
props = __rest(_a, ["children"]);
|
|
2042
|
-
if ('hidden' in props && props.hidden) {
|
|
2043
|
-
return null;
|
|
2044
|
-
}
|
|
2045
|
-
return jsx(Fragment, {
|
|
2046
|
-
children: React.Children.map(children, child => {
|
|
2047
|
-
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
2048
|
-
return /*#__PURE__*/React.cloneElement(child, props);
|
|
2049
|
-
}
|
|
2050
|
-
return null;
|
|
2051
|
-
})
|
|
2052
|
-
});
|
|
2053
|
-
};
|
|
2054
|
-
|
|
2055
2032
|
const useExperienceSelectionMiddleware = ({
|
|
2056
2033
|
experiences,
|
|
2057
2034
|
baseline,
|
|
@@ -2209,23 +2186,22 @@ const Experience = _a => {
|
|
|
2209
2186
|
}))
|
|
2210
2187
|
}), baseline.id);
|
|
2211
2188
|
}
|
|
2189
|
+
const isVariantHidden = 'hidden' in variant && variant.hidden;
|
|
2212
2190
|
return jsx(TrackExperience, Object.assign({
|
|
2213
2191
|
experience: experience,
|
|
2214
2192
|
variant: variant,
|
|
2215
2193
|
// the profile is definitely defined, otherwise there wouldn't be an experience selected
|
|
2216
2194
|
profile: profile
|
|
2217
2195
|
}, {
|
|
2218
|
-
children:
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
audience:
|
|
2224
|
-
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2225
|
-
}
|
|
2196
|
+
children: !isVariantHidden ? /*#__PURE__*/createElement$1(Component, Object.assign({}, Object.assign(Object.assign({}, passthroughProps), variant), {
|
|
2197
|
+
key: `${experience.id}-${variant.id}`,
|
|
2198
|
+
ninetailed: {
|
|
2199
|
+
isPersonalized,
|
|
2200
|
+
audience: {
|
|
2201
|
+
id: (audience === null || audience === void 0 ? void 0 : audience.id) || 'all visitors'
|
|
2226
2202
|
}
|
|
2227
|
-
}
|
|
2228
|
-
})
|
|
2203
|
+
}
|
|
2204
|
+
})) : null
|
|
2229
2205
|
}));
|
|
2230
2206
|
};
|
|
2231
2207
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const useExperimentsContext: () => {
|
|
2
|
-
experiments: import("@ninetailed/experience.js").ExperienceConfiguration<any>[];
|
|
2
|
+
experiments: import("@ninetailed/experience.js-shared").ExperienceConfiguration<any>[];
|
|
3
3
|
joinExperiment: import("./useProvideJoinExperiment").JoinExperiment;
|
|
4
4
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ExperienceConfiguration, Profile, Reference } from '@ninetailed/experience.js-shared';
|
|
2
|
-
type UseExperienceSelectionMiddlewareArg = {
|
|
3
|
-
experiences: ExperienceConfiguration<
|
|
2
|
+
type UseExperienceSelectionMiddlewareArg<Variant extends Reference> = {
|
|
3
|
+
experiences: ExperienceConfiguration<Variant>[];
|
|
4
4
|
baseline: Reference;
|
|
5
5
|
profile: Profile | null;
|
|
6
6
|
};
|
|
7
|
-
export declare const useExperienceSelectionMiddleware: ({ experiences, baseline, profile, }: UseExperienceSelectionMiddlewareArg) => ({ experience, variant, }: import("@ninetailed/experience.js").ExperienceSelectionMiddlewareReturnArg<
|
|
8
|
-
experience: ExperienceConfiguration<
|
|
9
|
-
variant:
|
|
7
|
+
export declare const useExperienceSelectionMiddleware: <Variant extends Reference>({ experiences, baseline, profile, }: UseExperienceSelectionMiddlewareArg<Variant>) => ({ experience, variant, }: import("@ninetailed/experience.js").ExperienceSelectionMiddlewareReturnArg<Variant | import("@ninetailed/experience.js-shared").VariantRef>) => {
|
|
8
|
+
experience: ExperienceConfiguration<Variant | import("@ninetailed/experience.js-shared").VariantRef> | null;
|
|
9
|
+
variant: Variant | import("@ninetailed/experience.js-shared").VariantRef | null;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
package/lib/useProfile.d.ts
CHANGED
|
@@ -41,7 +41,12 @@ export declare const useProfile: () => {
|
|
|
41
41
|
averageSessionLength: number;
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
error: null;
|
|
44
|
+
error: null; /**
|
|
45
|
+
* This effect compares the old and new profile state before updating it.
|
|
46
|
+
* We use a ref to avoid an infinite loop which can happen when an empty profile state was updated with no changes.
|
|
47
|
+
* This behaviour occurred as the validation handling on the error property was not set properly in the "CreateProfile" and "UpdateProfile" endpoint types.
|
|
48
|
+
* Furthermore, it was also observed, that it "only" occurred when the preview plugin was used in parallel.
|
|
49
|
+
*/
|
|
45
50
|
} | {
|
|
46
51
|
loading: boolean;
|
|
47
52
|
from: "api" | "hydrated";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js-react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0-beta.1",
|
|
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": "4.
|
|
11
|
+
"@ninetailed/experience.js": "4.2.0-beta.1",
|
|
12
12
|
"react-intersection-observer": "8.34.0",
|
|
13
|
-
"@ninetailed/experience.js-shared": "4.
|
|
13
|
+
"@ninetailed/experience.js-shared": "4.2.0-beta.1",
|
|
14
14
|
"analytics": "0.8.1"
|
|
15
15
|
},
|
|
16
16
|
"module": "./index.js",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* This component is used to conditionally render Experiences which may include empty variants.
|
|
4
|
-
* It is essential to intercept the props within the ComponentWrapper to be able to get the current variant.
|
|
5
|
-
* Note: the passed props can be altered by the render plugins.
|
|
6
|
-
*/
|
|
7
|
-
export declare const ConditionalRenderComponent: React.FC<React.PropsWithChildren>;
|