elseware-ui 2.40.0 → 2.40.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.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +31 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -294,6 +294,20 @@ interface UsePageTrackingOptions {
|
|
|
294
294
|
fullUrl?: string;
|
|
295
295
|
metadata?: Record<string, unknown>;
|
|
296
296
|
enabled?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
|
|
299
|
+
* Disabled by default for lightweight analytics.
|
|
300
|
+
|
|
301
|
+
* Enable only when you really need time-on-page.
|
|
302
|
+
|
|
303
|
+
*/
|
|
304
|
+
trackPageLeave?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
|
|
307
|
+
* Prevents duplicate page_view events for the same path in the same mount cycle.
|
|
308
|
+
|
|
309
|
+
*/
|
|
310
|
+
dedupe?: boolean;
|
|
297
311
|
}
|
|
298
312
|
interface UseSessionTrackingOptions {
|
|
299
313
|
enabled?: boolean;
|
|
@@ -366,7 +380,7 @@ declare const useCookieConsent: () => {
|
|
|
366
380
|
resetConsent: () => void;
|
|
367
381
|
};
|
|
368
382
|
|
|
369
|
-
declare const usePageTracking: ({ path, search, title, fullUrl, metadata, enabled, }: UsePageTrackingOptions) => void;
|
|
383
|
+
declare const usePageTracking: ({ path, search, title, fullUrl, metadata, enabled, trackPageLeave, dedupe, }: UsePageTrackingOptions) => void;
|
|
370
384
|
|
|
371
385
|
declare const useSessionTracking: ({ enabled, metadata, }?: UseSessionTrackingOptions) => void;
|
|
372
386
|
|
package/dist/index.d.ts
CHANGED
|
@@ -294,6 +294,20 @@ interface UsePageTrackingOptions {
|
|
|
294
294
|
fullUrl?: string;
|
|
295
295
|
metadata?: Record<string, unknown>;
|
|
296
296
|
enabled?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
|
|
299
|
+
* Disabled by default for lightweight analytics.
|
|
300
|
+
|
|
301
|
+
* Enable only when you really need time-on-page.
|
|
302
|
+
|
|
303
|
+
*/
|
|
304
|
+
trackPageLeave?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
|
|
307
|
+
* Prevents duplicate page_view events for the same path in the same mount cycle.
|
|
308
|
+
|
|
309
|
+
*/
|
|
310
|
+
dedupe?: boolean;
|
|
297
311
|
}
|
|
298
312
|
interface UseSessionTrackingOptions {
|
|
299
313
|
enabled?: boolean;
|
|
@@ -366,7 +380,7 @@ declare const useCookieConsent: () => {
|
|
|
366
380
|
resetConsent: () => void;
|
|
367
381
|
};
|
|
368
382
|
|
|
369
|
-
declare const usePageTracking: ({ path, search, title, fullUrl, metadata, enabled, }: UsePageTrackingOptions) => void;
|
|
383
|
+
declare const usePageTracking: ({ path, search, title, fullUrl, metadata, enabled, trackPageLeave, dedupe, }: UsePageTrackingOptions) => void;
|
|
370
384
|
|
|
371
385
|
declare const useSessionTracking: ({ enabled, metadata, }?: UseSessionTrackingOptions) => void;
|
|
372
386
|
|
package/dist/index.js
CHANGED
|
@@ -29594,7 +29594,7 @@ var CookieBanner = ({
|
|
|
29594
29594
|
] })
|
|
29595
29595
|
}
|
|
29596
29596
|
),
|
|
29597
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
29597
|
+
preferencesOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
29598
29598
|
CookiePreferencesModal_default,
|
|
29599
29599
|
{
|
|
29600
29600
|
open: preferencesOpen,
|
|
@@ -29605,7 +29605,7 @@ var CookieBanner = ({
|
|
|
29605
29605
|
save: labels?.save
|
|
29606
29606
|
}
|
|
29607
29607
|
}
|
|
29608
|
-
)
|
|
29608
|
+
) : null
|
|
29609
29609
|
] });
|
|
29610
29610
|
};
|
|
29611
29611
|
var usePageTracking = ({
|
|
@@ -29614,17 +29614,29 @@ var usePageTracking = ({
|
|
|
29614
29614
|
title,
|
|
29615
29615
|
fullUrl,
|
|
29616
29616
|
metadata,
|
|
29617
|
-
enabled = true
|
|
29617
|
+
enabled = true,
|
|
29618
|
+
trackPageLeave = false,
|
|
29619
|
+
dedupe = true
|
|
29618
29620
|
}) => {
|
|
29619
29621
|
const { track } = useAnalytics();
|
|
29622
|
+
const trackRef = React25.useRef(track);
|
|
29620
29623
|
const enteredAtRef = React25.useRef(Date.now());
|
|
29621
29624
|
const previousPathRef = React25.useRef(null);
|
|
29625
|
+
const trackedPathsRef = React25.useRef(/* @__PURE__ */ new Set());
|
|
29626
|
+
React25.useEffect(() => {
|
|
29627
|
+
trackRef.current = track;
|
|
29628
|
+
}, [track]);
|
|
29629
|
+
const metadataKey = React25.useMemo(() => JSON.stringify(metadata ?? {}), [metadata]);
|
|
29622
29630
|
React25.useEffect(() => {
|
|
29623
29631
|
if (!enabled) return;
|
|
29624
29632
|
const nextPath = `${path2}${search3}`;
|
|
29625
|
-
if (
|
|
29633
|
+
if (!nextPath) return;
|
|
29634
|
+
if (dedupe && trackedPathsRef.current.has(nextPath)) {
|
|
29635
|
+
return;
|
|
29636
|
+
}
|
|
29637
|
+
if (trackPageLeave && previousPathRef.current) {
|
|
29626
29638
|
const durationMs = Date.now() - enteredAtRef.current;
|
|
29627
|
-
|
|
29639
|
+
trackRef.current("page_leave", {
|
|
29628
29640
|
path: previousPathRef.current,
|
|
29629
29641
|
durationMs,
|
|
29630
29642
|
metadata
|
|
@@ -29632,21 +29644,32 @@ var usePageTracking = ({
|
|
|
29632
29644
|
}
|
|
29633
29645
|
enteredAtRef.current = Date.now();
|
|
29634
29646
|
previousPathRef.current = nextPath;
|
|
29635
|
-
|
|
29647
|
+
trackedPathsRef.current.add(nextPath);
|
|
29648
|
+
trackRef.current("page_view", {
|
|
29636
29649
|
path: nextPath,
|
|
29637
29650
|
title,
|
|
29638
29651
|
fullUrl,
|
|
29639
29652
|
metadata
|
|
29640
29653
|
});
|
|
29641
29654
|
return () => {
|
|
29655
|
+
if (!trackPageLeave) return;
|
|
29642
29656
|
const durationMs = Date.now() - enteredAtRef.current;
|
|
29643
|
-
|
|
29657
|
+
trackRef.current("page_leave", {
|
|
29644
29658
|
path: nextPath,
|
|
29645
29659
|
durationMs,
|
|
29646
29660
|
metadata
|
|
29647
29661
|
});
|
|
29648
29662
|
};
|
|
29649
|
-
}, [
|
|
29663
|
+
}, [
|
|
29664
|
+
dedupe,
|
|
29665
|
+
enabled,
|
|
29666
|
+
fullUrl,
|
|
29667
|
+
metadataKey,
|
|
29668
|
+
path2,
|
|
29669
|
+
search3,
|
|
29670
|
+
title,
|
|
29671
|
+
trackPageLeave
|
|
29672
|
+
]);
|
|
29650
29673
|
};
|
|
29651
29674
|
var useSessionTracking = ({
|
|
29652
29675
|
enabled = true,
|