@wapitee/typhoonx-hydrogen 0.4.3 → 0.4.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/dist/TyphoonX.js +3 -12
- package/package.json +1 -1
package/dist/TyphoonX.js
CHANGED
|
@@ -16,18 +16,10 @@ export default function TyphoonX(props) {
|
|
|
16
16
|
function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
|
|
17
17
|
const { canTrack, register, subscribe } = useAnalytics();
|
|
18
18
|
const { ready } = register('TyphoonX');
|
|
19
|
-
const canTrackRef = useRef(canTrack);
|
|
20
|
-
const configRef = useRef({ cookieDomain, merchantId, shopId });
|
|
21
|
-
canTrackRef.current = canTrack;
|
|
22
|
-
configRef.current = { cookieDomain, merchantId, shopId };
|
|
23
19
|
const currentUrlRef = useRef(null);
|
|
24
20
|
const previousUrlRef = useRef(null);
|
|
25
|
-
const startedRef = useRef(false);
|
|
26
21
|
useEffect(() => {
|
|
27
|
-
|
|
28
|
-
return;
|
|
29
|
-
startedRef.current = true;
|
|
30
|
-
const clientId = getOrCreateClientId(configRef.current.cookieDomain);
|
|
22
|
+
const clientId = getOrCreateClientId(cookieDomain);
|
|
31
23
|
const referrerFor = (url) => {
|
|
32
24
|
if (currentUrlRef.current !== url) {
|
|
33
25
|
previousUrlRef.current = currentUrlRef.current;
|
|
@@ -36,9 +28,8 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
|
|
|
36
28
|
return previousUrlRef.current ?? document.referrer;
|
|
37
29
|
};
|
|
38
30
|
const send = (payload) => {
|
|
39
|
-
if (!
|
|
31
|
+
if (!canTrack())
|
|
40
32
|
return;
|
|
41
|
-
}
|
|
42
33
|
navigator.sendBeacon(COLLECT_ENDPOINT, new Blob([JSON.stringify(payload)], { type: 'application/json' }));
|
|
43
34
|
};
|
|
44
35
|
const shared = (url, currency) => ({
|
|
@@ -151,6 +142,6 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
|
|
|
151
142
|
});
|
|
152
143
|
});
|
|
153
144
|
ready();
|
|
154
|
-
}, [subscribe]);
|
|
145
|
+
}, [canTrack, ready, subscribe]);
|
|
155
146
|
return null;
|
|
156
147
|
}
|