cja-phoenix 1.2.21 → 1.2.23

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,7 +1,7 @@
1
1
  {
2
2
  "name": "cja-phoenix",
3
3
  "configKey": "cja-phoenix",
4
- "version": "1.2.21",
4
+ "version": "1.2.23",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -16,11 +16,8 @@ export const useValidateForm = (options) => {
16
16
  await validate();
17
17
  if (validForm.value) {
18
18
  if (!submitLock.value) {
19
- console.log("Toggle submitLock");
20
19
  submitLock.value = true;
21
- console.log("Executing callback");
22
20
  await options.onSubmit?.();
23
- console.log("Toggle submitLock");
24
21
  submitLock.value = false;
25
22
  }
26
23
  } else {
@@ -0,0 +1,9 @@
1
+ export declare const getAbTestVersion: (journeyId: string | undefined, config: {
2
+ formType: "FUNNEL" | "LANDING" | "RESULTS_PAGE";
3
+ enabled: boolean;
4
+ experiment: string;
5
+ condition?: {
6
+ type: "utmSource";
7
+ utmSource: string;
8
+ };
9
+ }) => Promise<string>;
@@ -0,0 +1,41 @@
1
+ import { useRuntimeConfig, useCookie, updateForm } from "#imports";
2
+ export const getAbTestVersion = async (journeyId, config) => {
3
+ const { apiURL } = useRuntimeConfig().public;
4
+ const abTestCookie = useCookie(`abTestVersion_${config.experiment}`);
5
+ const fetchAbTestVersion = async () => fetch(new URL("/core/apis/data/abTestServiceLookup", apiURL), {
6
+ method: "post",
7
+ body: JSON.stringify({
8
+ experimentName: config.experiment,
9
+ journeyId
10
+ })
11
+ }).then((r) => r.json()).then(async (d) => {
12
+ const abTestVersion = d.version || "control";
13
+ abTestCookie.value = abTestVersion;
14
+ await updateForm({
15
+ journeyId,
16
+ step: 0,
17
+ stepName: "AB Test Version",
18
+ formType: config.formType,
19
+ eventType: "STEP_CHANGED",
20
+ payload: {
21
+ abTestName: config.experiment,
22
+ abTestVersion
23
+ }
24
+ });
25
+ return abTestVersion;
26
+ });
27
+ if (!abTestCookie.value && journeyId && config.enabled) {
28
+ if (config.condition) {
29
+ switch (config.condition.type) {
30
+ case "utmSource":
31
+ const url = new URL(location.href);
32
+ if (url.searchParams.get("utm_source") == config.condition.utmSource) {
33
+ return fetchAbTestVersion();
34
+ }
35
+ }
36
+ } else {
37
+ return fetchAbTestVersion();
38
+ }
39
+ }
40
+ return abTestCookie.value || "control";
41
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cja-phoenix",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "Phoenix utility",
5
5
  "repository": "comparaja/phoenix",
6
6
  "license": "MIT",