@lookiero/checkout 5.2.0-beta.0 → 5.3.0-beta.0
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/dist/infrastructure/testing/asyncKameleoon.d.ts +4 -1
- package/dist/infrastructure/testing/asyncKameleoon.js +15 -10
- package/dist/infrastructure/testing/kameleoon.d.ts +22 -3
- package/dist/infrastructure/testing/kameleoon.js +3 -1
- package/dist/infrastructure/testing/kameleoonEnvironment.d.ts +3 -4
- package/dist/infrastructure/testing/react/kameleoon.d.ts +1 -1
- package/dist/infrastructure/testing/react/kameleoon.js +1 -0
- package/dist/infrastructure/testing/react/kameleoon.web.d.ts +1 -1
- package/dist/infrastructure/testing/react/kameleoon.web.js +5 -3
- package/dist/infrastructure/testing/react/useAssignedVariationByExperimentId.d.ts +1 -1
- package/dist/infrastructure/testing/react/useAssignedVariationByExperimentId.js +1 -1
- package/dist/infrastructure/testing/react/useAssignedVariationByExperimentId.web.js +3 -1
- package/dist/infrastructure/testing/react/useKameleoon.d.ts +1 -1
- package/dist/infrastructure/testing/react/useTrackingConversion.d.ts +12 -0
- package/dist/infrastructure/testing/react/useTrackingConversion.js +6 -0
- package/dist/infrastructure/testing/react/useTrackingConversion.web.d.ts +3 -0
- package/dist/infrastructure/testing/react/useTrackingConversion.web.js +13 -0
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/hostDefaultReturnQuestionItem/HostDefaultReturnQuestionItem.js +3 -8
- package/dist/infrastructure/ui/components/organisms/returnQuestions/components/textareaReturnQuestionItem/TextareaReturnQuestionItem.js +3 -8
- package/dist/infrastructure/ui/hooks/useNewFeedbackExperiment.d.ts +14 -0
- package/dist/infrastructure/ui/hooks/useNewFeedbackExperiment.js +48 -0
- package/dist/infrastructure/ui/routing/Routing.js +5 -3
- package/dist/infrastructure/ui/views/item/Item.js +3 -8
- package/dist/shared/tracking/infrastructure/useTrackAssignedVariationByExperiment.d.ts +18 -0
- package/dist/shared/tracking/infrastructure/useTrackAssignedVariationByExperiment.js +24 -0
- package/dist/shared/tracking/tracking.d.ts +7 -2
- package/dist/shared/tracking/tracking.js +1 -0
- package/package.json +6 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Logger } from "../../shared/logging/Logger";
|
|
2
|
+
import { Kameleoon, KameleoonAPI } from "./Kameleoon";
|
|
2
3
|
declare global {
|
|
3
4
|
interface Window {
|
|
4
5
|
readonly Kameleoon: KameleoonAPI;
|
|
@@ -7,9 +8,11 @@ declare global {
|
|
|
7
8
|
}
|
|
8
9
|
interface AsyncKameleoonFunctionArgs {
|
|
9
10
|
readonly siteCode: string;
|
|
11
|
+
readonly logger: Logger;
|
|
10
12
|
}
|
|
11
13
|
interface AsyncKameleoonFunction {
|
|
12
14
|
(args: AsyncKameleoonFunctionArgs): Promise<Kameleoon>;
|
|
13
15
|
}
|
|
14
16
|
declare const asyncKameleoon: AsyncKameleoonFunction;
|
|
15
17
|
export { asyncKameleoon };
|
|
18
|
+
export type { AsyncKameleoonFunction };
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
+
import loadjs from "loadjs";
|
|
1
2
|
let instance;
|
|
2
|
-
const asyncKameleoon = async ({ siteCode }) => {
|
|
3
|
+
const asyncKameleoon = async ({ siteCode, logger }) => {
|
|
3
4
|
if (instance) {
|
|
4
5
|
return instance;
|
|
5
6
|
}
|
|
6
7
|
const init = async () => {
|
|
8
|
+
if (window.Kameleoon) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
7
11
|
try {
|
|
8
|
-
await
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"Content-Type": "application/json",
|
|
13
|
-
},
|
|
14
|
-
});
|
|
12
|
+
await loadjs(`//${siteCode}.kameleoon.eu/kameleoon.js`, { returnPromise: true });
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
logger.captureException(error);
|
|
15
16
|
}
|
|
16
|
-
catch (error) { }
|
|
17
17
|
};
|
|
18
18
|
const assignedVariantByExperimentId = ({ experimentId }) => {
|
|
19
19
|
let variation = undefined;
|
|
20
20
|
if (window.Kameleoon && !window.Cypress) {
|
|
21
|
-
window.Kameleoon.API.Core.load();
|
|
22
21
|
const experiment = window.Kameleoon.API.Experiments.getById(experimentId);
|
|
23
22
|
if (experiment && experiment.associatedVariation) {
|
|
24
23
|
variation = experiment.associatedVariation;
|
|
@@ -26,8 +25,14 @@ const asyncKameleoon = async ({ siteCode }) => {
|
|
|
26
25
|
}
|
|
27
26
|
return variation;
|
|
28
27
|
};
|
|
28
|
+
const trackConversion = ({ goalId }) => {
|
|
29
|
+
if (window.Kameleoon) {
|
|
30
|
+
window.Kameleoon.API.Goals.processConversion(goalId);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
29
33
|
instance = {
|
|
30
34
|
assignedVariantByExperimentId,
|
|
35
|
+
trackConversion,
|
|
31
36
|
};
|
|
32
37
|
await init();
|
|
33
38
|
return instance;
|
|
@@ -1,14 +1,28 @@
|
|
|
1
|
+
declare const EXCLUDED_VARIATION_NAME = "Excluded";
|
|
2
|
+
interface ExcludedVariation {
|
|
3
|
+
readonly id: null;
|
|
4
|
+
readonly name: typeof EXCLUDED_VARIATION_NAME;
|
|
5
|
+
}
|
|
1
6
|
interface Variation {
|
|
2
|
-
readonly id: number
|
|
7
|
+
readonly id: number;
|
|
8
|
+
readonly name: string;
|
|
3
9
|
}
|
|
10
|
+
declare const isExcludedVariation: (variation: Variation | ExcludedVariation) => variation is ExcludedVariation;
|
|
4
11
|
interface AssignedVariantByExperimentIdFunctionArgs {
|
|
5
12
|
readonly experimentId: string;
|
|
6
13
|
}
|
|
7
14
|
interface AssignedVariantByExperimentIdFunction {
|
|
8
|
-
(args: AssignedVariantByExperimentIdFunctionArgs): Variation | undefined;
|
|
15
|
+
(args: AssignedVariantByExperimentIdFunctionArgs): Variation | ExcludedVariation | undefined;
|
|
16
|
+
}
|
|
17
|
+
interface TrackConversionFunctionArgs {
|
|
18
|
+
readonly goalId: number;
|
|
19
|
+
}
|
|
20
|
+
interface TrackConversionFunction {
|
|
21
|
+
(args: TrackConversionFunctionArgs): void;
|
|
9
22
|
}
|
|
10
23
|
interface Kameleoon {
|
|
11
24
|
readonly assignedVariantByExperimentId: AssignedVariantByExperimentIdFunction;
|
|
25
|
+
readonly trackConversion: TrackConversionFunction;
|
|
12
26
|
}
|
|
13
27
|
interface Experiment {
|
|
14
28
|
readonly id: string;
|
|
@@ -20,11 +34,16 @@ interface Experiments {
|
|
|
20
34
|
interface Core {
|
|
21
35
|
readonly load: () => void;
|
|
22
36
|
}
|
|
37
|
+
interface Goals {
|
|
38
|
+
readonly processConversion: (goalNameOrID: string | number, revenue?: number) => void;
|
|
39
|
+
}
|
|
23
40
|
interface API {
|
|
24
41
|
readonly Core: Core;
|
|
25
42
|
readonly Experiments: Experiments;
|
|
43
|
+
readonly Goals: Goals;
|
|
26
44
|
}
|
|
27
45
|
interface KameleoonAPI {
|
|
28
46
|
readonly API: API;
|
|
29
47
|
}
|
|
30
|
-
export
|
|
48
|
+
export { isExcludedVariation };
|
|
49
|
+
export type { Kameleoon, Variation, KameleoonAPI, TrackConversionFunction, AssignedVariantByExperimentIdFunction, ExcludedVariation, };
|
|
@@ -2,11 +2,10 @@ interface Experiment<T extends string> {
|
|
|
2
2
|
readonly id: string;
|
|
3
3
|
readonly variations: Record<T, string>;
|
|
4
4
|
}
|
|
5
|
-
interface Experiments {
|
|
6
|
-
[key: string]: Experiment<string>;
|
|
7
|
-
}
|
|
8
5
|
interface KameleoonEnvironment {
|
|
9
6
|
readonly siteCode: string;
|
|
10
|
-
readonly experiments:
|
|
7
|
+
readonly experiments: {
|
|
8
|
+
readonly newFeedback: Experiment<"v1">;
|
|
9
|
+
};
|
|
11
10
|
}
|
|
12
11
|
export type { KameleoonEnvironment };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FC, ReactNode } from "react";
|
|
2
2
|
interface KameleoonProps {
|
|
3
3
|
readonly siteCode: string;
|
|
4
|
-
readonly loader?: ReactNode;
|
|
5
4
|
readonly children: ReactNode;
|
|
5
|
+
readonly loader?: ReactNode;
|
|
6
6
|
}
|
|
7
7
|
declare const Kameleoon: FC<KameleoonProps>;
|
|
8
8
|
export { Kameleoon };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useLogger } from "../../../shared/logging/useLogger";
|
|
3
|
+
import { asyncKameleoon } from "../AsyncKameleoon";
|
|
3
4
|
import { KameleoonProvider } from "./useKameleoon";
|
|
4
5
|
const Kameleoon = ({ siteCode, loader = null, children }) => {
|
|
6
|
+
const logger = useLogger();
|
|
5
7
|
const [kameleoon, setKameleoon] = useState();
|
|
6
8
|
useEffect(() => {
|
|
7
|
-
const loadKameleoon = async () => setKameleoon(await asyncKameleoon({ siteCode }));
|
|
9
|
+
const loadKameleoon = async () => setKameleoon(await asyncKameleoon({ siteCode, logger }));
|
|
8
10
|
loadKameleoon();
|
|
9
|
-
}, [siteCode]);
|
|
11
|
+
}, [logger, siteCode]);
|
|
10
12
|
return kameleoon ? (React.createElement(KameleoonProvider, { kameleoon: kameleoon }, children)) :
|
|
11
13
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
14
|
loader;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
+
import { isExcludedVariation } from "../Kameleoon";
|
|
2
3
|
import { useKameleoon } from "./useKameleoon";
|
|
3
4
|
const useAssignedVariationByExperimentId = ({ experimentId, enabled = true, }) => {
|
|
4
5
|
const kameleoon = useKameleoon();
|
|
@@ -8,7 +9,8 @@ const useAssignedVariationByExperimentId = ({ experimentId, enabled = true, }) =
|
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
11
|
const variation = kameleoon.assignedVariantByExperimentId({ experimentId });
|
|
11
|
-
|
|
12
|
+
const isActiveVariation = variation && !isExcludedVariation(variation);
|
|
13
|
+
setAssignedVariation(isActiveVariation ? variation : null);
|
|
12
14
|
}, [enabled, experimentId, kameleoon]);
|
|
13
15
|
return { assignedVariation };
|
|
14
16
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface TrackConversionFunctionArgs {
|
|
2
|
+
readonly goalId: string;
|
|
3
|
+
}
|
|
4
|
+
interface TrackConversionFunction {
|
|
5
|
+
(args: TrackConversionFunctionArgs): void;
|
|
6
|
+
}
|
|
7
|
+
interface UseTrackingConversionFunction {
|
|
8
|
+
(): TrackConversionFunction;
|
|
9
|
+
}
|
|
10
|
+
declare const useTrackingConversion: UseTrackingConversionFunction;
|
|
11
|
+
export { useTrackingConversion };
|
|
12
|
+
export type { UseTrackingConversionFunction, TrackConversionFunction };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useKameleoon } from "./useKameleoon";
|
|
3
|
+
const useTrackingConversion = () => {
|
|
4
|
+
const kameleoon = useKameleoon();
|
|
5
|
+
const trackConversion = useCallback(({ goalId }) => {
|
|
6
|
+
if (!kameleoon) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
kameleoon.trackConversion({ goalId: Number(goalId) });
|
|
10
|
+
}, [kameleoon]);
|
|
11
|
+
return trackConversion;
|
|
12
|
+
};
|
|
13
|
+
export { useTrackingConversion };
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { Text, View } from "@lookiero/aurora";
|
|
2
2
|
import { useI18nMessage } from "@lookiero/i18n-react";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { useStaticInfo } from "../../../../../hooks/useStaticInfo";
|
|
4
|
+
import { NewFeedbackExperimentVariation, useNewFeedbackExperiment, } from "../../../../../hooks/useNewFeedbackExperiment";
|
|
6
5
|
import { I18nMessages } from "../../../../../i18n/i18n";
|
|
7
6
|
import { style } from "./HostDefaultReturnQuestionItem.style";
|
|
8
7
|
const HostDefaultReturnQuestionItem = ({ returnQuestion, children }) => {
|
|
9
8
|
const titleText = useI18nMessage({ id: returnQuestion.name });
|
|
10
9
|
const isAllOptions = returnQuestion.name === I18nMessages.RETURN_QUESTION_MAIN_ALL_OPINION;
|
|
11
10
|
/* Kameleoon experiment */
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const { assignedVariation: newFeedbackVariation } = useAssignedVariationByExperimentId({
|
|
15
|
-
experimentId: newFeedbackId,
|
|
16
|
-
});
|
|
17
|
-
const isReturnPage = newFeedbackVariation?.id === Number(variations.v2);
|
|
11
|
+
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
12
|
+
const isReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
18
13
|
/* Kameleoon experiment */
|
|
19
14
|
return (React.createElement(React.Fragment, null,
|
|
20
15
|
titleText && titleText !== " " ? (React.createElement(View, { style: [
|
|
@@ -2,19 +2,14 @@ import { View } from "@lookiero/aurora";
|
|
|
2
2
|
import { useIntl } from "@lookiero/i18n-react";
|
|
3
3
|
import React, { useCallback, useMemo } from "react";
|
|
4
4
|
import { InputField } from "../../../../../../../shared/ui/components/molecules/inputField/InputField";
|
|
5
|
-
import {
|
|
6
|
-
import { useStaticInfo } from "../../../../../hooks/useStaticInfo";
|
|
5
|
+
import { NewFeedbackExperimentVariation, useNewFeedbackExperiment, } from "../../../../../hooks/useNewFeedbackExperiment";
|
|
7
6
|
import { useReturnQuestionFeedbackForReturnQuestion } from "../../behaviors/useReturnQuestionFeedback";
|
|
8
7
|
import { style } from "./TextareaReturnQuestionItem.style";
|
|
9
8
|
const TextareaReturnQuestionItem = ({ returnQuestion, returnQuestionParent, testID, }) => {
|
|
10
9
|
const { formatMessage } = useIntl();
|
|
11
10
|
/* Kameleoon experiment */
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const { assignedVariation: newFeedbackVariation } = useAssignedVariationByExperimentId({
|
|
15
|
-
experimentId: newFeedbackId,
|
|
16
|
-
});
|
|
17
|
-
const isReturnPage = newFeedbackVariation?.id === Number(variations.v2);
|
|
11
|
+
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
12
|
+
const isReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
18
13
|
/* Kameleoon experiment */
|
|
19
14
|
const placeholderText = useMemo(() => (returnQuestion.placeholder ? formatMessage({ id: returnQuestion.placeholder }) : ""), [formatMessage, returnQuestion.placeholder]);
|
|
20
15
|
const { feedback, onChange } = useReturnQuestionFeedbackForReturnQuestion({ returnQuestion: returnQuestionParent });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { Country } from "../../../projection/shared/country";
|
|
3
|
+
declare enum NewFeedbackExperimentVariation {
|
|
4
|
+
CONTROL = "control",
|
|
5
|
+
RETURN_PAGE = "return_page"
|
|
6
|
+
}
|
|
7
|
+
interface NewFeedbackExperimentProviderProps {
|
|
8
|
+
readonly country: Country;
|
|
9
|
+
readonly customerId: string;
|
|
10
|
+
readonly children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
declare const NewFeedbackExperimentProvider: FC<NewFeedbackExperimentProviderProps>;
|
|
13
|
+
declare const useNewFeedbackExperiment: () => NewFeedbackExperimentVariation;
|
|
14
|
+
export { useNewFeedbackExperiment, NewFeedbackExperimentProvider, NewFeedbackExperimentVariation };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { createContext, useContext, useEffect, useMemo, useRef } from "react";
|
|
2
|
+
import invariant from "tiny-invariant";
|
|
3
|
+
import { useTrackAssignedVariationByExperiment } from "../../../shared/tracking/infrastructure/useTrackAssignedVariationByExperiment";
|
|
4
|
+
import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
|
|
5
|
+
import { useViewFirstAvailableCheckoutByCustomerId } from "../../projection/checkout/react/useViewFirstAvailableCheckoutByCustomerId";
|
|
6
|
+
import { useAssignedVariationByExperimentId } from "../../testing/react/useAssignedVariationByExperimentId";
|
|
7
|
+
import { useStaticInfo } from "./useStaticInfo";
|
|
8
|
+
var NewFeedbackExperimentVariation;
|
|
9
|
+
(function (NewFeedbackExperimentVariation) {
|
|
10
|
+
NewFeedbackExperimentVariation["CONTROL"] = "control";
|
|
11
|
+
NewFeedbackExperimentVariation["RETURN_PAGE"] = "return_page";
|
|
12
|
+
})(NewFeedbackExperimentVariation || (NewFeedbackExperimentVariation = {}));
|
|
13
|
+
const NewFeedbackExperimentContext = createContext(null);
|
|
14
|
+
const NewFeedbackExperimentProvider = ({ customerId, country, children }) => {
|
|
15
|
+
const { kameleoon: { experiments: { newFeedback: { id: newFeedbackId, variations }, }, }, } = useStaticInfo();
|
|
16
|
+
const [checkout] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
17
|
+
const { assignedVariation: newFeedbackVariation } = useAssignedVariationByExperimentId({
|
|
18
|
+
experimentId: newFeedbackId,
|
|
19
|
+
});
|
|
20
|
+
const trackAssignedVariation = useTrackAssignedVariationByExperiment({
|
|
21
|
+
checkoutId: checkout?.id,
|
|
22
|
+
country,
|
|
23
|
+
experimentId: newFeedbackId,
|
|
24
|
+
});
|
|
25
|
+
const value = useMemo(() => ({
|
|
26
|
+
variation: newFeedbackVariation?.id === Number(variations.v1)
|
|
27
|
+
? NewFeedbackExperimentVariation.RETURN_PAGE
|
|
28
|
+
: NewFeedbackExperimentVariation.CONTROL,
|
|
29
|
+
}), [newFeedbackVariation?.id, variations.v1]);
|
|
30
|
+
const assignedVariantTracked = useRef(false);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (assignedVariantTracked.current || !newFeedbackVariation || !checkout?.id) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
trackAssignedVariation({ assignedVariation: newFeedbackVariation });
|
|
36
|
+
assignedVariantTracked.current = true;
|
|
37
|
+
}, [checkout?.id, newFeedbackVariation, trackAssignedVariation]);
|
|
38
|
+
if (!checkout) {
|
|
39
|
+
return React.createElement(Spinner, null);
|
|
40
|
+
}
|
|
41
|
+
return React.createElement(NewFeedbackExperimentContext.Provider, { value: value }, children);
|
|
42
|
+
};
|
|
43
|
+
const useNewFeedbackExperiment = () => {
|
|
44
|
+
const newFeedbackExperiment = useContext(NewFeedbackExperimentContext);
|
|
45
|
+
invariant(newFeedbackExperiment, "Your are trying to use the useNewFeedbackExperiment hook without wrapping your app with the <NewFeedbackExperimentProvider>.");
|
|
46
|
+
return newFeedbackExperiment.variation;
|
|
47
|
+
};
|
|
48
|
+
export { useNewFeedbackExperiment, NewFeedbackExperimentProvider, NewFeedbackExperimentVariation };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { lazy, memo, Suspense } from "react";
|
|
2
2
|
import { Navigate, Outlet, useRoutes as reactRouterUseRoutes } from "react-router-native";
|
|
3
3
|
import { Spinner } from "../../../shared/ui/components/atoms/spinner/Spinner";
|
|
4
|
-
import { Kameleoon } from "../../testing/react/
|
|
4
|
+
import { Kameleoon } from "../../testing/react/Kameleoon";
|
|
5
|
+
import { NewFeedbackExperimentProvider } from "../hooks/useNewFeedbackExperiment";
|
|
5
6
|
import { StaticInfoProvider } from "../hooks/useStaticInfo";
|
|
6
7
|
import { App } from "../views/App";
|
|
7
8
|
import { CheckoutPaymentModal } from "../views/checkout/components/checkoutPaymentModal/CheckoutPaymentModal";
|
|
@@ -25,8 +26,9 @@ const Routing = ({ basePath = "", customer, order, subscription, locale, I18n, k
|
|
|
25
26
|
React.createElement(I18n, { loader: React.createElement(Spinner, null), locale: locale, onError: onI18nError },
|
|
26
27
|
React.createElement(Kameleoon, { loader: React.createElement(Spinner, null), siteCode: kameleoon.siteCode },
|
|
27
28
|
React.createElement(CheckoutMiddleware, { customerId: customer?.customerId, onNotAccessible: onNotAccessible },
|
|
28
|
-
React.createElement(
|
|
29
|
-
React.createElement(
|
|
29
|
+
React.createElement(NewFeedbackExperimentProvider, { country: customer?.country, customerId: customer?.customerId },
|
|
30
|
+
React.createElement(App, null,
|
|
31
|
+
React.createElement(Outlet, null)))))))))),
|
|
30
32
|
children: [
|
|
31
33
|
{
|
|
32
34
|
path: Routes.ITEM,
|
|
@@ -18,13 +18,12 @@ import { useViewFirstAvailableCheckoutByCustomerId } from "../../../projection/c
|
|
|
18
18
|
import { useViewFiveItemsDiscountByCustomerId } from "../../../projection/checkout/react/useViewFiveItemsDiscountByCustomerId";
|
|
19
19
|
import { useViewIsSizeChangeEnabledByCheckoutId } from "../../../projection/checkout/react/useViewIsSizeChangeEnabledByCheckoutId";
|
|
20
20
|
import { useListReturnQuestionsByCheckoutItemId } from "../../../projection/returnQuestion/react/useListReturnQuestionsByCheckoutItemId";
|
|
21
|
-
import { useAssignedVariationByExperimentId } from "../../../testing/react/useAssignedVariationByExperimentId";
|
|
22
21
|
import { TrackingPage } from "../../../tracking/tracking";
|
|
23
22
|
import { FiveItemsDiscountBanner } from "../../components/atoms/fiveItemsDiscountBanner/FiveItemsDiscountBanner";
|
|
24
23
|
import { ReturnQuestionFeedbackProvider } from "../../components/organisms/returnQuestions/behaviors/useReturnQuestionFeedback";
|
|
25
24
|
import { ItemDetailHeader } from "../../components/templates/header/itemDetailHeader/ItemDetailHeader";
|
|
26
25
|
import { ItemHeader } from "../../components/templates/header/itemHeader/ItemHeader";
|
|
27
|
-
import {
|
|
26
|
+
import { NewFeedbackExperimentVariation, useNewFeedbackExperiment } from "../../hooks/useNewFeedbackExperiment";
|
|
28
27
|
import { Routes } from "../../routing/routes";
|
|
29
28
|
import { useBasePath } from "../../routing/useBasePath";
|
|
30
29
|
import { style } from "./Item.style";
|
|
@@ -42,12 +41,8 @@ const Item = ({ customerId, country, layout: Layout }) => {
|
|
|
42
41
|
const [checkout, checkoutStatus] = useViewFirstAvailableCheckoutByCustomerId({ customerId });
|
|
43
42
|
const checkoutItem = checkout?.items.find((checkoutItem) => checkoutItem.id === id);
|
|
44
43
|
/* Kameleoon experiment */
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const { assignedVariation: newFeedbackVariation } = useAssignedVariationByExperimentId({
|
|
48
|
-
experimentId: newFeedbackId,
|
|
49
|
-
});
|
|
50
|
-
const redirectToReturnPage = newFeedbackVariation?.id === Number(variations.v2);
|
|
44
|
+
const newFeedbackVariation = useNewFeedbackExperiment();
|
|
45
|
+
const redirectToReturnPage = newFeedbackVariation === NewFeedbackExperimentVariation.RETURN_PAGE;
|
|
51
46
|
/* Kameleoon experiment */
|
|
52
47
|
/* SizeChange and Booking */
|
|
53
48
|
const [isSizeChangeEnabled, sizeChangeEnabledStatus] = useViewIsSizeChangeEnabledByCheckoutId({
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Variation } from "../../../infrastructure/testing/Kameleoon";
|
|
2
|
+
import { Country } from "../../../projection/shared/country";
|
|
3
|
+
interface TrackAssignedVariationFunctionArgs {
|
|
4
|
+
readonly assignedVariation: Variation;
|
|
5
|
+
}
|
|
6
|
+
interface TrackAssignedVariationFunction {
|
|
7
|
+
(args: TrackAssignedVariationFunctionArgs): void;
|
|
8
|
+
}
|
|
9
|
+
interface UseTrackAssignedVariationByExperimentFunctionArgs {
|
|
10
|
+
readonly experimentId: string;
|
|
11
|
+
readonly country: Country;
|
|
12
|
+
readonly checkoutId: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface UseTrackAssignedVariationByExperimentFunction {
|
|
15
|
+
(args: UseTrackAssignedVariationByExperimentFunctionArgs): TrackAssignedVariationFunction;
|
|
16
|
+
}
|
|
17
|
+
declare const useTrackAssignedVariationByExperiment: UseTrackAssignedVariationByExperimentFunction;
|
|
18
|
+
export { useTrackAssignedVariationByExperiment };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { PROJECT } from "../../../infrastructure/tracking/tracking";
|
|
3
|
+
import { TrackingEvent, TrackingEventCategory } from "../tracking";
|
|
4
|
+
import { useEmitUserEvent } from "./useEmitUserEvent";
|
|
5
|
+
const useTrackAssignedVariationByExperiment = ({ experimentId, country, checkoutId, }) => {
|
|
6
|
+
const emitUserEvent = useEmitUserEvent();
|
|
7
|
+
const trackAssignedVariation = useCallback(({ assignedVariation }) => {
|
|
8
|
+
if (!checkoutId || !assignedVariation) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const abTestTrackingEvent = {
|
|
12
|
+
event: TrackingEvent.AB_TEST,
|
|
13
|
+
eventCategory: TrackingEventCategory.NAVIGATION,
|
|
14
|
+
section: PROJECT,
|
|
15
|
+
store: country,
|
|
16
|
+
checkoutId,
|
|
17
|
+
experiment: experimentId,
|
|
18
|
+
variation: String(assignedVariation.id),
|
|
19
|
+
};
|
|
20
|
+
emitUserEvent(abTestTrackingEvent);
|
|
21
|
+
}, [checkoutId, country, emitUserEvent, experimentId]);
|
|
22
|
+
return trackAssignedVariation;
|
|
23
|
+
};
|
|
24
|
+
export { useTrackAssignedVariationByExperiment };
|
|
@@ -19,7 +19,8 @@ declare enum TrackingEvent {
|
|
|
19
19
|
PRESS_BACK = "press_back",
|
|
20
20
|
PRESS_NEXT = "press_next",
|
|
21
21
|
PRESS_PREVIOUS = "press_previous",
|
|
22
|
-
CHECKOUT = "checkout"
|
|
22
|
+
CHECKOUT = "checkout",
|
|
23
|
+
AB_TEST = "abtest"
|
|
23
24
|
}
|
|
24
25
|
declare enum TrackingEventCategory {
|
|
25
26
|
NAVIGATION = "navigation",
|
|
@@ -103,5 +104,9 @@ interface CheckoutTrackingEvent extends BaseTrackingEvent {
|
|
|
103
104
|
};
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
|
-
|
|
107
|
+
interface ABTestTrackingEvent extends BaseTrackingEvent {
|
|
108
|
+
readonly experiment: string;
|
|
109
|
+
readonly variation: string;
|
|
110
|
+
}
|
|
111
|
+
export type { BaseTrackingEvent, ChangeFeedbackTrackingEvent, CheckoutTrackingEvent, ImageViewTrackingEvent, ItemPageViewTrackingEvent, KeepItemTrackingEvent, PageViewTrackingEvent, PressContinueTrackingEvent, PressItemTrackingEvent, PressPricingTrackingEvent, ReplaceItemTrackingEvent, ResetItemTrackingEvent, ReturnItemTrackingEvent, TabViewTrackingEvent, PressMenuTrackingEvent, PressBackTrackingEvent, PressNextTrackingEvent, PressPreviousTrackingEvent, ABTestTrackingEvent, };
|
|
107
112
|
export { TrackingEvent, TrackingEventCategory };
|
|
@@ -16,6 +16,7 @@ var TrackingEvent;
|
|
|
16
16
|
TrackingEvent["PRESS_NEXT"] = "press_next";
|
|
17
17
|
TrackingEvent["PRESS_PREVIOUS"] = "press_previous";
|
|
18
18
|
TrackingEvent["CHECKOUT"] = "checkout";
|
|
19
|
+
TrackingEvent["AB_TEST"] = "abtest";
|
|
19
20
|
})(TrackingEvent || (TrackingEvent = {}));
|
|
20
21
|
var TrackingEventCategory;
|
|
21
22
|
(function (TrackingEventCategory) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lookiero/checkout",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0-beta.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@gorhom/portal": "^1.0.14",
|
|
30
|
-
"@lookiero/aurora": "
|
|
31
|
-
"@lookiero/aurora-fonts": "
|
|
32
|
-
"@lookiero/aurora-iconfont": "
|
|
30
|
+
"@lookiero/aurora": ">=5",
|
|
31
|
+
"@lookiero/aurora-fonts": ">=2",
|
|
32
|
+
"@lookiero/aurora-iconfont": ">=3",
|
|
33
33
|
"@lookiero/i18n": "^0.9.0",
|
|
34
34
|
"@lookiero/i18n-react": "^0.9.0",
|
|
35
35
|
"@lookiero/messaging": "^8.1.1",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@react-spring/native": "9.6.1",
|
|
38
38
|
"@sentry/react-native": "^4.13.0",
|
|
39
39
|
"inline-style-prefixer": "6.0.1",
|
|
40
|
+
"loadjs": "^4.2.0",
|
|
40
41
|
"lodash": "^4.17.21",
|
|
41
42
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
42
43
|
"react-native-safe-area-context": "^4.5.0",
|
|
@@ -82,6 +83,7 @@
|
|
|
82
83
|
"@testing-library/react-native": "^11.5.0",
|
|
83
84
|
"@trivago/prettier-plugin-sort-imports": "^3.4.0",
|
|
84
85
|
"@types/jest": "^29.2.4",
|
|
86
|
+
"@types/loadjs": "^4.0.4",
|
|
85
87
|
"@types/pino-pretty": "^5.0.0",
|
|
86
88
|
"@types/react": "~18.0.27",
|
|
87
89
|
"@types/react-dom": "~18.0.10",
|