@aranova/tracking-next 0.16.0 → 0.16.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/README.md +29 -0
- package/dist/index.js +18 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1668,6 +1668,7 @@ function attachFormStart(client, config) {
|
|
|
1668
1668
|
}
|
|
1669
1669
|
|
|
1670
1670
|
// ../tracking-core/src/triggers/page-exit.ts
|
|
1671
|
+
var MIN_SEGMENT_MS = 50;
|
|
1671
1672
|
function attachPageExit(client) {
|
|
1672
1673
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
1673
1674
|
return () => {
|
|
@@ -1705,7 +1706,7 @@ function attachPageExit(client) {
|
|
|
1705
1706
|
}
|
|
1706
1707
|
function emitSegment(path, flush) {
|
|
1707
1708
|
const dwell = settledDwellMs();
|
|
1708
|
-
if (dwell
|
|
1709
|
+
if (dwell < MIN_SEGMENT_MS) return;
|
|
1709
1710
|
client.trackEvent({
|
|
1710
1711
|
eventType: "page_exit",
|
|
1711
1712
|
metadata: {
|
|
@@ -1720,7 +1721,7 @@ function attachPageExit(client) {
|
|
|
1720
1721
|
client.flushBeacon();
|
|
1721
1722
|
}
|
|
1722
1723
|
accumulatedMs = 0;
|
|
1723
|
-
activeSince =
|
|
1724
|
+
activeSince = null;
|
|
1724
1725
|
}
|
|
1725
1726
|
function onNavigate() {
|
|
1726
1727
|
const newPath = window.location.pathname;
|
|
@@ -2522,10 +2523,18 @@ function GoogleAdsTracking(props) {
|
|
|
2522
2523
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
2523
2524
|
|
|
2524
2525
|
// package.json
|
|
2525
|
-
var version = "0.16.
|
|
2526
|
+
var version = "0.16.2";
|
|
2526
2527
|
|
|
2527
2528
|
// src/factory.tsx
|
|
2528
|
-
import {
|
|
2529
|
+
import {
|
|
2530
|
+
createContext as createContext2,
|
|
2531
|
+
Suspense,
|
|
2532
|
+
useCallback as useCallback3,
|
|
2533
|
+
useContext as useContext2,
|
|
2534
|
+
useEffect as useEffect3,
|
|
2535
|
+
useMemo as useMemo2,
|
|
2536
|
+
useRef
|
|
2537
|
+
} from "react";
|
|
2529
2538
|
|
|
2530
2539
|
// ../tracking-core/src/phone-react.tsx
|
|
2531
2540
|
import {
|
|
@@ -2621,7 +2630,15 @@ var PhoneField = forwardRef(function PhoneField2({ country, value, defaultValue,
|
|
|
2621
2630
|
});
|
|
2622
2631
|
|
|
2623
2632
|
// src/factory.tsx
|
|
2624
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2633
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2634
|
+
function PageViewTracker({ fire }) {
|
|
2635
|
+
const pathname = usePathname();
|
|
2636
|
+
const searchParams = useSearchParams();
|
|
2637
|
+
useEffect3(() => {
|
|
2638
|
+
fire();
|
|
2639
|
+
}, [pathname, searchParams, fire]);
|
|
2640
|
+
return null;
|
|
2641
|
+
}
|
|
2625
2642
|
function createTracking(options) {
|
|
2626
2643
|
const { apiKey, endpoint, triggers, environment, gtagIds, debug, phone, conversionConfig } = options;
|
|
2627
2644
|
if (!apiKey || !endpoint) {
|
|
@@ -2648,7 +2665,6 @@ function createTracking(options) {
|
|
|
2648
2665
|
const timeOnSiteConfig = triggers.automatic.time_on_site ?? null;
|
|
2649
2666
|
function TrackingProvider({ children }) {
|
|
2650
2667
|
const pathname = usePathname();
|
|
2651
|
-
const searchParams = useSearchParams();
|
|
2652
2668
|
const client = useMemo2(
|
|
2653
2669
|
() => createTypedClient(
|
|
2654
2670
|
getOrCreateTrackingClient({
|
|
@@ -2678,7 +2694,7 @@ function createTracking(options) {
|
|
|
2678
2694
|
const autoFire = conversionStore ? createConversionAutoFire(conversionStore) : null;
|
|
2679
2695
|
return (c) => autoFire ? withConversionAutoFire(c, autoFire) : c;
|
|
2680
2696
|
}, [conversionStore]);
|
|
2681
|
-
|
|
2697
|
+
const firePageView = useCallback3(() => {
|
|
2682
2698
|
const rawClient = getOrCreateTrackingClient({
|
|
2683
2699
|
apiKey,
|
|
2684
2700
|
endpoint,
|
|
@@ -2690,7 +2706,7 @@ function createTracking(options) {
|
|
|
2690
2706
|
debug
|
|
2691
2707
|
});
|
|
2692
2708
|
fireManualPageView(wrapClient(rawClient));
|
|
2693
|
-
}, [
|
|
2709
|
+
}, [wrapClient]);
|
|
2694
2710
|
const firedPagesRef = useRef(/* @__PURE__ */ new Set());
|
|
2695
2711
|
useEffect3(() => {
|
|
2696
2712
|
if (!specificPageVisitConfig || pathname === null) return;
|
|
@@ -2829,7 +2845,10 @@ function createTracking(options) {
|
|
|
2829
2845
|
}
|
|
2830
2846
|
};
|
|
2831
2847
|
}, []);
|
|
2832
|
-
return /* @__PURE__ */
|
|
2848
|
+
return /* @__PURE__ */ jsxs4(TrackingContext.Provider, { value: client, children: [
|
|
2849
|
+
/* @__PURE__ */ jsx5(Suspense, { fallback: null, children: /* @__PURE__ */ jsx5(PageViewTracker, { fire: firePageView }) }),
|
|
2850
|
+
/* @__PURE__ */ jsx5(PhoneConfigProvider, { value: phone ?? null, children })
|
|
2851
|
+
] });
|
|
2833
2852
|
}
|
|
2834
2853
|
function useTracking() {
|
|
2835
2854
|
const client = useContext2(TrackingContext);
|