ublo-lib 1.47.3 → 1.47.4
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/es/common/components/collapsible/collapsible.d.ts +2 -1
- package/es/common/components/collapsible/collapsible.d.ts.map +1 -1
- package/es/common/components/collapsible/collapsible.js +9 -3
- package/es/common/components/cross-selling-editor/cross-selling-editor.js +1 -1
- package/es/common/components/custom-contact-form/custom-contact-form.js +1 -1
- package/es/common/components/gesco-contact-form/services/plausible.js +1 -1
- package/es/common/hooks/use-account.js +1 -1
- package/es/common/hooks/use-tunnel.js +1 -1
- package/es/esf/components/instant-search/instant-search.js +1 -1
- package/es/lbm/components/instant-search/instant-search.js +1 -1
- package/es/market-place/components/instant-search/instant-search.js +1 -1
- package/package.json +1 -1
- package/es/common/components/plausible/hooks/use-plausible.d.ts +0 -12
- package/es/common/components/plausible/hooks/use-plausible.d.ts.map +0 -1
- package/es/common/components/plausible/hooks/use-plausible.js +0 -25
- package/es/common/components/plausible/index.d.ts +0 -8
- package/es/common/components/plausible/index.d.ts.map +0 -1
- package/es/common/components/plausible/index.js +0 -7
- package/es/common/components/plausible/plausible.d.ts +0 -7
- package/es/common/components/plausible/plausible.d.ts.map +0 -1
- package/es/common/components/plausible/plausible.js +0 -16
- package/es/common/components/plausible/services/callback.d.ts +0 -24
- package/es/common/components/plausible/services/callback.d.ts.map +0 -1
- package/es/common/components/plausible/services/callback.js +0 -157
- package/es/common/components/plausible/services/load.d.ts +0 -2
- package/es/common/components/plausible/services/load.d.ts.map +0 -1
- package/es/common/components/plausible/services/load.js +0 -7
- package/es/common/components/plausible/services/send-goal.d.ts +0 -7
- package/es/common/components/plausible/services/send-goal.d.ts.map +0 -1
- package/es/common/components/plausible/services/send-goal.js +0 -5
|
@@ -5,7 +5,8 @@ type Props = {
|
|
|
5
5
|
gradientColor: string;
|
|
6
6
|
path: string;
|
|
7
7
|
children: React.ReactNode;
|
|
8
|
+
customMessage?: string;
|
|
8
9
|
};
|
|
9
|
-
export default function Collapsible({ gradientColor, height, lang, path, children, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function Collapsible({ gradientColor, height, lang, path, customMessage, children, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=collapsible.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collapsible.d.ts","sourceRoot":"","sources":["../../../../src/common/components/collapsible/collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"collapsible.d.ts","sourceRoot":"","sources":["../../../../src/common/components/collapsible/collapsible.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAqBF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,aAAsB,EACtB,MAAY,EACZ,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,QAAQ,GACT,EAAE,KAAK,2CA2EP"}
|
|
@@ -24,7 +24,7 @@ const i18n = {
|
|
|
24
24
|
close: "Amagar",
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
|
-
export default function Collapsible({ gradientColor = "#fff", height = 150, lang, path, children, }) {
|
|
27
|
+
export default function Collapsible({ gradientColor = "#fff", height = 150, lang, path, customMessage, children, }) {
|
|
28
28
|
const [opened, setOpened] = React.useState(false);
|
|
29
29
|
const [hasOverflow, setHasOverflow] = React.useState(false);
|
|
30
30
|
const [isConnected, setIsConnected] = React.useState(false);
|
|
@@ -38,8 +38,14 @@ export default function Collapsible({ gradientColor = "#fff", height = 150, lang
|
|
|
38
38
|
const toggleOpen = () => {
|
|
39
39
|
setOpened(!opened);
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
let message = "";
|
|
42
|
+
if (!customMessage) {
|
|
43
|
+
const messages = i18n[lang] || i18n.en;
|
|
44
|
+
message = opened ? messages.close : messages.open;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
message = customMessage;
|
|
48
|
+
}
|
|
43
49
|
const Icon = opened ? ChevronUpIcon : ChevronDownIcon;
|
|
44
50
|
React.useEffect(() => {
|
|
45
51
|
const parentHeight = parentRef.current?.offsetHeight;
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import classNames from "classnames";
|
|
4
4
|
import Zone from "ublo/zone";
|
|
5
5
|
import { useUbloContext } from "ublo/with-ublo";
|
|
6
|
-
import * as Plausible from "
|
|
6
|
+
import * as Plausible from "../../../future/components/plausible";
|
|
7
7
|
import Editor from "./editor";
|
|
8
8
|
import styles from "./cross-selling-editor.module.css";
|
|
9
9
|
export default function CrossSellingEditor({ titleZoneProps = {}, contentZoneProps = {}, durations, className, tunnelOffersOrder, displayedTunnelOffers, children, }) {
|
|
@@ -8,7 +8,7 @@ import Button from "dt-design-system/es/button";
|
|
|
8
8
|
import * as Messages from "./messages";
|
|
9
9
|
import * as Icons from "./icons";
|
|
10
10
|
import MailIcon from "dt-design-system/es/icons/mail";
|
|
11
|
-
import * as Plausible from "
|
|
11
|
+
import * as Plausible from "../../../future/components/plausible";
|
|
12
12
|
import { getInitialFormState, getSettings, send } from "./utils";
|
|
13
13
|
import css from "./custom-contact-form.module.css";
|
|
14
14
|
export default React.memo(CustomContactFormWithSnackbar);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import getConfig from "next/config";
|
|
3
3
|
import { useUbloContext } from "ublo/with-ublo";
|
|
4
|
-
import * as Plausible from "
|
|
4
|
+
import * as Plausible from "../../future/components/plausible";
|
|
5
5
|
import { loadJS } from "../utils/load-js";
|
|
6
6
|
const { publicRuntimeConfig } = getConfig();
|
|
7
7
|
const { langPrefix, resort, merchant } = publicRuntimeConfig;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import getConfig from "next/config";
|
|
3
3
|
import { useUbloContext } from "ublo/with-ublo";
|
|
4
|
-
import * as Plausible from "
|
|
4
|
+
import * as Plausible from "../../future/components/plausible";
|
|
5
5
|
import { loadJS } from "../utils/load-js";
|
|
6
6
|
const { publicRuntimeConfig } = getConfig();
|
|
7
7
|
const { langPrefix, resort } = publicRuntimeConfig;
|
|
@@ -9,7 +9,7 @@ import PeriodPicker from "../period-picker";
|
|
|
9
9
|
import Input from "./input";
|
|
10
10
|
import Results from "./results";
|
|
11
11
|
import useSearch from "./hooks/use-search";
|
|
12
|
-
import * as Plausible from "../../../
|
|
12
|
+
import * as Plausible from "../../../future/components/plausible";
|
|
13
13
|
import css from "./instant-search.module.css";
|
|
14
14
|
export default function InstantSearch({ lang, suggestions, className, ubloContext, options = {}, resultsOptions, productImage, }) {
|
|
15
15
|
const [opened, setOpened] = React.useState(false);
|
|
@@ -7,7 +7,7 @@ import Dialog from "dt-design-system/es/dialog";
|
|
|
7
7
|
import SearchInput from "./search-input";
|
|
8
8
|
import Results from "./results";
|
|
9
9
|
import useSearch from "./hooks/use-search";
|
|
10
|
-
import * as Plausible from "../../../
|
|
10
|
+
import * as Plausible from "../../../future/components/plausible";
|
|
11
11
|
import css from "./instant-search.module.css";
|
|
12
12
|
export default function InstantSearch({ lang, suggestions, className, options = {}, }) {
|
|
13
13
|
const [opened, setOpened] = React.useState(false);
|
|
@@ -7,7 +7,7 @@ import Dialog from "dt-design-system/es/dialog";
|
|
|
7
7
|
import SearchInput from "./search-input";
|
|
8
8
|
import Results from "./results";
|
|
9
9
|
import useSearch from "./hooks/use-search";
|
|
10
|
-
import * as Plausible from "../../../
|
|
10
|
+
import * as Plausible from "../../../future/components/plausible";
|
|
11
11
|
import message from "./services/messages";
|
|
12
12
|
import css from "./instant-search.module.css";
|
|
13
13
|
export default function InstantSearch({ lang, suggestions, className, options = {}, weekNumber, }) {
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type Revenue = {
|
|
2
|
-
currency: string;
|
|
3
|
-
amount: number;
|
|
4
|
-
};
|
|
5
|
-
export default function useGoal(goal: string, props: Record<string, any>, revenue?: Revenue, domainOverride?: string): void;
|
|
6
|
-
declare global {
|
|
7
|
-
interface Window {
|
|
8
|
-
plausible: any;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=use-plausible.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-plausible.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/plausible/hooks/use-plausible.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1B,OAAO,CAAC,EAAE,OAAO,EACjB,cAAc,CAAC,EAAE,MAAM,QAQxB;AAcD,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,MAAM;QACd,SAAS,EAAE,GAAG,CAAC;KAChB;CACF"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import getConfig from "next/config";
|
|
3
|
-
import load from "../services/load";
|
|
4
|
-
import sendGoal from "../services/send-goal";
|
|
5
|
-
const { publicRuntimeConfig } = getConfig();
|
|
6
|
-
const { plausibleDomain } = publicRuntimeConfig;
|
|
7
|
-
export default function useGoal(goal, props, revenue, domainOverride) {
|
|
8
|
-
const [loaded] = usePlausible(domainOverride);
|
|
9
|
-
React.useEffect(() => {
|
|
10
|
-
if (!loaded || !window.plausible)
|
|
11
|
-
return;
|
|
12
|
-
const defaultProps = { path: document.location.pathname };
|
|
13
|
-
sendGoal(goal, props || defaultProps, revenue);
|
|
14
|
-
}, [goal, loaded, props, revenue]);
|
|
15
|
-
}
|
|
16
|
-
function usePlausible(domainOverride) {
|
|
17
|
-
const [loaded, setLoaded] = React.useState(false);
|
|
18
|
-
React.useEffect(() => {
|
|
19
|
-
if (!domainOverride && !plausibleDomain)
|
|
20
|
-
return;
|
|
21
|
-
load();
|
|
22
|
-
setLoaded(true);
|
|
23
|
-
}, [domainOverride]);
|
|
24
|
-
return [loaded, setLoaded];
|
|
25
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import Script from "./plausible";
|
|
2
|
-
import * as Callback from "./services/callback";
|
|
3
|
-
declare const callback: typeof Callback.MseM;
|
|
4
|
-
export { default as load } from "./services/load";
|
|
5
|
-
export { default as sendGoal } from "./services/send-goal";
|
|
6
|
-
export { default as useGoal } from "./hooks/use-plausible";
|
|
7
|
-
export { callback, Script };
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/plausible/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,QAAA,MAAM,QAAQ,sBAAgB,CAAC;AAE/B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import Script from "./plausible";
|
|
2
|
-
import * as Callback from "./services/callback";
|
|
3
|
-
const callback = Callback.MseM;
|
|
4
|
-
export { default as load } from "./services/load";
|
|
5
|
-
export { default as sendGoal } from "./services/send-goal";
|
|
6
|
-
export { default as useGoal } from "./hooks/use-plausible";
|
|
7
|
-
export { callback, Script };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plausible.d.ts","sourceRoot":"","sources":["../../../../src/common/components/plausible/plausible.tsx"],"names":[],"mappings":"AAMA,KAAK,KAAK,GAAG;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAKF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,EACtC,IAAI,EACJ,MAAuB,GACxB,EAAE,KAAK,2CAeP"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import Script from "next/script";
|
|
3
|
-
import getConfig from "next/config";
|
|
4
|
-
const { publicRuntimeConfig } = getConfig();
|
|
5
|
-
const { plausibleDomain } = publicRuntimeConfig;
|
|
6
|
-
const DEFAULT_SOURCE = "https://plausible.io/js/script.revenue.file-downloads.outbound-links.js";
|
|
7
|
-
export default function PlausibleScript({ lang, source = DEFAULT_SOURCE, }) {
|
|
8
|
-
const hasI18n = typeof plausibleDomain === "object";
|
|
9
|
-
if (hasI18n && !lang) {
|
|
10
|
-
console.warn("PlausibleScript: the lang props is mandatory if you want to use a specific domain for each lang");
|
|
11
|
-
}
|
|
12
|
-
const domain = hasI18n && lang ? plausibleDomain[lang] : plausibleDomain;
|
|
13
|
-
if (!domain)
|
|
14
|
-
return null;
|
|
15
|
-
return _jsx(Script, { "data-domain": domain, src: source });
|
|
16
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
type Item = {
|
|
2
|
-
gtmData: {
|
|
3
|
-
item_name: string;
|
|
4
|
-
item_brand: string;
|
|
5
|
-
item_category: string;
|
|
6
|
-
item_category2: string;
|
|
7
|
-
item_category3: string;
|
|
8
|
-
item_variant: string;
|
|
9
|
-
price: number;
|
|
10
|
-
quantity: number;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
type Props = {
|
|
14
|
-
event: string;
|
|
15
|
-
payment_type?: string;
|
|
16
|
-
execcode?: string;
|
|
17
|
-
items?: Item[];
|
|
18
|
-
orderId?: string;
|
|
19
|
-
cartId?: string;
|
|
20
|
-
currency?: string;
|
|
21
|
-
};
|
|
22
|
-
export declare function MseM({ event, payment_type: paymentType, execcode, items, orderId, cartId, currency, }: Props): void;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=callback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../../../../src/common/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,QAgIP"}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import sendGoal from "./send-goal";
|
|
2
|
-
const EVENT_NAMES = {
|
|
3
|
-
view_item: "MseM: View item",
|
|
4
|
-
add_to_cart: "MseM: Add to cart",
|
|
5
|
-
remove_from_cart: "MseM: Remove from cart",
|
|
6
|
-
checkout: "MseM: Begin checkout",
|
|
7
|
-
add_payment_info: "MseM: Checkout process",
|
|
8
|
-
purchase: "MseM: Payment success",
|
|
9
|
-
payment_failure: "MseM: Payment failure",
|
|
10
|
-
};
|
|
11
|
-
export function MseM({ event, payment_type: paymentType, execcode, items = [], orderId, cartId, currency = "EUR", }) {
|
|
12
|
-
const hoteId = getBusinessProvider();
|
|
13
|
-
const stay = getStay();
|
|
14
|
-
const amount = items.reduce((acc, item) => {
|
|
15
|
-
return acc + item.gtmData.price * item.gtmData.quantity;
|
|
16
|
-
}, 0);
|
|
17
|
-
const revenue = { currency, amount };
|
|
18
|
-
let name = EVENT_NAMES[event];
|
|
19
|
-
const firstProductProps = {
|
|
20
|
-
Name: items[0]?.gtmData.item_name,
|
|
21
|
-
Brand: items[0]?.gtmData.item_brand,
|
|
22
|
-
Kind: items[0]?.gtmData.item_category,
|
|
23
|
-
Activity: items[0]?.gtmData.item_category2,
|
|
24
|
-
Code: items[0]?.gtmData.item_category3,
|
|
25
|
-
Product: items[0]?.gtmData.item_variant,
|
|
26
|
-
};
|
|
27
|
-
switch (event) {
|
|
28
|
-
case "view_item": {
|
|
29
|
-
const formattedItems = formatPeekPerformancesItem(items);
|
|
30
|
-
const rawData = JSON.stringify({
|
|
31
|
-
products: formattedItems,
|
|
32
|
-
hoteId,
|
|
33
|
-
stay,
|
|
34
|
-
});
|
|
35
|
-
sendGoal(name, { ...firstProductProps, stayFrom: stay?.from, rawData });
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case "add_to_cart": {
|
|
39
|
-
const formattedItems = formatPeekPerformancesItem(items);
|
|
40
|
-
const rawData = JSON.stringify({
|
|
41
|
-
products: formattedItems,
|
|
42
|
-
hoteId,
|
|
43
|
-
stay,
|
|
44
|
-
});
|
|
45
|
-
sendGoal(name, { ...firstProductProps, stayFrom: stay?.from, rawData }, revenue);
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
case "remove_from_cart": {
|
|
49
|
-
const formattedItems = formatPeekPerformancesItem(items);
|
|
50
|
-
const rawData = JSON.stringify({
|
|
51
|
-
products: formattedItems,
|
|
52
|
-
hoteId,
|
|
53
|
-
stay,
|
|
54
|
-
});
|
|
55
|
-
sendGoal(name, { ...firstProductProps, stayFrom: stay?.from, rawData }, revenue);
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
case "checkout": {
|
|
59
|
-
const formattedItems = formatPeekPerformancesItem(items);
|
|
60
|
-
const rawData = JSON.stringify({
|
|
61
|
-
products: formattedItems,
|
|
62
|
-
hoteId,
|
|
63
|
-
stay,
|
|
64
|
-
});
|
|
65
|
-
sendGoal(name, { cartId, stayFrom: stay?.from, rawData }, revenue);
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
case "add_payment_info": {
|
|
69
|
-
const formattedItems = formatPeekPerformancesItem(items);
|
|
70
|
-
const rawData = JSON.stringify({
|
|
71
|
-
products: formattedItems,
|
|
72
|
-
hoteId,
|
|
73
|
-
stay,
|
|
74
|
-
paymentMethod: paymentType,
|
|
75
|
-
});
|
|
76
|
-
sendGoal(name, { cartId, "Payment type": paymentType, stayFrom: stay?.from, rawData }, revenue);
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
case "purchase": {
|
|
80
|
-
const isFailure = execcode !== "0000";
|
|
81
|
-
const formattedItems = formatPeekPerformancesItem(items);
|
|
82
|
-
const attempts = (cartId && getPurchaseAttempts()[cartId]) || 0;
|
|
83
|
-
const rawData = JSON.stringify({
|
|
84
|
-
products: formattedItems,
|
|
85
|
-
hoteId,
|
|
86
|
-
stay,
|
|
87
|
-
attempts,
|
|
88
|
-
paymentMethod: paymentType,
|
|
89
|
-
execCode: execcode,
|
|
90
|
-
});
|
|
91
|
-
if (isFailure) {
|
|
92
|
-
name = EVENT_NAMES.payment_failure;
|
|
93
|
-
sendGoal(name, { cartId, orderId, Code: execcode, stayFrom: stay?.from, rawData }, revenue);
|
|
94
|
-
if (cartId) {
|
|
95
|
-
setPurchaseAttempts(cartId, attempts + 1);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
const isQuotation = checkQuotation(amount);
|
|
100
|
-
if (isQuotation)
|
|
101
|
-
return;
|
|
102
|
-
sendGoal(name, { cartId, orderId, Code: execcode, stayFrom: stay?.from, rawData }, revenue);
|
|
103
|
-
}
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const PURCHASE_ATTEMPTS_STORAGE_KEY = "purchase_attempts";
|
|
109
|
-
function getPurchaseAttempts() {
|
|
110
|
-
try {
|
|
111
|
-
const storedAttempts = window.localStorage.getItem(PURCHASE_ATTEMPTS_STORAGE_KEY);
|
|
112
|
-
return storedAttempts !== null ? JSON.parse(storedAttempts) : {};
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
return {};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
function setPurchaseAttempts(cartId, attempts) {
|
|
119
|
-
const purchaseAttempts = getPurchaseAttempts();
|
|
120
|
-
window.localStorage.setItem(PURCHASE_ATTEMPTS_STORAGE_KEY, JSON.stringify({ ...purchaseAttempts, [cartId]: attempts }));
|
|
121
|
-
}
|
|
122
|
-
function formatPeekPerformancesItem(items) {
|
|
123
|
-
if (!items || !items.length)
|
|
124
|
-
return;
|
|
125
|
-
return items.map(({ gtmData }) => {
|
|
126
|
-
return {
|
|
127
|
-
category: gtmData.item_category,
|
|
128
|
-
subCategory: gtmData.item_category2,
|
|
129
|
-
merchant: gtmData.item_brand,
|
|
130
|
-
price: gtmData.price,
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function checkQuotation(amount) {
|
|
135
|
-
const search = window.location.search;
|
|
136
|
-
const hasQuotation = new URLSearchParams(search).has("hasQuotation");
|
|
137
|
-
return hasQuotation && amount === 0;
|
|
138
|
-
}
|
|
139
|
-
function getStay() {
|
|
140
|
-
const stay = window.sessionStorage.getItem("stay");
|
|
141
|
-
if (stay) {
|
|
142
|
-
return JSON.parse(stay);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function getBusinessProvider() {
|
|
146
|
-
const businessProvider = window.localStorage.getItem("businessProvider");
|
|
147
|
-
if (businessProvider) {
|
|
148
|
-
try {
|
|
149
|
-
const { id, exp } = JSON.parse(businessProvider);
|
|
150
|
-
const isExpired = exp < Date.now();
|
|
151
|
-
if (!isExpired && id !== -1) {
|
|
152
|
-
return id;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
catch (e) { }
|
|
156
|
-
}
|
|
157
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/plausible/services/load.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,IAAI,SAM3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"send-goal.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/plausible/services/send-goal.ts"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,OAAO,CAAC,EAAE,OAAO,QAIlB"}
|