@aranova/tracking-next 0.17.1 → 0.17.2
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/index.js +51 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -51
- package/dist/index.mjs.map +1 -1
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1040,6 +1040,27 @@ function getOrCreateTrackingClient(config) {
|
|
|
1040
1040
|
globalClientKey = key;
|
|
1041
1041
|
return globalClient;
|
|
1042
1042
|
}
|
|
1043
|
+
var clientCaptureRegistry = /* @__PURE__ */ new WeakMap();
|
|
1044
|
+
function attachClientCapturesOnce(client, build) {
|
|
1045
|
+
let entry = clientCaptureRegistry.get(client);
|
|
1046
|
+
if (entry === void 0) {
|
|
1047
|
+
entry = { detach: build(), refCount: 0 };
|
|
1048
|
+
clientCaptureRegistry.set(client, entry);
|
|
1049
|
+
}
|
|
1050
|
+
entry.refCount += 1;
|
|
1051
|
+
let released = false;
|
|
1052
|
+
return () => {
|
|
1053
|
+
if (released) return;
|
|
1054
|
+
released = true;
|
|
1055
|
+
const current = clientCaptureRegistry.get(client);
|
|
1056
|
+
if (current === void 0) return;
|
|
1057
|
+
current.refCount -= 1;
|
|
1058
|
+
if (current.refCount <= 0) {
|
|
1059
|
+
current.detach();
|
|
1060
|
+
clientCaptureRegistry.delete(client);
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1043
1064
|
function createTrackingClient(config) {
|
|
1044
1065
|
const flushIntervalMs = config.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
|
|
1045
1066
|
const maxQueueSize = Math.min(config.maxQueueSize ?? DEFAULT_MAX_QUEUE_SIZE, HARD_MAX_BATCH);
|
|
@@ -2585,7 +2606,7 @@ function GoogleAdsTracking(props) {
|
|
|
2585
2606
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
2586
2607
|
|
|
2587
2608
|
// package.json
|
|
2588
|
-
var version = "0.17.
|
|
2609
|
+
var version = "0.17.2";
|
|
2589
2610
|
|
|
2590
2611
|
// src/factory.tsx
|
|
2591
2612
|
import {
|
|
@@ -2799,33 +2820,6 @@ function createTracking(options) {
|
|
|
2799
2820
|
});
|
|
2800
2821
|
}
|
|
2801
2822
|
}, [pathname]);
|
|
2802
|
-
useEffect3(() => {
|
|
2803
|
-
const rawClient = getOrCreateTrackingClient({
|
|
2804
|
-
apiKey,
|
|
2805
|
-
endpoint,
|
|
2806
|
-
surface: "next",
|
|
2807
|
-
packageName: "@aranova/tracking-next",
|
|
2808
|
-
triggers,
|
|
2809
|
-
environment,
|
|
2810
|
-
activeGtagIds: gtagIds,
|
|
2811
|
-
debug
|
|
2812
|
-
});
|
|
2813
|
-
return attachBfcacheRestore(wrapClient(rawClient));
|
|
2814
|
-
}, []);
|
|
2815
|
-
useEffect3(() => {
|
|
2816
|
-
if (!timeOnSiteConfig) return;
|
|
2817
|
-
const rawClient = getOrCreateTrackingClient({
|
|
2818
|
-
apiKey,
|
|
2819
|
-
endpoint,
|
|
2820
|
-
surface: "next",
|
|
2821
|
-
packageName: "@aranova/tracking-next",
|
|
2822
|
-
triggers,
|
|
2823
|
-
environment,
|
|
2824
|
-
activeGtagIds: gtagIds,
|
|
2825
|
-
debug
|
|
2826
|
-
});
|
|
2827
|
-
return attachTimeOnSite(wrapClient(rawClient), timeOnSiteConfig);
|
|
2828
|
-
}, []);
|
|
2829
2823
|
const multiPageSessionConfig = triggers.automatic.multi_page_session ?? null;
|
|
2830
2824
|
const mpsLastPathRef = useRef(null);
|
|
2831
2825
|
useEffect3(() => {
|
|
@@ -2876,7 +2870,6 @@ function createTracking(options) {
|
|
|
2876
2870
|
}
|
|
2877
2871
|
}, [pathname]);
|
|
2878
2872
|
useEffect3(() => {
|
|
2879
|
-
const detachers = [];
|
|
2880
2873
|
const rawClient = getOrCreateTrackingClient({
|
|
2881
2874
|
apiKey,
|
|
2882
2875
|
endpoint,
|
|
@@ -2887,29 +2880,36 @@ function createTracking(options) {
|
|
|
2887
2880
|
activeGtagIds: gtagIds,
|
|
2888
2881
|
debug
|
|
2889
2882
|
});
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
detachers.push(
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
if (phoneClick) {
|
|
2906
|
-
detachers.push(attachPhoneClickCapture(detectorClient, phoneClick));
|
|
2907
|
-
}
|
|
2908
|
-
return () => {
|
|
2909
|
-
for (let i = detachers.length - 1; i >= 0; i--) {
|
|
2910
|
-
detachers[i]();
|
|
2883
|
+
return attachClientCapturesOnce(rawClient, () => {
|
|
2884
|
+
const detachers = [];
|
|
2885
|
+
const detectorClient = wrapClient(rawClient);
|
|
2886
|
+
detachers.push(attachPageExit(detectorClient));
|
|
2887
|
+
detachers.push(attachBfcacheRestore(detectorClient));
|
|
2888
|
+
if (timeOnSiteConfig) {
|
|
2889
|
+
detachers.push(attachTimeOnSite(detectorClient, timeOnSiteConfig));
|
|
2890
|
+
}
|
|
2891
|
+
const scrollDepth = triggers.automatic.scroll_depth;
|
|
2892
|
+
if (scrollDepth) {
|
|
2893
|
+
detachers.push(attachScrollDepth(detectorClient, scrollDepth));
|
|
2894
|
+
}
|
|
2895
|
+
const formStart = triggers.automatic.form_start;
|
|
2896
|
+
if (formStart) {
|
|
2897
|
+
detachers.push(attachFormStart(detectorClient, formStart));
|
|
2911
2898
|
}
|
|
2912
|
-
|
|
2899
|
+
const ctaClick = triggers.manual?.cta_click;
|
|
2900
|
+
if (ctaClick) {
|
|
2901
|
+
detachers.push(attachCtaClickCapture(detectorClient, ctaClick));
|
|
2902
|
+
}
|
|
2903
|
+
const phoneClick = triggers.manual?.phone_click;
|
|
2904
|
+
if (phoneClick) {
|
|
2905
|
+
detachers.push(attachPhoneClickCapture(detectorClient, phoneClick));
|
|
2906
|
+
}
|
|
2907
|
+
return () => {
|
|
2908
|
+
for (let i = detachers.length - 1; i >= 0; i--) {
|
|
2909
|
+
detachers[i]();
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
});
|
|
2913
2913
|
}, []);
|
|
2914
2914
|
return /* @__PURE__ */ jsxs4(TrackingContext.Provider, { value: client, children: [
|
|
2915
2915
|
/* @__PURE__ */ jsx5(Suspense, { fallback: null, children: /* @__PURE__ */ jsx5(PageViewTracker, { fire: firePageView }) }),
|