@wapitee/typhoonx-hydrogen 0.4.4 → 0.4.5
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/TyphoonX.js +7 -2
- package/package.json +1 -1
package/dist/TyphoonX.js
CHANGED
|
@@ -19,6 +19,7 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
|
|
|
19
19
|
const currentUrlRef = useRef(null);
|
|
20
20
|
const previousUrlRef = useRef(null);
|
|
21
21
|
useEffect(() => {
|
|
22
|
+
let cancelled = false;
|
|
22
23
|
const clientId = getOrCreateClientId(cookieDomain);
|
|
23
24
|
const referrerFor = (url) => {
|
|
24
25
|
if (currentUrlRef.current !== url) {
|
|
@@ -28,8 +29,9 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
|
|
|
28
29
|
return previousUrlRef.current ?? document.referrer;
|
|
29
30
|
};
|
|
30
31
|
const send = (payload) => {
|
|
31
|
-
if (!canTrack())
|
|
32
|
+
if (cancelled || !canTrack()) {
|
|
32
33
|
return;
|
|
34
|
+
}
|
|
33
35
|
navigator.sendBeacon(COLLECT_ENDPOINT, new Blob([JSON.stringify(payload)], { type: 'application/json' }));
|
|
34
36
|
};
|
|
35
37
|
const shared = (url, currency) => ({
|
|
@@ -142,6 +144,9 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
|
|
|
142
144
|
});
|
|
143
145
|
});
|
|
144
146
|
ready();
|
|
145
|
-
|
|
147
|
+
return () => {
|
|
148
|
+
cancelled = true;
|
|
149
|
+
};
|
|
150
|
+
}, [canTrack, cookieDomain, merchantId, ready, shopId, subscribe]);
|
|
146
151
|
return null;
|
|
147
152
|
}
|