cja-phoenix 1.2.54 → 1.2.55
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/module.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { ref } from "vue";
|
|
1
|
+
import { nextTick, ref } from "vue";
|
|
2
2
|
export const useValidateForm = (options) => {
|
|
3
3
|
const validForm = ref(false);
|
|
4
4
|
const submitLock = ref(false);
|
|
5
5
|
const validate = async () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
await field.value.validate();
|
|
11
|
-
}
|
|
6
|
+
await nextTick();
|
|
7
|
+
const fields = options.fields?.filter((f) => f.value) ?? [];
|
|
8
|
+
for (const field of fields) {
|
|
9
|
+
await field.value.validate();
|
|
12
10
|
}
|
|
13
|
-
validForm.value = fields
|
|
11
|
+
validForm.value = fields.every((f) => f.value.meta.valid);
|
|
14
12
|
};
|
|
15
13
|
const submit = async () => {
|
|
16
14
|
await validate();
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
3
|
-
stepType: StepType;
|
|
4
|
-
enabled: boolean;
|
|
5
|
-
experiment: string;
|
|
6
|
-
condition?: {
|
|
7
|
-
type: "utmSource";
|
|
8
|
-
utmSource: string;
|
|
9
|
-
};
|
|
10
|
-
}) => Promise<any>;
|
|
1
|
+
export type AbTestVersion = "control" | "variant";
|
|
2
|
+
export declare function getAbTestVersion(experimentName: string): Promise<AbTestVersion>;
|
|
@@ -1,46 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
updateForm,
|
|
5
|
-
useRequestFetch
|
|
6
|
-
} from "#imports";
|
|
7
|
-
export const getAbTestVersion = async (journeyId, config) => {
|
|
8
|
-
const { apiURL } = useRuntimeConfig().public;
|
|
1
|
+
import { useCookie, useRequestFetch, useRuntimeConfig } from "#imports";
|
|
2
|
+
export async function getAbTestVersion(experimentName) {
|
|
3
|
+
const { nucleusURL } = useRuntimeConfig().public;
|
|
9
4
|
const requestFetch = useRequestFetch();
|
|
10
|
-
const abTestCookie = useCookie(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const abTestCookie = useCookie(
|
|
6
|
+
`abTestVersion_${experimentName}`
|
|
7
|
+
);
|
|
8
|
+
const deviceIdCookie = useCookie("device_id");
|
|
9
|
+
if (abTestCookie.value == "control" || abTestCookie.value == "variant") {
|
|
10
|
+
return abTestCookie.value;
|
|
11
|
+
}
|
|
12
|
+
const response = await requestFetch("/experiments/abtest", {
|
|
13
|
+
baseURL: nucleusURL,
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: {
|
|
16
|
+
"Content-Type": "application/json"
|
|
17
|
+
},
|
|
14
18
|
body: {
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
experiment_name: experimentName,
|
|
20
|
+
device_id: deviceIdCookie.value
|
|
17
21
|
}
|
|
18
|
-
}).then(async (d) => {
|
|
19
|
-
const abTestVersion = d.version || "control";
|
|
20
|
-
abTestCookie.value = abTestVersion;
|
|
21
|
-
await updateForm({
|
|
22
|
-
journeyId,
|
|
23
|
-
stepName: "AB Test Version",
|
|
24
|
-
stepType: config.stepType,
|
|
25
|
-
payload: {
|
|
26
|
-
abTestName: config.experiment,
|
|
27
|
-
abTestVersion
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return abTestVersion;
|
|
31
22
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const url = new URL(location.href);
|
|
37
|
-
if (url.searchParams.get("utm_source") == config.condition.utmSource) {
|
|
38
|
-
return fetchAbTestVersion();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
return fetchAbTestVersion();
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return abTestCookie.value || "control";
|
|
46
|
-
};
|
|
23
|
+
const version = response?.version_shown || "control";
|
|
24
|
+
abTestCookie.value = version;
|
|
25
|
+
return version;
|
|
26
|
+
}
|