elseware-ui 2.40.1 → 2.40.3
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/LICENSE +20 -20
- package/dist/index.d.mts +25 -16
- package/dist/index.d.ts +25 -16
- package/dist/index.js +73 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5020,7 +5020,7 @@ var EUI_ANALYTICS_QUEUE_STORAGE_KEY = "eui.analytics.queue";
|
|
|
5020
5020
|
var DEFAULT_ANALYTICS_CONFIG = {
|
|
5021
5021
|
enabled: true,
|
|
5022
5022
|
trackPageViews: true,
|
|
5023
|
-
trackSession:
|
|
5023
|
+
trackSession: false,
|
|
5024
5024
|
flushIntervalMs: 1e4,
|
|
5025
5025
|
maxBatchSize: 20,
|
|
5026
5026
|
respectDoNotTrack: true,
|
|
@@ -5062,7 +5062,9 @@ var createDefaultConsent = (version) => ({
|
|
|
5062
5062
|
marketing: false
|
|
5063
5063
|
}
|
|
5064
5064
|
});
|
|
5065
|
-
var AnalyticsContext = createContext(
|
|
5065
|
+
var AnalyticsContext = createContext(
|
|
5066
|
+
null
|
|
5067
|
+
);
|
|
5066
5068
|
|
|
5067
5069
|
// src/components/analytics/analytics.utils.ts
|
|
5068
5070
|
var isBrowser = () => typeof window !== "undefined";
|
|
@@ -5131,16 +5133,12 @@ var createAnalyticsEvent = ({
|
|
|
5131
5133
|
type: type2,
|
|
5132
5134
|
appId,
|
|
5133
5135
|
sessionId,
|
|
5134
|
-
anonymousId,
|
|
5135
|
-
userId,
|
|
5136
|
-
path: getCurrentPath(),
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
timestamp: getNowISOString(),
|
|
5141
|
-
viewport: getViewport(),
|
|
5142
|
-
device: getDeviceInfo(),
|
|
5143
|
-
...options,
|
|
5136
|
+
anonymousId: options?.anonymousId ?? anonymousId,
|
|
5137
|
+
userId: options?.userId ?? userId,
|
|
5138
|
+
path: options?.path ?? getCurrentPath(),
|
|
5139
|
+
referrer: options?.referrer ?? getCurrentReferrer(),
|
|
5140
|
+
viewport: options?.viewport ?? getViewport(),
|
|
5141
|
+
device: options?.device ?? getDeviceInfo(),
|
|
5144
5142
|
metadata: {
|
|
5145
5143
|
...options?.metadata
|
|
5146
5144
|
}
|
|
@@ -29604,60 +29602,104 @@ var usePageTracking = ({
|
|
|
29604
29602
|
title,
|
|
29605
29603
|
fullUrl,
|
|
29606
29604
|
metadata,
|
|
29607
|
-
enabled = true
|
|
29605
|
+
enabled = true,
|
|
29606
|
+
trackPageLeave = false,
|
|
29607
|
+
dedupe = true
|
|
29608
29608
|
}) => {
|
|
29609
29609
|
const { track } = useAnalytics();
|
|
29610
|
+
const trackRef = useRef(track);
|
|
29610
29611
|
const enteredAtRef = useRef(Date.now());
|
|
29611
29612
|
const previousPathRef = useRef(null);
|
|
29613
|
+
const trackedPathsRef = useRef(/* @__PURE__ */ new Set());
|
|
29614
|
+
useEffect(() => {
|
|
29615
|
+
trackRef.current = track;
|
|
29616
|
+
}, [track]);
|
|
29617
|
+
const metadataKey = useMemo(() => JSON.stringify(metadata ?? {}), [metadata]);
|
|
29612
29618
|
useEffect(() => {
|
|
29613
29619
|
if (!enabled) return;
|
|
29614
29620
|
const nextPath = `${path2}${search3}`;
|
|
29615
|
-
if (
|
|
29621
|
+
if (!nextPath) return;
|
|
29622
|
+
if (dedupe && trackedPathsRef.current.has(nextPath)) {
|
|
29623
|
+
return;
|
|
29624
|
+
}
|
|
29625
|
+
if (trackPageLeave && previousPathRef.current) {
|
|
29616
29626
|
const durationMs = Date.now() - enteredAtRef.current;
|
|
29617
|
-
|
|
29627
|
+
trackRef.current("custom", {
|
|
29618
29628
|
path: previousPathRef.current,
|
|
29619
|
-
|
|
29620
|
-
|
|
29629
|
+
metadata: {
|
|
29630
|
+
eventName: "page_leave",
|
|
29631
|
+
durationMs,
|
|
29632
|
+
...metadata
|
|
29633
|
+
}
|
|
29621
29634
|
});
|
|
29622
29635
|
}
|
|
29623
29636
|
enteredAtRef.current = Date.now();
|
|
29624
29637
|
previousPathRef.current = nextPath;
|
|
29625
|
-
|
|
29638
|
+
trackedPathsRef.current.add(nextPath);
|
|
29639
|
+
trackRef.current("page_view", {
|
|
29626
29640
|
path: nextPath,
|
|
29627
|
-
|
|
29628
|
-
|
|
29629
|
-
|
|
29641
|
+
metadata: {
|
|
29642
|
+
title,
|
|
29643
|
+
fullUrl,
|
|
29644
|
+
...metadata
|
|
29645
|
+
}
|
|
29630
29646
|
});
|
|
29631
29647
|
return () => {
|
|
29648
|
+
if (!trackPageLeave) return;
|
|
29632
29649
|
const durationMs = Date.now() - enteredAtRef.current;
|
|
29633
|
-
|
|
29650
|
+
trackRef.current("custom", {
|
|
29634
29651
|
path: nextPath,
|
|
29635
|
-
|
|
29636
|
-
|
|
29652
|
+
metadata: {
|
|
29653
|
+
eventName: "page_leave",
|
|
29654
|
+
durationMs,
|
|
29655
|
+
title,
|
|
29656
|
+
fullUrl,
|
|
29657
|
+
...metadata
|
|
29658
|
+
}
|
|
29637
29659
|
});
|
|
29638
29660
|
};
|
|
29639
|
-
}, [
|
|
29661
|
+
}, [
|
|
29662
|
+
dedupe,
|
|
29663
|
+
enabled,
|
|
29664
|
+
fullUrl,
|
|
29665
|
+
metadataKey,
|
|
29666
|
+
path2,
|
|
29667
|
+
search3,
|
|
29668
|
+
title,
|
|
29669
|
+
trackPageLeave
|
|
29670
|
+
]);
|
|
29640
29671
|
};
|
|
29641
29672
|
var useSessionTracking = ({
|
|
29642
29673
|
enabled = true,
|
|
29643
29674
|
metadata
|
|
29644
29675
|
} = {}) => {
|
|
29645
29676
|
const { track } = useAnalytics();
|
|
29677
|
+
const trackRef = useRef(track);
|
|
29646
29678
|
const startedAtRef = useRef(Date.now());
|
|
29647
29679
|
const endedRef = useRef(false);
|
|
29680
|
+
useEffect(() => {
|
|
29681
|
+
trackRef.current = track;
|
|
29682
|
+
}, [track]);
|
|
29683
|
+
const metadataKey = useMemo(() => JSON.stringify(metadata ?? {}), [metadata]);
|
|
29648
29684
|
useEffect(() => {
|
|
29649
29685
|
if (!enabled || !isBrowser()) return;
|
|
29650
29686
|
startedAtRef.current = Date.now();
|
|
29651
29687
|
endedRef.current = false;
|
|
29652
|
-
|
|
29653
|
-
metadata
|
|
29688
|
+
trackRef.current("custom", {
|
|
29689
|
+
metadata: {
|
|
29690
|
+
eventName: "session_start",
|
|
29691
|
+
...metadata
|
|
29692
|
+
}
|
|
29654
29693
|
});
|
|
29655
29694
|
const endSession = () => {
|
|
29656
29695
|
if (endedRef.current) return;
|
|
29657
29696
|
endedRef.current = true;
|
|
29658
|
-
|
|
29659
|
-
|
|
29660
|
-
|
|
29697
|
+
trackRef.current("custom", {
|
|
29698
|
+
metadata: {
|
|
29699
|
+
eventName: "session_end",
|
|
29700
|
+
durationMs: Date.now() - startedAtRef.current,
|
|
29701
|
+
...metadata
|
|
29702
|
+
}
|
|
29661
29703
|
});
|
|
29662
29704
|
};
|
|
29663
29705
|
const handleVisibilityChange = () => {
|
|
@@ -29672,7 +29714,7 @@ var useSessionTracking = ({
|
|
|
29672
29714
|
window.removeEventListener("pagehide", endSession);
|
|
29673
29715
|
document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
29674
29716
|
};
|
|
29675
|
-
}, [enabled,
|
|
29717
|
+
}, [enabled, metadataKey]);
|
|
29676
29718
|
};
|
|
29677
29719
|
var ContentArea = forwardRef(
|
|
29678
29720
|
({ children: children3, styles, enablePadding = false }, ref) => {
|