elseware-ui 2.40.2 → 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/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: true,
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(null);
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
- fullUrl: getCurrentFullUrl(),
5138
- referrer: getCurrentReferrer(),
5139
- title: getCurrentTitle(),
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
  }
@@ -29626,10 +29624,13 @@ var usePageTracking = ({
29626
29624
  }
29627
29625
  if (trackPageLeave && previousPathRef.current) {
29628
29626
  const durationMs = Date.now() - enteredAtRef.current;
29629
- trackRef.current("page_leave", {
29627
+ trackRef.current("custom", {
29630
29628
  path: previousPathRef.current,
29631
- durationMs,
29632
- metadata
29629
+ metadata: {
29630
+ eventName: "page_leave",
29631
+ durationMs,
29632
+ ...metadata
29633
+ }
29633
29634
  });
29634
29635
  }
29635
29636
  enteredAtRef.current = Date.now();
@@ -29637,17 +29638,24 @@ var usePageTracking = ({
29637
29638
  trackedPathsRef.current.add(nextPath);
29638
29639
  trackRef.current("page_view", {
29639
29640
  path: nextPath,
29640
- title,
29641
- fullUrl,
29642
- metadata
29641
+ metadata: {
29642
+ title,
29643
+ fullUrl,
29644
+ ...metadata
29645
+ }
29643
29646
  });
29644
29647
  return () => {
29645
29648
  if (!trackPageLeave) return;
29646
29649
  const durationMs = Date.now() - enteredAtRef.current;
29647
- trackRef.current("page_leave", {
29650
+ trackRef.current("custom", {
29648
29651
  path: nextPath,
29649
- durationMs,
29650
- metadata
29652
+ metadata: {
29653
+ eventName: "page_leave",
29654
+ durationMs,
29655
+ title,
29656
+ fullUrl,
29657
+ ...metadata
29658
+ }
29651
29659
  });
29652
29660
  };
29653
29661
  }, [
@@ -29666,21 +29674,32 @@ var useSessionTracking = ({
29666
29674
  metadata
29667
29675
  } = {}) => {
29668
29676
  const { track } = useAnalytics();
29677
+ const trackRef = useRef(track);
29669
29678
  const startedAtRef = useRef(Date.now());
29670
29679
  const endedRef = useRef(false);
29680
+ useEffect(() => {
29681
+ trackRef.current = track;
29682
+ }, [track]);
29683
+ const metadataKey = useMemo(() => JSON.stringify(metadata ?? {}), [metadata]);
29671
29684
  useEffect(() => {
29672
29685
  if (!enabled || !isBrowser()) return;
29673
29686
  startedAtRef.current = Date.now();
29674
29687
  endedRef.current = false;
29675
- track("session_start", {
29676
- metadata
29688
+ trackRef.current("custom", {
29689
+ metadata: {
29690
+ eventName: "session_start",
29691
+ ...metadata
29692
+ }
29677
29693
  });
29678
29694
  const endSession = () => {
29679
29695
  if (endedRef.current) return;
29680
29696
  endedRef.current = true;
29681
- track("session_end", {
29682
- durationMs: Date.now() - startedAtRef.current,
29683
- metadata
29697
+ trackRef.current("custom", {
29698
+ metadata: {
29699
+ eventName: "session_end",
29700
+ durationMs: Date.now() - startedAtRef.current,
29701
+ ...metadata
29702
+ }
29684
29703
  });
29685
29704
  };
29686
29705
  const handleVisibilityChange = () => {
@@ -29695,7 +29714,7 @@ var useSessionTracking = ({
29695
29714
  window.removeEventListener("pagehide", endSession);
29696
29715
  document.removeEventListener("visibilitychange", handleVisibilityChange);
29697
29716
  };
29698
- }, [enabled, metadata, track]);
29717
+ }, [enabled, metadataKey]);
29699
29718
  };
29700
29719
  var ContentArea = forwardRef(
29701
29720
  ({ children: children3, styles, enablePadding = false }, ref) => {