@wikicasa-dev/utilities 0.1.2 → 0.2.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/README.md +32 -2
- package/dist/index.d.ts +2 -3
- package/dist/main.d.ts +0 -0
- package/dist/utilities.cjs +4 -4
- package/dist/utilities.iife.js +4 -4
- package/dist/utilities.mjs +890 -1185
- package/dist/utils/FunctionUtils.d.ts +2 -2
- package/dist/utils/StringUtils.d.ts +1 -0
- package/index.html +13 -0
- package/package.json +4 -3
- package/src/index.ts +3 -5
- package/src/main.ts +1 -0
- package/src/services/placesAPI.ts +1 -1
- package/src/services/publicUserAPI.ts +1 -1
- package/src/services/realEstateAPI.ts +1 -1
- package/src/utils/FunctionUtils.ts +13 -13
- package/src/utils/StringUtils.ts +8 -0
- package/dist/utils/AppRedirectUtils.d.ts +0 -1
- package/dist/utils/GAEvents.d.ts +0 -2
- package/src/utils/AppRedirectUtils.ts +0 -26
- package/src/utils/GAEvents.ts +0 -414
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @returns a function correctly typed as Promise
|
|
5
5
|
*/
|
|
6
6
|
export declare function isPromise<T>(functionToCheck: any): Promise<T>;
|
|
7
|
-
export declare function debounce<T extends
|
|
7
|
+
export declare function debounce<T extends (...args: any[]) => any, TReturn>(timeout: {
|
|
8
8
|
id?: ReturnType<typeof setTimeout>;
|
|
9
9
|
delay: number;
|
|
10
|
-
}, func: T): (...args: any) => Promise<TReturn>;
|
|
10
|
+
}, func: T): (...args: any[]) => Promise<TReturn>;
|
|
@@ -10,3 +10,4 @@ export declare function decodeTextWithEntities(strWithEntities: string | null):
|
|
|
10
10
|
* */
|
|
11
11
|
export declare function replaceAllTokens(str: string, mapObj: Record<string, string>): string;
|
|
12
12
|
export declare function cleanASCII(str: string): string;
|
|
13
|
+
export declare const stringToHyphened: (str?: string) => string;
|
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Utilities</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wikicasa-dev/utilities",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Wikicasa frontend utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/utilities.cjs",
|
|
@@ -45,11 +45,12 @@
|
|
|
45
45
|
"leaflet-draw": "^1.0.4",
|
|
46
46
|
"leaflet-freedraw": "^2.13.3",
|
|
47
47
|
"uuid": "^9.0.0",
|
|
48
|
-
"@wikicasa-dev/types": "^0.0
|
|
48
|
+
"@wikicasa-dev/types": "^0.9.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"dev": "vite",
|
|
52
52
|
"build": "tsc && vite build",
|
|
53
|
-
"preview": "vite preview"
|
|
53
|
+
"preview": "vite preview",
|
|
54
|
+
"prepublish": "pnpm build"
|
|
54
55
|
}
|
|
55
56
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// SERVICE
|
|
2
|
-
|
|
3
2
|
export {
|
|
4
3
|
sendAgencyContactAsync,
|
|
5
4
|
getAgencyById,
|
|
@@ -87,8 +86,6 @@ export { userValuationWithPhotoFeedback } from "@services/wikicasaPro";
|
|
|
87
86
|
|
|
88
87
|
// UTILITIES
|
|
89
88
|
|
|
90
|
-
export { redirectToApp } from "@utils/AppRedirectUtils";
|
|
91
|
-
|
|
92
89
|
export { isArrNullOrEmpty } from "@utils/ArrayUtils";
|
|
93
90
|
|
|
94
91
|
export { rgba } from "@utils/ColorUtils";
|
|
@@ -115,13 +112,13 @@ export {
|
|
|
115
112
|
|
|
116
113
|
export { hashEmail } from "@utils/EmailUtils";
|
|
117
114
|
|
|
115
|
+
export { debounce } from "@utils/FunctionUtils";
|
|
116
|
+
|
|
118
117
|
export {
|
|
119
118
|
showAddFavoritesIcon,
|
|
120
119
|
showRemoveFavoritesIcons,
|
|
121
120
|
} from "@utils/FavoriteUtils";
|
|
122
121
|
|
|
123
|
-
export { sendGAEvent } from "@utils/GAEvents";
|
|
124
|
-
|
|
125
122
|
export {
|
|
126
123
|
googlePlaceConverter,
|
|
127
124
|
getPlaceFromGAutocomplete,
|
|
@@ -166,6 +163,7 @@ export {
|
|
|
166
163
|
formatAddress,
|
|
167
164
|
decodeTextWithEntities,
|
|
168
165
|
cleanASCII,
|
|
166
|
+
stringToHyphened
|
|
169
167
|
} from "@utils/StringUtils";
|
|
170
168
|
|
|
171
169
|
export { appendQueryString } from "@utils/URLBuilderUtils";
|
package/src/main.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log("Hello World");
|
|
@@ -3,7 +3,7 @@ import { handleAxiosError } from "./servicesUtils";
|
|
|
3
3
|
import type { PLACE_TYPE, Place } from "@wikicasa-dev/types";
|
|
4
4
|
import { appendQueryString } from "@utils/URLBuilderUtils";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
const baseURL = window["_baseURLIt"];
|
|
8
8
|
const baseController = "/ws";
|
|
9
9
|
|
|
@@ -8,7 +8,7 @@ import { getDefaultSaveSearchBean } from "@wikicasa-dev/types";
|
|
|
8
8
|
import axios, { AxiosError } from "axios";
|
|
9
9
|
import { handleAxiosError } from "./servicesUtils";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
const baseURL: string = window["_baseURLIt"];
|
|
13
13
|
const baseController = `${baseURL}/rest/publicUser`;
|
|
14
14
|
|
|
@@ -10,20 +10,20 @@ export function isPromise<T>(functionToCheck: any): Promise<T> {
|
|
|
10
10
|
return functionToCheck as Promise<T>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
|
|
14
|
+
export function debounce<T extends (...args: any[]) => any, TReturn>(timeout: {
|
|
15
|
+
id?: ReturnType<typeof setTimeout>,
|
|
16
|
+
delay: number
|
|
17
|
+
}, func: T): (...args: any[]) => Promise<TReturn> {
|
|
18
|
+
return (...args: any[]): Promise<TReturn> => new Promise((resolve, reject) => {
|
|
19
19
|
timeout.id && clearTimeout(timeout.id);
|
|
20
20
|
timeout.id = setTimeout(() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
try {
|
|
22
|
+
const res = func(...args) as TReturn;
|
|
23
|
+
resolve(res);
|
|
24
|
+
} catch (err) {
|
|
25
|
+
reject(err)
|
|
26
|
+
}
|
|
27
27
|
}, timeout.delay);
|
|
28
|
-
|
|
28
|
+
})
|
|
29
29
|
}
|
package/src/utils/StringUtils.ts
CHANGED
|
@@ -65,3 +65,11 @@ export function replaceAllTokens(
|
|
|
65
65
|
export function cleanASCII(str: string): string {
|
|
66
66
|
return str.replace(/[\uA78C\uA78B]/g, "'").replace(/[^\x00-\x7F]/g, "");
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
export const stringToHyphened = (str = ""): string => {
|
|
70
|
+
if(!str || !str.trim())
|
|
71
|
+
return ""
|
|
72
|
+
|
|
73
|
+
str = str.trim()
|
|
74
|
+
return str.replace(" ", "-").toLowerCase()
|
|
75
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const redirectToApp: (eventLocation?: "Banner" | "MenuUserModal") => void;
|
package/dist/utils/GAEvents.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { GAEvent, GaPhoneShowPayload, GaRequestPayload, GaValuationPayload, GaValuationSellingPayload, GenericPayload } from "@wikicasa-dev/types";
|
|
2
|
-
export declare function sendGAEvent<T extends GaValuationPayload | GaRequestPayload | GaPhoneShowPayload | GenericPayload | GaValuationSellingPayload>(GAEvent: GAEvent, payload?: T): void;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const redirectToApp = (
|
|
2
|
-
eventLocation: "Banner" | "MenuUserModal" = "Banner"
|
|
3
|
-
): void => {
|
|
4
|
-
if (window.navigator.userAgent.includes("iPhone")) {
|
|
5
|
-
//firefox on ios can't open the app
|
|
6
|
-
if (!window.navigator.userAgent.match(/firefox|fxios/i))
|
|
7
|
-
window.location.replace("wikicasa://");
|
|
8
|
-
|
|
9
|
-
setTimeout(() => {
|
|
10
|
-
window.location.replace(
|
|
11
|
-
"https://apps.apple.com/it/app/wikicasa/id1626038379"
|
|
12
|
-
);
|
|
13
|
-
}, 500);
|
|
14
|
-
} else if (window.navigator.userAgent.includes("Android")) {
|
|
15
|
-
const url =
|
|
16
|
-
"intent://wikicasa.it/#Intent;scheme=https;package=it.wikicasa.wikicasa_app;end";
|
|
17
|
-
window.location.replace(url);
|
|
18
|
-
}
|
|
19
|
-
//@ts-ignore
|
|
20
|
-
window.dataLayer.push({
|
|
21
|
-
//GA4
|
|
22
|
-
event_name: "open_store",
|
|
23
|
-
event_location: eventLocation,
|
|
24
|
-
OS: window.navigator?.userAgent,
|
|
25
|
-
});
|
|
26
|
-
};
|
package/src/utils/GAEvents.ts
DELETED
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Nullable,
|
|
3
|
-
GA3Props,
|
|
4
|
-
GA4Props,
|
|
5
|
-
GAEvent,
|
|
6
|
-
GaPhoneShowPayload,
|
|
7
|
-
GaRequestPayload,
|
|
8
|
-
GaValuationPayload,
|
|
9
|
-
GaValuationSellingPayload,
|
|
10
|
-
GenericPayload,
|
|
11
|
-
ValuationEventObject,
|
|
12
|
-
} from "@wikicasa-dev/types";
|
|
13
|
-
|
|
14
|
-
const createBaseGAEvent = (
|
|
15
|
-
GA3_props: Nullable<GA3Props>,
|
|
16
|
-
GA4_props: GA4Props
|
|
17
|
-
): Partial<GA3Props> & GA4Props => {
|
|
18
|
-
return GA3_props ? { ...GA3_props, ...GA4_props } : { ...GA4_props };
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const sendValuationGAEvent = (payload: GaValuationPayload): void => {
|
|
22
|
-
const eventObject: ValuationEventObject = {
|
|
23
|
-
event: "GAevent",
|
|
24
|
-
eventCategory: "Valutazione immobile",
|
|
25
|
-
eventAction: payload.eventAction,
|
|
26
|
-
eventLabel: "Pagina valutazione",
|
|
27
|
-
//GA4
|
|
28
|
-
event_name:
|
|
29
|
-
payload.eventAction === "Share"
|
|
30
|
-
? "valuation_share"
|
|
31
|
-
: "valuation_share_modal",
|
|
32
|
-
event_location: "Valutazione",
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
if (payload.social) eventObject.social = payload.social;
|
|
36
|
-
|
|
37
|
-
//@ts-ignore
|
|
38
|
-
window["dataLayer"].push(eventObject);
|
|
39
|
-
};
|
|
40
|
-
const sendRequestGAEvent = (data: GaRequestPayload): void => {
|
|
41
|
-
//@ts-ignore
|
|
42
|
-
window["dataLayer"].push({
|
|
43
|
-
event: "GAevent",
|
|
44
|
-
eventCategory: data.id ? "Richiesta specifica" : "Richiesta agenzia",
|
|
45
|
-
eventAction: "Invio richiesta",
|
|
46
|
-
// eslint-disable-next-line max-len
|
|
47
|
-
eventLabel:
|
|
48
|
-
(data.franchise
|
|
49
|
-
? `${data.franchise} / AG_${data.agencyId}`
|
|
50
|
-
: `AG_${data.agencyId}`) +
|
|
51
|
-
(data.id
|
|
52
|
-
? ` / WK_${data.id} (${data.pageName}: ${
|
|
53
|
-
data.sale ? "vendita" : "affitto"
|
|
54
|
-
} / ${data.premium ? "premium" : data.lite ? "lite" : "free"})`
|
|
55
|
-
: ` (${data.pageName}: ${
|
|
56
|
-
data.premium ? "premium" : data.lite ? "lite" : "free"
|
|
57
|
-
})`),
|
|
58
|
-
franchise: data.franchise ? data.franchise : undefined,
|
|
59
|
-
agent_id: data.agentId ? `${data.agentId}` : undefined,
|
|
60
|
-
agent_email: data.agentEmail,
|
|
61
|
-
product_price: data.productPrice,
|
|
62
|
-
email: data.email,
|
|
63
|
-
//GA4
|
|
64
|
-
event_name: data.id ? "specific_request_lead" : "generic_request_lead",
|
|
65
|
-
event_location: `${data.pageName}`,
|
|
66
|
-
real_estate_id: data.id,
|
|
67
|
-
product_id: `WK_${data.id}`,
|
|
68
|
-
contract_type: data.id
|
|
69
|
-
? data.auction
|
|
70
|
-
? "auction"
|
|
71
|
-
: data.rent
|
|
72
|
-
? "rent"
|
|
73
|
-
: "sale"
|
|
74
|
-
: undefined,
|
|
75
|
-
price: data.price,
|
|
76
|
-
typology_name: data.typologyName,
|
|
77
|
-
agency_id: data.agencyId,
|
|
78
|
-
agency_name: data.agencyName,
|
|
79
|
-
franchise_id: data.franchise_id,
|
|
80
|
-
franchise_name: data.franchise_name,
|
|
81
|
-
subscription_type: data.premium ? "premium" : data.lite ? "lite" : "free",
|
|
82
|
-
premium: data.premium,
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const sendMortgageGAEvent = (): void => {
|
|
86
|
-
//@ts-ignore
|
|
87
|
-
window["dataLayer"].push({
|
|
88
|
-
event: "GAevent",
|
|
89
|
-
eventCategory: "Preventivo Mutuo",
|
|
90
|
-
eventAction: "Invio richiesta",
|
|
91
|
-
eventLabel: "Popup - Richiesta specifica",
|
|
92
|
-
//GA4
|
|
93
|
-
event_name: "mortgage_lead",
|
|
94
|
-
event_location: "Modale Richiesta Specifica",
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
const sendMailAlertSaveGAEvent = (): void => {
|
|
98
|
-
//@ts-ignore
|
|
99
|
-
window["dataLayer"].push({
|
|
100
|
-
event: "GAevent",
|
|
101
|
-
eventCategory: "Mail alert",
|
|
102
|
-
eventAction: "Ricerca salvata",
|
|
103
|
-
eventLabel: "Popup - Richiesta specifica",
|
|
104
|
-
//GA4
|
|
105
|
-
event_name: "mail_alert_save",
|
|
106
|
-
event_location: "Modale Richiesta Specifica",
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
const sendGenericRequestLead = (): void => {
|
|
110
|
-
//@ts-ignore
|
|
111
|
-
window["dataLayer"].push({
|
|
112
|
-
event: "GAevent",
|
|
113
|
-
eventCategory: "Richiesta generica",
|
|
114
|
-
eventAction: "Invio richiesta",
|
|
115
|
-
eventLabel: "Popup - Richiesta specifica",
|
|
116
|
-
//GA4
|
|
117
|
-
event_name: "generic_request_lead",
|
|
118
|
-
event_location: "Modale Richiesta Specifica",
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
const sendNewsletterSubscribeGAEvent = (): void => {
|
|
122
|
-
//@ts-ignore
|
|
123
|
-
window["dataLayer"].push({
|
|
124
|
-
event: "GAevent",
|
|
125
|
-
eventCategory: "Newsletter",
|
|
126
|
-
eventAction: "Iscrizione",
|
|
127
|
-
eventLabel: "Popup - Richiesta specifica",
|
|
128
|
-
//GA4
|
|
129
|
-
event_name: "newsletter_subscribe",
|
|
130
|
-
event_location: "Modale Richiesta Specifica",
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
const sendPhoneShowGAEvent = (agencyData: GaPhoneShowPayload): void => {
|
|
134
|
-
//@ts-ignore
|
|
135
|
-
window["dataLayer"].push({
|
|
136
|
-
event: "GAevent",
|
|
137
|
-
eventCategory: "Telefono",
|
|
138
|
-
eventAction: "Mostra telefono",
|
|
139
|
-
// eslint-disable-next-line max-len
|
|
140
|
-
eventLabel:
|
|
141
|
-
(agencyData.franchise
|
|
142
|
-
? `${agencyData.franchise} / AG_${agencyData.agencyId}`
|
|
143
|
-
: `AG_${agencyData.agencyId}`) +
|
|
144
|
-
// eslint-disable-next-line max-len
|
|
145
|
-
(agencyData.id
|
|
146
|
-
? ` / WK_${agencyData.id} (${agencyData.pageName}: ${
|
|
147
|
-
agencyData.sale ? "vendita" : "affitto"
|
|
148
|
-
} / ${
|
|
149
|
-
agencyData.premium ? "premium" : agencyData.lite ? "lite" : "free"
|
|
150
|
-
})`
|
|
151
|
-
: ` (${agencyData.pageName}: ${
|
|
152
|
-
agencyData.premium ? "premium" : agencyData.lite ? "lite" : "free"
|
|
153
|
-
})`),
|
|
154
|
-
franchise: agencyData.franchise ? agencyData.franchise : undefined,
|
|
155
|
-
product_id: agencyData.id ? `WK_${agencyData.id}` : undefined,
|
|
156
|
-
product_price: agencyData.product_price,
|
|
157
|
-
//GA4
|
|
158
|
-
event_name: "phone_show",
|
|
159
|
-
real_estate_id: `${agencyData.id}`,
|
|
160
|
-
contract_type: agencyData.auction
|
|
161
|
-
? "auction"
|
|
162
|
-
: agencyData.rent && !agencyData.sale
|
|
163
|
-
? "rent"
|
|
164
|
-
: "sale",
|
|
165
|
-
price: agencyData.price,
|
|
166
|
-
typology_name: agencyData.typologyName,
|
|
167
|
-
agency_id: agencyData.agencyId,
|
|
168
|
-
agency_name: agencyData?.agencyName,
|
|
169
|
-
franchise_id: agencyData.franchise ? agencyData.franchise_id : "",
|
|
170
|
-
franchise_name: agencyData.franchise,
|
|
171
|
-
premium: agencyData.premium,
|
|
172
|
-
subscription_type: agencyData.premium
|
|
173
|
-
? "premium"
|
|
174
|
-
: agencyData.lite
|
|
175
|
-
? "lite"
|
|
176
|
-
: "free",
|
|
177
|
-
event_location: agencyData.pageName,
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
const sendPublicUserLoginGAEvent = (): void => {
|
|
181
|
-
//@ts-ignore
|
|
182
|
-
window["dataLayer"].push({
|
|
183
|
-
event: "GAevent",
|
|
184
|
-
eventCategory: "Utenti pubblici",
|
|
185
|
-
eventAction: "Login",
|
|
186
|
-
eventLabel: "Modale Login",
|
|
187
|
-
//GA4
|
|
188
|
-
event_name: "login",
|
|
189
|
-
event_location: "login_modal",
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const sendNotificationOpenedGAEvent = (): void => {
|
|
194
|
-
const GAEventObj = createBaseGAEvent(
|
|
195
|
-
{
|
|
196
|
-
event: "GAevent",
|
|
197
|
-
eventCategory: "Mail alert",
|
|
198
|
-
eventAction: "Apertura notifica push",
|
|
199
|
-
eventLabel: "Notifica Push - Salva ricerca",
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
event: "GAevent",
|
|
203
|
-
event_name: "push_notification_opened",
|
|
204
|
-
event_location: "Notifica Push - Android_or_Web",
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
//@ts-ignore
|
|
208
|
-
window["dataLayer"].push({ event_location: "save_searches", ...GAEventObj });
|
|
209
|
-
};
|
|
210
|
-
const sendSignUpGAEvent = (): void => {
|
|
211
|
-
//@ts-ignore
|
|
212
|
-
window["dataLayer"].push(
|
|
213
|
-
createBaseGAEvent(
|
|
214
|
-
{
|
|
215
|
-
event: "GAevent",
|
|
216
|
-
eventCategory: "Utenti pubblici",
|
|
217
|
-
eventAction: "Registrazione",
|
|
218
|
-
eventLabel: "Modale registrazione",
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
event: "GAevent",
|
|
222
|
-
event_name: "public_user_sign_up",
|
|
223
|
-
event_location: "Modale Registrazione",
|
|
224
|
-
}
|
|
225
|
-
)
|
|
226
|
-
);
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const sendErrorRequestGAEvent = (): void => {
|
|
230
|
-
//@ts-ignore
|
|
231
|
-
window["dataLayer"].push({
|
|
232
|
-
event: "GAevent",
|
|
233
|
-
eventCategory: "Richiesta Specifica",
|
|
234
|
-
eventAction: "Errore Richiesta",
|
|
235
|
-
eventLabel: "Richiesta gia effettuata - 409",
|
|
236
|
-
//GA4
|
|
237
|
-
event_name: "specific_request_error",
|
|
238
|
-
event_location: "Modale Richiesta Specifica",
|
|
239
|
-
code_error: "request_already_made_409",
|
|
240
|
-
});
|
|
241
|
-
};
|
|
242
|
-
const sendPremiumInfoGAEvent = (): void => {
|
|
243
|
-
//@ts-ignore
|
|
244
|
-
window["dataLayer"].push(
|
|
245
|
-
createBaseGAEvent(
|
|
246
|
-
{
|
|
247
|
-
event: "GAevent",
|
|
248
|
-
eventCategory: "Premium",
|
|
249
|
-
eventAction: "Richiesta Informazioni",
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
event: "GAevent",
|
|
253
|
-
event_name: "premium_info",
|
|
254
|
-
event_location: "Pagina Premium",
|
|
255
|
-
}
|
|
256
|
-
)
|
|
257
|
-
);
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const sendValuationComplete = (): void => {
|
|
261
|
-
//@ts-ignore
|
|
262
|
-
window["dataLayer"].push(
|
|
263
|
-
createBaseGAEvent(
|
|
264
|
-
{
|
|
265
|
-
event: "GAevent",
|
|
266
|
-
eventCategory: "Valutazione immobile",
|
|
267
|
-
eventAction: "Invio richiesta",
|
|
268
|
-
eventLabel: "Pagina valutazione",
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
event: "GAevent",
|
|
272
|
-
event_name: "valuation_complete",
|
|
273
|
-
event_location: "Valutazione - Step 3",
|
|
274
|
-
}
|
|
275
|
-
)
|
|
276
|
-
);
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
const sendValuationLead = (
|
|
280
|
-
sellingPayload: GaValuationSellingPayload = {
|
|
281
|
-
isSelling: false,
|
|
282
|
-
}
|
|
283
|
-
): void => {
|
|
284
|
-
//@ts-ignore
|
|
285
|
-
window["dataLayer"].push(
|
|
286
|
-
createBaseGAEvent(null, {
|
|
287
|
-
event: "GAevent",
|
|
288
|
-
event_name: "valuation_lead",
|
|
289
|
-
event_location: "Valutazione - Step 3",
|
|
290
|
-
valuation_type: sellingPayload.isSelling ? "selling" : "valuation",
|
|
291
|
-
})
|
|
292
|
-
);
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
const sendDownloadPDF = (): void => {
|
|
296
|
-
//@ts-ignore
|
|
297
|
-
window["dataLayer"].push(
|
|
298
|
-
createBaseGAEvent(
|
|
299
|
-
{
|
|
300
|
-
event: "GAevent",
|
|
301
|
-
eventCategory: "Valutazione immobile",
|
|
302
|
-
eventAction: "Download PDF",
|
|
303
|
-
eventLabel: "Pagina valutazione",
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
event: "GAevent",
|
|
307
|
-
//GA4
|
|
308
|
-
event_name: "valuation_pdf_download",
|
|
309
|
-
event_location: "Valutazione",
|
|
310
|
-
}
|
|
311
|
-
)
|
|
312
|
-
);
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
const sendRequestModalInteractionGAEvent = (props: {
|
|
316
|
-
pageName: string;
|
|
317
|
-
}): void => {
|
|
318
|
-
const gaEvent = createBaseGAEvent(null, {
|
|
319
|
-
event: "GAevent",
|
|
320
|
-
event_name: "specific_request_interaction",
|
|
321
|
-
event_location: props.pageName,
|
|
322
|
-
});
|
|
323
|
-
//@ts-ignore
|
|
324
|
-
window["dataLayer"].push(gaEvent);
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
const copyAVMwidgetGAEvent = (): void => {
|
|
328
|
-
//@ts-ignore
|
|
329
|
-
window["dataLayer"].push(
|
|
330
|
-
createBaseGAEvent(
|
|
331
|
-
{
|
|
332
|
-
event: "GAevent",
|
|
333
|
-
eventCategory: "Widget AVM",
|
|
334
|
-
eventAction: "Copia Widget AVM",
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
event: "GAevent",
|
|
338
|
-
event_name: "copy_avm_widget",
|
|
339
|
-
event_location: "Pagina Widget AVM",
|
|
340
|
-
}
|
|
341
|
-
)
|
|
342
|
-
);
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
const copyTrendWidgetGAEvent = (): void => {
|
|
346
|
-
//@ts-ignore
|
|
347
|
-
window["dataLayer"].push(
|
|
348
|
-
createBaseGAEvent(
|
|
349
|
-
{
|
|
350
|
-
event: "GAevent",
|
|
351
|
-
eventCategory: "Widget Quotazioni",
|
|
352
|
-
eventAction: "Copia Widget Quotazioni",
|
|
353
|
-
},
|
|
354
|
-
{
|
|
355
|
-
event: "GAevent",
|
|
356
|
-
event_name: "copy_trend_widget",
|
|
357
|
-
event_location: "Pagina Widget Quotazioni",
|
|
358
|
-
}
|
|
359
|
-
)
|
|
360
|
-
);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
const sendAVMwidgetRequest = (): void => {
|
|
364
|
-
//@ts-ignore
|
|
365
|
-
window["dataLayer"].push(
|
|
366
|
-
createBaseGAEvent(
|
|
367
|
-
{
|
|
368
|
-
event: "GAevent",
|
|
369
|
-
eventCategory: "Widget AVM",
|
|
370
|
-
eventAction: "Invio Richiesta Widget AVM",
|
|
371
|
-
},
|
|
372
|
-
{
|
|
373
|
-
event: "GAevent",
|
|
374
|
-
event_name: "send_request_avm_widget",
|
|
375
|
-
event_location: "Pagina Widget AVM",
|
|
376
|
-
}
|
|
377
|
-
)
|
|
378
|
-
);
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
const GAEventHandler: Record<GAEvent, (...args: any[]) => void> = {
|
|
382
|
-
valuation: sendValuationGAEvent,
|
|
383
|
-
request: sendRequestGAEvent,
|
|
384
|
-
mortgage: sendMortgageGAEvent,
|
|
385
|
-
mailAlertSave: sendMailAlertSaveGAEvent,
|
|
386
|
-
generic_request_lead: sendGenericRequestLead,
|
|
387
|
-
newsletter_subscribe: sendNewsletterSubscribeGAEvent,
|
|
388
|
-
phone_show: sendPhoneShowGAEvent,
|
|
389
|
-
public_user_login: sendPublicUserLoginGAEvent,
|
|
390
|
-
pushNotificationOpened: sendNotificationOpenedGAEvent,
|
|
391
|
-
public_user_sign_up: sendSignUpGAEvent,
|
|
392
|
-
premium_info: sendPremiumInfoGAEvent,
|
|
393
|
-
valuation_complete: sendValuationComplete,
|
|
394
|
-
valuation_lead: sendValuationLead,
|
|
395
|
-
valuation_pdf_download: sendDownloadPDF,
|
|
396
|
-
error_request_409: sendErrorRequestGAEvent,
|
|
397
|
-
specific_request_interaction: sendRequestModalInteractionGAEvent,
|
|
398
|
-
copy_avm_widget: copyAVMwidgetGAEvent,
|
|
399
|
-
copy_trend_widget: copyTrendWidgetGAEvent,
|
|
400
|
-
send_avm_widget_request: sendAVMwidgetRequest,
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
// eslint-disable-next-line max-len
|
|
404
|
-
export function sendGAEvent<
|
|
405
|
-
T extends
|
|
406
|
-
| GaValuationPayload
|
|
407
|
-
| GaRequestPayload
|
|
408
|
-
| GaPhoneShowPayload
|
|
409
|
-
| GenericPayload
|
|
410
|
-
| GaValuationSellingPayload
|
|
411
|
-
>(GAEvent: GAEvent, payload?: T): void {
|
|
412
|
-
const handler = GAEventHandler[GAEvent];
|
|
413
|
-
payload ? handler(payload) : handler();
|
|
414
|
-
}
|