ublo-lib 1.47.61 → 1.47.63

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.
@@ -1 +1 @@
1
- {"version":3,"file":"use-booking-links.d.ts","sourceRoot":"","sources":["../../../src/esf/hooks/use-booking-links.js"],"names":[],"mappings":"AAKA,uJAyDC"}
1
+ {"version":3,"file":"use-booking-links.d.ts","sourceRoot":"","sources":["../../../src/esf/hooks/use-booking-links.js"],"names":[],"mappings":"AAKA,uJAwDC"}
@@ -5,7 +5,6 @@ import * as Plausible from "../../future/components/plausible";
5
5
  export default function useBookingLinks(cart, multipleVillages, setupCallback, channel = "ESF", cartChanged, skipRecap) {
6
6
  const { breadcrumb, config, lang, path } = useUbloContext();
7
7
  const hasLangPrefix = config.langPrefix.links;
8
- const bookingLang = lang === "fr" ? "fr" : "en";
9
8
  const handleCartChange = React.useCallback((cart, kind, eventType) => {
10
9
  cartChanged?.(cart, kind, eventType);
11
10
  const event = new CustomEvent("msem-cart-changed", {
@@ -16,13 +15,13 @@ export default function useBookingLinks(cart, multipleVillages, setupCallback, c
16
15
  React.useEffect(() => {
17
16
  const run = async () => {
18
17
  await loadJS("https://widget.vente-en-ligne-esf.com/boutique/boutique.js", "boutique-js");
19
- setupConfig(bookingLang, breadcrumb, cart, multipleVillages, hasLangPrefix, channel, handleCartChange, skipRecap);
18
+ setupConfig(lang, breadcrumb, cart, multipleVillages, hasLangPrefix, channel, handleCartChange, skipRecap);
20
19
  setupDialogCleanup();
21
20
  setupCallback?.();
22
21
  };
23
22
  run();
24
23
  }, [
25
- bookingLang,
24
+ lang,
26
25
  breadcrumb,
27
26
  cart,
28
27
  handleCartChange,
@@ -0,0 +1,2 @@
1
+ export default function useGescoReferral(): void;
2
+ //# sourceMappingURL=use-gesco-referral.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-gesco-referral.d.ts","sourceRoot":"","sources":["../../../src/esf/hooks/use-gesco-referral.js"],"names":[],"mappings":"AAMA,iDAcC"}
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import * as Plausible from "../../future/components/plausible";
3
+ const STORAGE_KEY = "gescoReferral";
4
+ const CHECKER_STORAGE_KEY = "gescoReferralChecked";
5
+ export default function useGescoReferral() {
6
+ React.useEffect(() => {
7
+ const storedChecker = window.sessionStorage.getItem(CHECKER_STORAGE_KEY);
8
+ const storedGescoReferral = window.localStorage.getItem(STORAGE_KEY);
9
+ if (!storedChecker && storedGescoReferral) {
10
+ const { type, exp } = JSON.parse(storedGescoReferral);
11
+ const isExpired = exp < Date.now();
12
+ if (!isExpired && type !== -1) {
13
+ Plausible.sendGoal("MseM: Payment link", { GescoReferral: type });
14
+ window.sessionStorage.setItem(CHECKER_STORAGE_KEY, "true");
15
+ }
16
+ }
17
+ }, []);
18
+ }
@@ -18,7 +18,8 @@ type Props = {
18
18
  orderId?: string;
19
19
  cartId?: string;
20
20
  currency?: string;
21
+ type?: string;
21
22
  };
22
- export declare function MseM({ event, payment_type: paymentType, execcode, items, orderId, cartId, currency, }: Props): void;
23
+ export declare function MseM({ event, payment_type: paymentType, execcode, items, orderId, cartId, currency, type, }: Props): Promise<void>;
23
24
  export {};
24
25
  //# sourceMappingURL=callback.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../../../src/future/components/plausible/services/callback.ts"],"names":[],"mappings":"AAEA,KAAK,IAAI,GAAG;IACV,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAYF,wBAAgB,IAAI,CAAC,EACnB,KAAK,EACL,YAAY,EAAE,WAAW,EACzB,QAAQ,EACR,KAAU,EACV,OAAO,EACP,MAAM,EACN,QAAgB,GACjB,EAAE,KAAK,QAwJP"}
1
+ {"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../../../src/future/components/plausible/services/callback.ts"],"names":[],"mappings":"AAIA,KAAK,IAAI,GAAG;IACV,OAAO,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA6BF,wBAAsB,IAAI,CAAC,EACzB,KAAK,EACL,YAAY,EAAE,WAAW,EACzB,QAAQ,EACR,KAAU,EACV,OAAO,EACP,MAAM,EACN,QAAgB,EAChB,IAAI,GACL,EAAE,KAAK,iBA8MP"}
@@ -1,6 +1,9 @@
1
+ import { fetchCart } from "../../../../common/components/cart-preview/api";
1
2
  import sendGoal from "./send-goal";
3
+ import * as Utils from "../../../../common/components/cart-preview/utils";
2
4
  const EVENT_NAMES = {
3
5
  view_item: "MseM: View item",
6
+ gesco_event: "Contact-",
4
7
  add_to_cart: "MseM: Add to cart",
5
8
  remove_from_cart: "MseM: Remove from cart",
6
9
  checkout: "MseM: Begin checkout",
@@ -8,8 +11,13 @@ const EVENT_NAMES = {
8
11
  purchase: "MseM: Payment success",
9
12
  payment_failure: "MseM: Payment failure",
10
13
  };
11
- export function MseM({ event, payment_type: paymentType, execcode, items = [], orderId, cartId, currency = "EUR", }) {
14
+ const GESCO_EVENT_NAMES = {
15
+ tunnel: "CPSM",
16
+ vel: "VEL",
17
+ };
18
+ export async function MseM({ event, payment_type: paymentType, execcode, items = [], orderId, cartId, currency = "EUR", type, }) {
12
19
  const hoteId = getBusinessProvider();
20
+ const gescoReferral = getGescoProvenance();
13
21
  const stay = getStay();
14
22
  const amount = items.reduce((acc, item) => {
15
23
  return acc + item.gtmData.price * item.gtmData.quantity;
@@ -32,12 +40,21 @@ export function MseM({ event, payment_type: paymentType, execcode, items = [], o
32
40
  Activity: item.gtmData.item_category2,
33
41
  Code: item.gtmData.item_category3,
34
42
  Product: item.gtmData.item_variant,
43
+ Price: item.gtmData.price,
44
+ Quantity: item.gtmData.quantity,
35
45
  };
36
46
  });
37
47
  const sendPerProductGoals = (name, perProductProps) => perProductProps.forEach((props) => {
38
- sendGoal(name + " item", props, {
48
+ const { Price, Quantity, ...filteredProps } = props;
49
+ sendGoal(name + " item", {
50
+ ...filteredProps,
51
+ GescoReferral: gescoReferral,
52
+ hoteId,
53
+ stayFrom: stay?.from,
54
+ stayTo: stay?.to,
55
+ }, {
39
56
  currency,
40
- amount: props.Price * props.Quantity,
57
+ amount: Price * Quantity,
41
58
  });
42
59
  });
43
60
  switch (event) {
@@ -48,7 +65,11 @@ export function MseM({ event, payment_type: paymentType, execcode, items = [], o
48
65
  hoteId,
49
66
  stay,
50
67
  });
51
- sendGoal(name, { ...firstProductProps, stayFrom: stay?.from, rawData });
68
+ sendGoal(name, {
69
+ ...firstProductProps,
70
+ stayFrom: stay?.from,
71
+ rawData,
72
+ });
52
73
  break;
53
74
  }
54
75
  case "add_to_cart": {
@@ -69,6 +90,15 @@ export function MseM({ event, payment_type: paymentType, execcode, items = [], o
69
90
  stay,
70
91
  });
71
92
  sendGoal(name, { ...firstProductProps, stayFrom: stay?.from, rawData }, revenue);
93
+ try {
94
+ const response = await fetchCart(cartId);
95
+ const { orders: bareOrders } = response?.cart;
96
+ const orders = Utils.getOrders(bareOrders);
97
+ if (!response || !orders || orders.length === 0) {
98
+ removeGescoProvenance();
99
+ }
100
+ }
101
+ catch { }
72
102
  break;
73
103
  }
74
104
  case "checkout": {
@@ -78,7 +108,7 @@ export function MseM({ event, payment_type: paymentType, execcode, items = [], o
78
108
  hoteId,
79
109
  stay,
80
110
  });
81
- sendGoal(name, { cartId, stayFrom: stay?.from, rawData }, revenue);
111
+ sendGoal(name, { cartId, stayFrom: stay?.from, rawData, GescoReferral: gescoReferral }, revenue);
82
112
  sendPerProductGoals(name, perProductProps);
83
113
  break;
84
114
  }
@@ -90,10 +120,23 @@ export function MseM({ event, payment_type: paymentType, execcode, items = [], o
90
120
  stay,
91
121
  paymentMethod: paymentType,
92
122
  });
93
- sendGoal(name, { cartId, "Payment type": paymentType, stayFrom: stay?.from, rawData }, revenue);
123
+ sendGoal(name, {
124
+ cartId,
125
+ "Payment type": paymentType,
126
+ stayFrom: stay?.from,
127
+ rawData,
128
+ GescoReferral: gescoReferral,
129
+ }, revenue);
94
130
  sendPerProductGoals(name, perProductProps);
95
131
  break;
96
132
  }
133
+ case "gesco_event": {
134
+ if (type !== "tunnel" && type !== "vel")
135
+ return;
136
+ name += GESCO_EVENT_NAMES[type];
137
+ sendGoal(name, { stayFrom: stay?.from });
138
+ break;
139
+ }
97
140
  case "purchase": {
98
141
  const isFailure = execcode !== "0000";
99
142
  const formattedItems = formatPeekPerformancesItem(items);
@@ -108,7 +151,14 @@ export function MseM({ event, payment_type: paymentType, execcode, items = [], o
108
151
  });
109
152
  if (isFailure) {
110
153
  name = EVENT_NAMES.payment_failure;
111
- sendGoal(name, { cartId, orderId, Code: execcode, stayFrom: stay?.from, rawData }, revenue);
154
+ sendGoal(name, {
155
+ cartId,
156
+ orderId,
157
+ Code: execcode,
158
+ stayFrom: stay?.from,
159
+ rawData,
160
+ GescoReferral: gescoReferral,
161
+ }, revenue);
112
162
  sendPerProductGoals(name, perProductProps);
113
163
  if (cartId) {
114
164
  setPurchaseAttempts(cartId, attempts + 1);
@@ -118,8 +168,16 @@ export function MseM({ event, payment_type: paymentType, execcode, items = [], o
118
168
  const isQuotation = checkQuotation(amount);
119
169
  if (isQuotation)
120
170
  return;
121
- sendGoal(name, { cartId, orderId, Code: execcode, stayFrom: stay?.from, rawData }, revenue);
171
+ sendGoal(name, {
172
+ cartId,
173
+ orderId,
174
+ Code: execcode,
175
+ stayFrom: stay?.from,
176
+ rawData,
177
+ GescoReferral: gescoReferral,
178
+ }, revenue);
122
179
  sendPerProductGoals(name, perProductProps);
180
+ removeGescoProvenance();
123
181
  }
124
182
  break;
125
183
  }
@@ -175,3 +233,21 @@ function getBusinessProvider() {
175
233
  catch (e) { }
176
234
  }
177
235
  }
236
+ function getGescoProvenance() {
237
+ const gescoReferral = window.localStorage.getItem("gescoReferral");
238
+ if (gescoReferral) {
239
+ try {
240
+ const { type, exp } = JSON.parse(gescoReferral);
241
+ const isExpired = exp < Date.now();
242
+ if (!isExpired && type !== -1) {
243
+ return type;
244
+ }
245
+ }
246
+ catch (e) { }
247
+ }
248
+ }
249
+ function removeGescoProvenance() {
250
+ window.localStorage.removeItem("gescoReferral");
251
+ window.sessionStorage.removeItem("gescoReferral");
252
+ window.localStorage.removeItem("gescoReferralChecked");
253
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.47.61",
3
+ "version": "1.47.63",
4
4
  "peerDependencies": {
5
5
  "classnames": "^2.5.1",
6
6
  "dt-design-system": "^3.12.0",