cja-phoenix 1.2.49 → 1.2.50

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.49",
4
+ "version": "1.2.50",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,4 +1,3 @@
1
- export * from './Form.js';
2
- export * from './Grid.js';
3
- export * from './Icon.js';
4
- export * from './JourneyConfig.js';
1
+ export * from "./Form.js";
2
+ export * from "./Grid.js";
3
+ export * from "./Icon.js";
@@ -1,4 +1,3 @@
1
1
  export * from "./Form.js";
2
2
  export * from "./Grid.js";
3
3
  export * from "./Icon.js";
4
- export * from "./JourneyConfig.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cja-phoenix",
3
- "version": "1.2.49",
3
+ "version": "1.2.50",
4
4
  "description": "Phoenix utility",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,19 +0,0 @@
1
- import type { JourneyLocation, VerticalCode } from "../types/JourneyConfig.js";
2
- export declare const useCjaGtm: (vertical: VerticalCode, source: JourneyLocation | {
3
- formType: string;
4
- location: string;
5
- }) => {
6
- trackStepEvent: (options: {
7
- stepName: string;
8
- stepNumber: number;
9
- stepDetails?: any;
10
- action?: string;
11
- }) => void;
12
- trackPurchase: (options: {
13
- source: string;
14
- product: any;
15
- label: string;
16
- listing?: string;
17
- index?: number;
18
- }) => void;
19
- };
@@ -1,175 +0,0 @@
1
- import { useGtm } from "@gtm-support/vue-gtm";
2
- export const useCjaGtm = (vertical, source) => {
3
- const gtm = useGtm();
4
- const category = (() => {
5
- switch (vertical) {
6
- case "HL":
7
- return "mortgage";
8
- case "PL":
9
- return "personal-loan new-funnel";
10
- case "EN":
11
- return "energy";
12
- case "BB":
13
- return "broadband";
14
- case "CI":
15
- return "car-insurance-funnel";
16
- case "CC":
17
- return "credit-card";
18
- }
19
- })();
20
- const { formType, location } = (() => {
21
- switch (source) {
22
- case "funnel":
23
- return { formType: "FUNNEL", location: "Funnel" };
24
- case "results":
25
- return { formType: "RESULTS", location: "Results" };
26
- case "checkout":
27
- return { formType: "CHECKOUT", location: "Checkout" };
28
- case "contact":
29
- return { formType: "CONTACT", location: "Contact" };
30
- default:
31
- return source;
32
- }
33
- })();
34
- const trackStepEvent = (options) => {
35
- gtm?.trackEvent({
36
- event: `${location} Step`,
37
- eventDetails: {
38
- category,
39
- value: options.stepName,
40
- noninteraction: false,
41
- location,
42
- action: options.action,
43
- properties: {
44
- stepName: options.stepName,
45
- stepNumber: options.stepNumber,
46
- stepDetails: options.stepDetails,
47
- formType
48
- }
49
- }
50
- });
51
- };
52
- const trackPurchase = (options) => {
53
- const { source: source2, product, label, listing, index } = options;
54
- gtm?.trackEvent({
55
- event: "purchase",
56
- eventDetails: {
57
- source: `Conversion - ${source2}`,
58
- action: "Results Purchase",
59
- label,
60
- category,
61
- location,
62
- properties: {
63
- list: listing
64
- }
65
- },
66
- ecommerce: {
67
- purchase: {
68
- actionField: {
69
- id: Math.floor(
70
- Math.random() * (999999999999 - Math.pow(10, 11)) + Math.pow(10, 11)
71
- ),
72
- revenue: "5.00",
73
- action: "purchase"
74
- },
75
- products: (() => {
76
- switch (category) {
77
- case "personal-loan new-funnel":
78
- return [
79
- {
80
- name: product.description,
81
- id: product.cggId,
82
- brand: product.name,
83
- position: index,
84
- dimension3: source2,
85
- dimension4: product.banner.bannerType,
86
- dimension5: product.showCTALeadCapture,
87
- dimension6: `apr:${product.attributes.apr}, totalRepayment:${product.attributes.totalRepayment}, monthlyRepayment:${product.attributes.monthlyRepayment}`,
88
- category: "personal-loan",
89
- list: listing,
90
- price: "5.00",
91
- quantity: 1
92
- }
93
- ];
94
- case "energy":
95
- return [
96
- {
97
- name: label,
98
- id: product.productId,
99
- brand: product.provider,
100
- position: product.index + 1,
101
- dimension3: source2,
102
- category,
103
- list: listing,
104
- price: "5.00",
105
- quantity: 1
106
- }
107
- ];
108
- case "mortgage":
109
- return [
110
- {
111
- name: product.name,
112
- id: product.cggId,
113
- brand: product.provider.name,
114
- position: index,
115
- scoreValue: null,
116
- approvalRate: "unavailable",
117
- dimension3: source2,
118
- dimension6: `apr:${product.attributes.taeg}, totalRepayment:${product.attributes.mtic}, monthlyRepayment:${product.attributes.installment}`,
119
- category,
120
- list: listing,
121
- price: "5.00",
122
- quantity: 1
123
- }
124
- ];
125
- case "broadband":
126
- return [
127
- {
128
- name: product.description,
129
- id: product.cggId,
130
- brand: product.name,
131
- position: index,
132
- dimension3: source2,
133
- dimension4: product.banner.bannerType,
134
- dimension5: product.showCTALeadCapture,
135
- dimension6: `service: ${product.offer.service}, noOfChannels: ${product.tv.noOfChannels}, maxSpeedDownload: ${product.speed.maxSpeedDownload}, publicPrice: ${product.fee.publicPrice}`,
136
- category,
137
- list: listing,
138
- price: "5.00",
139
- quantity: 1
140
- }
141
- ];
142
- case "credit-card":
143
- return [
144
- {
145
- name: product.description,
146
- id: product.cggId,
147
- brand: product.name,
148
- position: index,
149
- approvalRate: product.approvalRate,
150
- dimension3: source2,
151
- dimension4: product.banner.bannerType,
152
- dimension5: product.showCTALeadCapture,
153
- dimension6: `annualFee: ${product.fee.annualFee}, basicAPR: ${product.fee.taeg}, basic: ${product.fee.tan}`,
154
- category: "credit-card",
155
- list: listing,
156
- price: "5.00",
157
- quantity: 1
158
- }
159
- ];
160
- default:
161
- console.error(
162
- `Unrecognized category ${category}, implement vertical specific gtm product`
163
- );
164
- return [{}];
165
- }
166
- })()
167
- }
168
- }
169
- });
170
- };
171
- return {
172
- trackStepEvent,
173
- trackPurchase
174
- };
175
- };
@@ -1,11 +0,0 @@
1
- import { type ComputedRef } from "vue";
2
- import type { StepData } from "../types/JourneyConfig.js";
3
- export declare const useFunnelConfig: (structure: ComputedRef<Map<string, string[]>>) => {
4
- steps: ComputedRef<string[]>;
5
- structure: ComputedRef<Map<string, string[]>>;
6
- currentStep: ComputedRef<StepData>;
7
- totalSteps: ComputedRef<number>;
8
- getStep: (step: string | number | undefined) => StepData | undefined;
9
- goNextStep: (relative?: boolean) => Promise<void>;
10
- goPrevStep: (relative?: boolean) => Promise<void>;
11
- };
@@ -1,68 +0,0 @@
1
- import { navigateTo, useRoute, useRouter } from "#app";
2
- import { computed } from "vue";
3
- export const useFunnelConfig = (structure) => {
4
- const route = useRouter().currentRoute;
5
- const steps = computed(() => Array.from(structure.value.keys()));
6
- const currentStep = computed(
7
- () => getStep(route.value.path.split("/").reverse()[0]) || currentStep.value
8
- );
9
- const totalSteps = computed(() => structure.value.size);
10
- const getStep = (step) => {
11
- if (step === void 0) return;
12
- const stepName = typeof step == "string" ? step : steps.value[step];
13
- const stepFields = stepName && structure.value.get(stepName);
14
- return stepName && stepFields ? {
15
- index: steps.value.indexOf(stepName),
16
- number: steps.value.indexOf(stepName) + 1,
17
- name: stepName,
18
- path: route.value.path.replace(/[^/]+(?=\/$|$)/g, stepName),
19
- fields: stepFields
20
- } : void 0;
21
- };
22
- const currentStepStatic = getStep(
23
- route.value.path.split("/").reverse()[0]
24
- );
25
- const goNextStep = async (relative) => {
26
- if (currentStep.value) {
27
- const nextStep = (() => {
28
- if (relative) {
29
- return getStep(currentStep.value.index + 1);
30
- } else if (currentStepStatic) {
31
- return getStep(currentStepStatic.index + 1);
32
- }
33
- })();
34
- if (nextStep) {
35
- await navigateTo({
36
- path: nextStep.path,
37
- query: useRoute().query
38
- });
39
- }
40
- }
41
- };
42
- const goPrevStep = async (relative) => {
43
- if (currentStep.value) {
44
- const prevStep = (() => {
45
- if (relative) {
46
- return getStep(currentStep.value.index - 1);
47
- } else if (currentStepStatic) {
48
- return;
49
- }
50
- })();
51
- if (prevStep) {
52
- await navigateTo({
53
- path: prevStep.path,
54
- query: useRoute().query
55
- });
56
- }
57
- }
58
- };
59
- return {
60
- steps,
61
- structure,
62
- currentStep,
63
- totalSteps,
64
- getStep,
65
- goNextStep,
66
- goPrevStep
67
- };
68
- };
@@ -1,21 +0,0 @@
1
- import type { SelectOption } from "../types/Form.js";
2
- import type { StepData } from "../types/JourneyConfig.js";
3
- import type { ComputedRef } from "vue";
4
- export declare function useFunnelSummary(options: {
5
- currentStep: ComputedRef<StepData>;
6
- structure: ComputedRef<Map<string, string[]>>;
7
- store: any;
8
- }): {
9
- stepIncludes: (field: string) => boolean;
10
- displayValue: (value: any, options?: SelectOption[]) => any;
11
- displayLabel: (value: any, label: string) => string;
12
- displayCurrency: (value: number | undefined) => string;
13
- displayPercent: (value: number | undefined, maxDigits?: number) => string;
14
- };
15
- export declare function useFunnelSummary(): {
16
- stepIncludes: undefined;
17
- displayValue: (value: any, options?: SelectOption[]) => any;
18
- displayLabel: (value: any, label: string) => string;
19
- displayCurrency: (value: number | undefined) => string;
20
- displayPercent: (value: number | undefined, maxDigits?: number) => string;
21
- };
@@ -1,18 +0,0 @@
1
- import { formatCurrency, formatPercent } from "../utils/formatValue.js";
2
- export function useFunnelSummary(options) {
3
- const stepIncludes = options ? (() => {
4
- const { currentStep, structure, store } = options;
5
- return (field) => (currentStep.value.fields.includes(field) || store[field] !== void 0) && Array.from(structure.value.values()).flat().includes(field);
6
- })() : void 0;
7
- const displayValue = (value, options2) => options2 ? options2.find((o) => o.value == value)?.label ?? "-" : value ?? "-";
8
- const displayLabel = (value, label) => value !== void 0 ? label : "-";
9
- const displayCurrency = (value) => value ? formatCurrency(value) : "-";
10
- const displayPercent = (value, maxDigits = 2) => value ? formatPercent(value, maxDigits) : "-";
11
- return {
12
- stepIncludes,
13
- displayValue,
14
- displayLabel,
15
- displayCurrency,
16
- displayPercent
17
- };
18
- }
@@ -1,11 +0,0 @@
1
- import type { JourneyLocation } from '../types/JourneyConfig.js';
2
- export declare const useJourneyConfig: (location: JourneyLocation, options: {
3
- locations: JourneyLocation[];
4
- initialStep: string;
5
- lastUrls: Map<JourneyLocation, string>;
6
- }) => {
7
- locations: JourneyLocation[];
8
- initialStep: string;
9
- lastUrls: Map<JourneyLocation, string>;
10
- previousUrl: string | undefined;
11
- };
@@ -1,13 +0,0 @@
1
- export const useJourneyConfig = (location, options) => {
2
- const {
3
- locations,
4
- initialStep,
5
- lastUrls
6
- } = options;
7
- return {
8
- locations,
9
- initialStep,
10
- lastUrls,
11
- previousUrl: lastUrls.get(locations[locations.indexOf(location) - 1])
12
- };
13
- };
@@ -1,10 +0,0 @@
1
- export type VerticalCode = "HL" | "PL" | "EN" | "BB" | "CI" | "CC";
2
- export type StepType = "LANDING" | "FUNNEL" | "RESULTS" | "CHECKOUT" | "LEAD_CAPTURE";
3
- export type JourneyLocation = "funnel" | "results" | "checkout" | "contact";
4
- export type StepData = {
5
- index: number;
6
- number: number;
7
- name: string;
8
- path: string;
9
- fields: string[];
10
- };
File without changes
@@ -1,10 +0,0 @@
1
- export declare const applyProductData: (options: {
2
- action: string;
3
- journeyId: string | undefined;
4
- index: number;
5
- productName: string;
6
- productId: string;
7
- providerId: string;
8
- viewId: string;
9
- category?: string;
10
- }) => Promise<unknown>;
@@ -1,22 +0,0 @@
1
- import { useRoute, useRuntimeConfig } from "#imports";
2
- export const applyProductData = (options) => {
3
- const { apiURL } = useRuntimeConfig().public;
4
- const { path } = useRoute();
5
- return $fetch("/core/apis/data/applyProductData", {
6
- baseURL: apiURL,
7
- method: "POST",
8
- body: {
9
- path,
10
- intent: "apply",
11
- action: options.action || "OPEN_APPLICATION_FORM",
12
- journeyId: options.journeyId,
13
- position: options.index,
14
- offerSelected: options.productName,
15
- cggId: options.productId,
16
- providerCggId: options.providerId,
17
- category: options.category,
18
- viewId: options.viewId,
19
- has_been_clicked: true
20
- }
21
- });
22
- };
@@ -1,2 +0,0 @@
1
- export declare const getFromUrl: (searchParam: string, removeFromUrl?: boolean) => string | string[] | undefined;
2
- export declare const removeFromUrl: (searchParam: string) => void;
@@ -1,25 +0,0 @@
1
- export const getFromUrl = (searchParam, removeFromUrl2) => {
2
- const url = new URL(window.location.href);
3
- return url.searchParams.has(searchParam) ? (() => {
4
- const param = url.searchParams.getAll(searchParam).map((p) => decodeURIComponent(p));
5
- if (removeFromUrl2) {
6
- url.searchParams.delete(searchParam);
7
- history.replaceState(history.state, "", url.toString());
8
- }
9
- switch (param.length) {
10
- case 0:
11
- return void 0;
12
- case 1:
13
- return param[0];
14
- default:
15
- return param;
16
- }
17
- })() : void 0;
18
- };
19
- export const removeFromUrl = (searchParam) => {
20
- const url = new URL(window.location.href);
21
- if (url.searchParams.has(searchParam)) {
22
- url.searchParams.delete(searchParam);
23
- history.replaceState(history.state, "", url.toString());
24
- }
25
- };
@@ -1,71 +0,0 @@
1
- type MultilinkStoryblok = {
2
- fieldtype: 'multilink';
3
- id: string;
4
- url: string;
5
- cached_url: string;
6
- target?: '_blank' | '_self';
7
- anchor?: string;
8
- rel?: string;
9
- title?: string;
10
- prep?: string;
11
- linktype: 'story';
12
- story?: {
13
- name: string;
14
- created_at?: string;
15
- published_at?: string;
16
- id: number;
17
- uuid: string;
18
- content?: {
19
- [k: string]: any;
20
- };
21
- slug: string;
22
- full_slug: string;
23
- sort_by_date?: null | string;
24
- position?: number;
25
- tag_list?: string[];
26
- is_startpage?: boolean;
27
- parent_id?: null | number;
28
- meta_data?: null | {
29
- [k: string]: any;
30
- };
31
- group_id?: string;
32
- first_published_at?: string;
33
- release_id?: null | number;
34
- lang?: string;
35
- path?: null | string;
36
- alternates?: any[];
37
- default_full_slug?: null | string;
38
- translated_slugs?: null | any[];
39
- [k: string]: any;
40
- };
41
- [k: string]: any;
42
- } | {
43
- fieldtype: 'multilink';
44
- id: string;
45
- url: string;
46
- cached_url: string;
47
- target?: '_blank' | '_self';
48
- linktype: 'url';
49
- rel?: string;
50
- title?: string;
51
- [k: string]: any;
52
- } | {
53
- fieldtype: 'multilink';
54
- id: string;
55
- url: string;
56
- cached_url: string;
57
- target?: '_blank' | '_self';
58
- email?: string;
59
- linktype: 'email';
60
- [k: string]: any;
61
- } | {
62
- fieldtype: 'multilink';
63
- id: string;
64
- url: string;
65
- cached_url: string;
66
- target?: '_blank' | '_self';
67
- linktype: 'asset';
68
- [k: string]: any;
69
- };
70
- export declare const getStoryblokUrl: (link: MultilinkStoryblok | undefined) => string | undefined;
71
- export {};
@@ -1,35 +0,0 @@
1
- const parametersList = ["category"];
2
- export const getStoryblokUrl = (link) => {
3
- if (link) {
4
- const url = link.url || link.cached_url;
5
- const parameters = [];
6
- if (url) {
7
- let finalUrl = (() => {
8
- switch (link.linktype) {
9
- case "story":
10
- if (url === "/") {
11
- return "/";
12
- }
13
- return `/${url.replace(/\/$/g, "")}`;
14
- case "url":
15
- return url.replace(/\/$/g, "");
16
- case "asset":
17
- return url;
18
- }
19
- })();
20
- if (Object.keys(link).filter((k) => parametersList.includes(k)).length) {
21
- parametersList.forEach((p) => {
22
- if (link[p]) {
23
- parameters.push([p, link[p]]);
24
- }
25
- });
26
- finalUrl += `?${new URLSearchParams(parameters)}`;
27
- }
28
- if (link.anchor) {
29
- finalUrl += `#${link.anchor}`;
30
- }
31
- return finalUrl;
32
- }
33
- }
34
- return void 0;
35
- };
@@ -1 +0,0 @@
1
- export declare const jsonReviver: (data: any) => any;
@@ -1,18 +0,0 @@
1
- export const jsonReviver = (data) => JSON.parse(data, (_, v) => {
2
- if (typeof v == "string" && v.includes(",")) {
3
- return v.split(",");
4
- }
5
- if (v === "true" || v === "false") {
6
- return v === "true";
7
- }
8
- if ((Number(v) || v === "0") && typeof v != "boolean") {
9
- return Number(v);
10
- }
11
- if (v === "undefined") {
12
- return void 0;
13
- }
14
- if (v === "null") {
15
- return null;
16
- }
17
- return v;
18
- });
@@ -1,9 +0,0 @@
1
- import type { StepType } from "../types/index.js";
2
- export declare const updateForm: (options: {
3
- journeyId: string | undefined;
4
- step?: number;
5
- stepName?: string;
6
- isCompleted?: boolean;
7
- stepType: StepType;
8
- payload: Record<string, any>;
9
- }) => Promise<unknown>;
@@ -1,31 +0,0 @@
1
- import {
2
- useCookie,
3
- useRequestHeader,
4
- useRoute,
5
- useRuntimeConfig
6
- } from "#imports";
7
- export const updateForm = async (options) => {
8
- const { nucleusURL } = useRuntimeConfig().public;
9
- const { fullPath } = useRoute();
10
- const deviceIdCookie = useCookie("device_id");
11
- if (!deviceIdCookie.value) {
12
- throw new Error("deviceId missing");
13
- }
14
- return $fetch(`/journeys/${options.journeyId}`, {
15
- method: "PUT",
16
- baseURL: nucleusURL,
17
- body: {
18
- device_id: deviceIdCookie.value,
19
- referrer_url: useRequestHeader("Referer") || document.referrer,
20
- form_data_json: {
21
- ...options.payload
22
- },
23
- last_step_url: fullPath,
24
- last_step_type: options.stepType,
25
- last_step_number: options.step,
26
- last_step_name: options.stepName,
27
- last_activity_at: (/* @__PURE__ */ new Date()).toISOString(),
28
- is_completed: options.isCompleted
29
- }
30
- });
31
- };
@@ -1,4 +0,0 @@
1
- export declare const updateMarketingConsent: (options: {
2
- email: string;
3
- journeyId?: string;
4
- }) => Promise<unknown>;
@@ -1,13 +0,0 @@
1
- import { useRuntimeConfig } from "#imports";
2
- export const updateMarketingConsent = (options) => {
3
- const { apiURL } = useRuntimeConfig().public;
4
- return $fetch("/core/apis/data/verifyConsent", {
5
- baseURL: apiURL,
6
- method: "POST",
7
- body: {
8
- email: options.email,
9
- currentPageUrl: location.origin + location.pathname,
10
- journeyId: options.journeyId
11
- }
12
- });
13
- };