@temps-sdk/react-analytics 0.0.3 → 0.0.7

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.
Files changed (44) hide show
  1. package/README.md +38 -7
  2. package/dist/EngagementTracker.d.ts +1 -54
  3. package/dist/EngagementTracker.d.ts.map +1 -1
  4. package/dist/EngagementTracker.js +3 -222
  5. package/dist/Provider.d.ts +2 -1
  6. package/dist/Provider.d.ts.map +1 -1
  7. package/dist/Provider.js +25 -10
  8. package/dist/SessionRecorder.d.ts +51 -52
  9. package/dist/SessionRecorder.d.ts.map +1 -1
  10. package/dist/SessionRecorder.js +32 -527
  11. package/dist/constants.d.ts +1 -1
  12. package/dist/constants.d.ts.map +1 -1
  13. package/dist/constants.js +3 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3 -1
  17. package/dist/types.d.ts +9 -59
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/types.js +2 -0
  20. package/dist/useAnalytics.d.ts +3 -2
  21. package/dist/useAnalytics.d.ts.map +1 -1
  22. package/dist/useAnalytics.js +2 -0
  23. package/dist/useEngagementTracking.d.ts +3 -2
  24. package/dist/useEngagementTracking.d.ts.map +1 -1
  25. package/dist/useEngagementTracking.js +12 -23
  26. package/dist/usePageLeave.d.ts +4 -2
  27. package/dist/usePageLeave.d.ts.map +1 -1
  28. package/dist/usePageLeave.js +2 -0
  29. package/dist/useScrollVisibility.d.ts.map +1 -1
  30. package/dist/useScrollVisibility.js +2 -0
  31. package/dist/useSessionRecording.d.ts +5 -3
  32. package/dist/useSessionRecording.d.ts.map +1 -1
  33. package/dist/useSessionRecording.js +42 -42
  34. package/dist/useSpeedAnalytics.d.ts +11 -0
  35. package/dist/useSpeedAnalytics.d.ts.map +1 -1
  36. package/dist/useSpeedAnalytics.js +13 -53
  37. package/dist/useTrackEvent.d.ts.map +1 -1
  38. package/dist/useTrackEvent.js +2 -0
  39. package/dist/useTrackPageview.d.ts.map +1 -1
  40. package/dist/useTrackPageview.js +2 -0
  41. package/dist/utils.d.ts +1 -6
  42. package/dist/utils.d.ts.map +1 -1
  43. package/dist/utils.js +3 -96
  44. package/package.json +4 -3
package/dist/types.d.ts CHANGED
@@ -1,24 +1,7 @@
1
1
  import type React from "react";
2
- export type JsonPrimitive = string | number | boolean | null;
3
- export type JsonValue = JsonPrimitive | JsonValue[] | {
4
- [key: string]: JsonValue;
5
- };
6
- export interface AnalyticsEventBase {
7
- event_name: string;
8
- request_query?: string;
9
- request_path?: string;
10
- event_data?: Record<string, JsonValue>;
11
- }
12
- export interface AnalyticsClientOptions {
13
- /** Base endpoint path. Defaults to `/_temps`. */
14
- basePath?: string;
15
- /** Set to true to disable analytics (e.g., for tests). */
16
- disabled?: boolean;
17
- /** Ignore localhost/test env automatically. Defaults to true. */
18
- ignoreLocalhost?: boolean;
19
- /** Custom domain to use for analytics. Defaults to window.location.hostname. */
20
- domain?: string;
21
- }
2
+ import type { JsonValue, AnalyticsClientOptions } from "@temps-sdk/analytics-core";
3
+ import type { SessionRecorderConfig } from "./SessionRecorder";
4
+ export type { JsonPrimitive, JsonValue, AnalyticsEventBase, AnalyticsClientOptions, WebVitalMetric, SpeedMetric, } from "@temps-sdk/analytics-core";
22
5
  export interface AnalyticsContextValue {
23
6
  /** Send a custom event. */
24
7
  trackEvent: (eventName: string, data?: Record<string, JsonValue>) => Promise<void>;
@@ -48,46 +31,13 @@ export interface TempsAnalyticsProviderProps extends AnalyticsClientOptions {
48
31
  engagementThreshold?: number;
49
32
  /** Enable session recording. Defaults to false. */
50
33
  enableSessionRecording?: boolean;
51
- /** Session recording configuration. */
52
- sessionRecordingConfig?: {
53
- /** Paths to exclude from recording. */
54
- excludedPaths?: string[];
55
- /** Sample rate for recording sessions (0.0 to 1.0). Defaults to 1.0. */
56
- sessionSampleRate?: number;
57
- /** Mask all inputs. Defaults to true. */
58
- maskAllInputs?: boolean;
59
- /** CSS selector for masking text. Defaults to "[data-mask]". */
60
- maskTextSelector?: string;
61
- /** CSS class to block from recording. Defaults to "rr-block". */
62
- blockClass?: string;
63
- /** CSS class to ignore from recording. Defaults to "rr-ignore". */
64
- ignoreClass?: string;
65
- /** CSS class to mask text. Defaults to "rr-mask". */
66
- maskTextClass?: string;
67
- /** Record canvas elements. Defaults to false. */
68
- recordCanvas?: boolean;
69
- /** Collect fonts. Defaults to false. */
70
- collectFonts?: boolean;
71
- /** Number of events to batch before sending. Defaults to 100. */
72
- batchSize?: number;
73
- /** Interval in ms to flush events. Defaults to 5000. */
74
- flushInterval?: number;
75
- };
34
+ /**
35
+ * Session recording configuration, forwarded to the recorder in full
36
+ * (including `idleTimeout`, `useDefaultExcludedPaths`, `debug` and the
37
+ * rrweb-level options).
38
+ */
39
+ sessionRecordingConfig?: SessionRecorderConfig;
76
40
  /** Children to render inside the provider. */
77
41
  children: React.ReactNode;
78
42
  }
79
- export interface WebVitalMetric {
80
- value: number;
81
- rating: "good" | "needs-improvement" | "poor";
82
- }
83
- export interface SpeedMetric {
84
- ttfb?: number | null;
85
- lcp?: number | null;
86
- fid?: number | null;
87
- fcp?: number | null;
88
- cls?: number | null;
89
- inp?: number | null;
90
- path?: string | null;
91
- query?: string | null;
92
- }
93
43
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnF,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAA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AC;IAC3B,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wGAAwG;IACxG,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mDAAmD;IACnD,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,qBAAqB,CAAC;IAC/C,8CAA8C;IAC9C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
package/dist/types.js CHANGED
@@ -1 +1,3 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  export {};
@@ -7,8 +7,9 @@ export interface UseAnalyticsOptions {
7
7
  client: AnalyticsClient;
8
8
  defaultContext?: Record<string, unknown>;
9
9
  }
10
- export declare function useAnalytics(options: UseAnalyticsOptions): {
10
+ export interface UseAnalyticsResult {
11
11
  track: (eventName: string, payload?: AnalyticsEventPayload) => void | Promise<void>;
12
12
  identify: (userId: string, traits?: Record<string, unknown>) => void | Promise<void>;
13
- };
13
+ }
14
+ export declare function useAnalytics(options: UseAnalyticsOptions): UseAnalyticsResult;
14
15
  //# sourceMappingURL=useAnalytics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAnalytics.d.ts","sourceRoot":"","sources":["../src/useAnalytics.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5D,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AAED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3 +1,5 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { useCallback, useMemo } from "react";
3
5
  export function useAnalytics(options) {
@@ -27,8 +27,9 @@ export interface UseEngagementTrackingOptions extends Omit<EngagementTrackerOpti
27
27
  * }
28
28
  * ```
29
29
  */
30
- export declare function useEngagementTracking(options?: UseEngagementTrackingOptions): {
30
+ export interface UseEngagementTrackingResult {
31
31
  engagementData: EngagementData;
32
32
  isTracking: boolean;
33
- };
33
+ }
34
+ export declare function useEngagementTracking(options?: UseEngagementTrackingOptions): UseEngagementTrackingResult;
34
35
  //# sourceMappingURL=useEngagementTracking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEngagementTracking.d.ts","sourceRoot":"","sources":["../src/useEngagementTracking.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,wBAAwB,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5G,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,QAAQ,CAAC;IACzG,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,4CAA4C;IAC5C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC;;;EAkD/E"}
1
+ {"version":3,"file":"useEngagementTracking.d.ts","sourceRoot":"","sources":["../src/useEngagementTracking.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,wBAAwB,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG5G,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,wBAAwB,EAAE,UAAU,GAAG,QAAQ,CAAC;IACzG,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,4CAA4C;IAC5C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,2BAA2B;IAC1C,cAAc,EAAE,cAAc,CAAC;IAC/B,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,qBAAqB,CACnC,OAAO,GAAE,4BAAiC,GACzC,2BAA2B,CA2D7B"}
@@ -1,27 +1,9 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { useEffect, useRef } from "react";
3
5
  import { EngagementTracker } from "./EngagementTracker";
4
6
  import { useTempsAnalytics } from "./Provider";
5
- /**
6
- * Hook to manually control engagement tracking for specific components or pages.
7
- * This is useful when you want fine-grained control over engagement tracking
8
- * or need to track engagement for specific sections of your app.
9
- *
10
- * @example
11
- * ```tsx
12
- * function ArticlePage() {
13
- * const { engagementData } = useEngagementTracking({
14
- * heartbeatInterval: 15000, // Send heartbeat every 15 seconds
15
- * engagementThreshold: 5000, // Consider engaged after 5 seconds
16
- * onEngagementUpdate: (data) => {
17
- * console.log('Engagement updated:', data);
18
- * }
19
- * });
20
- *
21
- * return <article>...</article>;
22
- * }
23
- * ```
24
- */
25
7
  export function useEngagementTracking(options = {}) {
26
8
  const analytics = useTempsAnalytics();
27
9
  const trackerRef = useRef(null);
@@ -33,21 +15,28 @@ export function useEngagementTracking(options = {}) {
33
15
  is_visible: true,
34
16
  time_since_last_activity: 0,
35
17
  });
36
- const { enabled = true, onEngagementUpdate, onPageLeave, ...trackerOptions } = options;
18
+ const { enabled = true } = options;
19
+ // Callers usually pass an inline options object, so it is a new value on
20
+ // every render. Keeping it in a ref lets the callbacks always see the latest
21
+ // closure without tearing the tracker down and recreating it each render.
22
+ // Tracker settings (intervals, thresholds) are read when tracking starts.
23
+ const optionsRef = useRef(options);
24
+ optionsRef.current = options;
37
25
  useEffect(() => {
38
26
  if (!enabled || !analytics.enabled) {
39
27
  return;
40
28
  }
29
+ const { enabled: _enabled, onEngagementUpdate: _onEngagementUpdate, onPageLeave: _onPageLeave, ...trackerOptions } = optionsRef.current;
41
30
  // Create tracker instance
42
31
  trackerRef.current = new EngagementTracker({
43
32
  ...trackerOptions,
44
33
  onHeartbeat: (data) => {
45
34
  engagementDataRef.current = data;
46
- onEngagementUpdate?.(data);
35
+ optionsRef.current.onEngagementUpdate?.(data);
47
36
  },
48
37
  onPageLeave: (data) => {
49
38
  engagementDataRef.current = data;
50
- onPageLeave?.(data);
39
+ optionsRef.current.onPageLeave?.(data);
51
40
  },
52
41
  });
53
42
  // Cleanup on unmount
@@ -7,7 +7,9 @@ export interface UsePageLeaveOptions {
7
7
  /** Whether to enable page leave tracking. Defaults to true */
8
8
  enabled?: boolean;
9
9
  }
10
- export declare function usePageLeave(options?: UsePageLeaveOptions): {
10
+ export interface UsePageLeaveResult {
11
+ /** Send the page-leave event now; resolves once sent, `undefined` if skipped. */
11
12
  triggerPageLeave: () => Promise<void> | undefined;
12
- };
13
+ }
14
+ export declare function usePageLeave(options?: UsePageLeaveOptions): UsePageLeaveResult;
13
15
  //# sourceMappingURL=usePageLeave.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePageLeave.d.ts","sourceRoot":"","sources":["../src/usePageLeave.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,8DAA8D;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB;;EA2E7D"}
1
+ {"version":3,"file":"usePageLeave.d.ts","sourceRoot":"","sources":["../src/usePageLeave.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,8DAA8D;IAC9D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;CACnD;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,kBAAkB,CA2ElF"}
@@ -1,3 +1,5 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { useEffect, useRef } from "react";
3
5
  import { useTempsAnalytics } from "./Provider";
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollVisibility.d.ts","sourceRoot":"","sources":["../src/useScrollVisibility.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEtC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B,UAyBjE,WAAW,GAAG,IAAI,UAwC5B"}
1
+ {"version":3,"file":"useScrollVisibility.d.ts","sourceRoot":"","sources":["../src/useScrollVisibility.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEtC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAiEpC"}
@@ -1,3 +1,5 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { useCallback, useEffect, useRef } from "react";
3
5
  import { useTempsAnalytics } from "./Provider";
@@ -1,4 +1,5 @@
1
1
  import type React from "react";
2
+ import type { ReactElement } from "react";
2
3
  interface SessionRecordingContextValue {
3
4
  isRecordingEnabled: boolean;
4
5
  enableRecording: () => void;
@@ -11,13 +12,14 @@ interface SessionRecordingProviderProps {
11
12
  defaultEnabled?: boolean;
12
13
  persistPreference?: boolean;
13
14
  }
14
- export declare function SessionRecordingProvider({ children, defaultEnabled, persistPreference }: SessionRecordingProviderProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function SessionRecordingProvider({ children, defaultEnabled, persistPreference }: SessionRecordingProviderProps): ReactElement;
15
16
  export declare function useSessionRecording(): SessionRecordingContextValue;
16
- export declare function useSessionRecordingControl(defaultEnabled?: boolean): {
17
+ export interface SessionRecordingControl {
17
18
  isEnabled: boolean;
18
19
  enable: () => void;
19
20
  disable: () => void;
20
21
  toggle: () => void;
21
- };
22
+ }
23
+ export declare function useSessionRecordingControl(defaultEnabled?: boolean): SessionRecordingControl;
22
24
  export {};
23
25
  //# sourceMappingURL=useSessionRecording.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSessionRecording.d.ts","sourceRoot":"","sources":["../src/useSessionRecording.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,UAAU,4BAA4B;IACpC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAID,UAAU,6BAA6B;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,cAAsB,EACtB,iBAAwB,EACzB,EAAE,6BAA6B,2CA8D/B;AAED,wBAAgB,mBAAmB,IAAI,4BAA4B,CAMlE;AAGD,wBAAgB,0BAA0B,CAAC,cAAc,UAAQ;;;;;EAyChE"}
1
+ {"version":3,"file":"useSessionRecording.d.ts","sourceRoot":"","sources":["../src/useSessionRecording.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,UAAU,4BAA4B;IACpC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAiCD,UAAU,6BAA6B;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,cAAsB,EACtB,iBAAwB,EACzB,EAAE,6BAA6B,GAAG,YAAY,CA6C9C;AAED,wBAAgB,mBAAmB,IAAI,4BAA4B,CAMlE;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAGD,wBAAgB,0BAA0B,CAAC,cAAc,UAAQ,GAAG,uBAAuB,CA2B1F"}
@@ -1,44 +1,58 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { jsx as _jsx } from "react/jsx-runtime";
3
5
  import { useState, useEffect, useCallback, createContext, useContext, useMemo } from "react";
4
6
  const SessionRecordingContext = createContext(undefined);
7
+ const PREFERENCE_KEY = "temps_session_recording_enabled";
8
+ /**
9
+ * `localStorage` access that cannot throw. Storage may be blocked (site data
10
+ * disabled, sandboxed iframe: merely reading `localStorage` throws) or full;
11
+ * the recording preference is a convenience and must never take the host
12
+ * app's render or event handler down with it.
13
+ */
14
+ function readStorage(key) {
15
+ try {
16
+ return typeof localStorage === "undefined" ? null : localStorage.getItem(key);
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ function writeStorage(key, value) {
23
+ try {
24
+ if (typeof localStorage !== "undefined")
25
+ localStorage.setItem(key, value);
26
+ }
27
+ catch (error) {
28
+ console.warn("[SessionRecording] could not persist the recording preference:", error);
29
+ }
30
+ }
31
+ function readPreference(defaultEnabled) {
32
+ const stored = readStorage(PREFERENCE_KEY);
33
+ return stored === null ? defaultEnabled : stored === "true";
34
+ }
5
35
  export function SessionRecordingProvider({ children, defaultEnabled = false, persistPreference = true }) {
6
- const [isRecordingEnabled, setIsRecordingEnabled] = useState(() => {
7
- if (!persistPreference)
8
- return defaultEnabled;
9
- if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
10
- const stored = localStorage.getItem("temps_session_recording_enabled");
11
- if (stored !== null) {
12
- return stored === "true";
13
- }
14
- }
15
- return defaultEnabled;
16
- });
36
+ const [isRecordingEnabled, setIsRecordingEnabled] = useState(() => persistPreference ? readPreference(defaultEnabled) : defaultEnabled);
17
37
  const [sessionId, setSessionId] = useState(null);
18
38
  useEffect(() => {
19
- if (typeof localStorage !== "undefined") {
20
- const storedSessionId = localStorage.getItem("currentRecordingSessionId");
21
- setSessionId(storedSessionId);
22
- }
39
+ setSessionId(readStorage("currentRecordingSessionId"));
23
40
  }, [isRecordingEnabled]);
24
41
  const enableRecording = useCallback(() => {
25
42
  setIsRecordingEnabled(true);
26
- if (persistPreference && typeof localStorage !== "undefined") {
27
- localStorage.setItem("temps_session_recording_enabled", "true");
28
- }
43
+ if (persistPreference)
44
+ writeStorage(PREFERENCE_KEY, "true");
29
45
  }, [persistPreference]);
30
46
  const disableRecording = useCallback(() => {
31
47
  setIsRecordingEnabled(false);
32
- if (persistPreference && typeof localStorage !== "undefined") {
33
- localStorage.setItem("temps_session_recording_enabled", "false");
34
- }
48
+ if (persistPreference)
49
+ writeStorage(PREFERENCE_KEY, "false");
35
50
  }, [persistPreference]);
36
51
  const toggleRecording = useCallback(() => {
37
52
  setIsRecordingEnabled(prev => {
38
53
  const newValue = !prev;
39
- if (persistPreference && typeof localStorage !== "undefined") {
40
- localStorage.setItem("temps_session_recording_enabled", String(newValue));
41
- }
54
+ if (persistPreference)
55
+ writeStorage(PREFERENCE_KEY, String(newValue));
42
56
  return newValue;
43
57
  });
44
58
  }, [persistPreference]);
@@ -60,33 +74,19 @@ export function useSessionRecording() {
60
74
  }
61
75
  // Standalone hook for controlling session recording without provider
62
76
  export function useSessionRecordingControl(defaultEnabled = false) {
63
- const [isEnabled, setIsEnabled] = useState(() => {
64
- if (typeof window !== "undefined" && typeof localStorage !== "undefined") {
65
- const stored = localStorage.getItem("temps_session_recording_enabled");
66
- if (stored !== null) {
67
- return stored === "true";
68
- }
69
- }
70
- return defaultEnabled;
71
- });
77
+ const [isEnabled, setIsEnabled] = useState(() => readPreference(defaultEnabled));
72
78
  const enable = useCallback(() => {
73
79
  setIsEnabled(true);
74
- if (typeof localStorage !== "undefined") {
75
- localStorage.setItem("temps_session_recording_enabled", "true");
76
- }
80
+ writeStorage(PREFERENCE_KEY, "true");
77
81
  }, []);
78
82
  const disable = useCallback(() => {
79
83
  setIsEnabled(false);
80
- if (typeof localStorage !== "undefined") {
81
- localStorage.setItem("temps_session_recording_enabled", "false");
82
- }
84
+ writeStorage(PREFERENCE_KEY, "false");
83
85
  }, []);
84
86
  const toggle = useCallback(() => {
85
87
  setIsEnabled(prev => {
86
88
  const newValue = !prev;
87
- if (typeof localStorage !== "undefined") {
88
- localStorage.setItem("temps_session_recording_enabled", String(newValue));
89
- }
89
+ writeStorage(PREFERENCE_KEY, String(newValue));
90
90
  return newValue;
91
91
  });
92
92
  }, []);
@@ -1,8 +1,19 @@
1
1
  export interface UseSpeedAnalyticsOptions {
2
2
  /** Base endpoint path. Defaults to `/_temps`. */
3
3
  basePath?: string;
4
+ /**
5
+ * Analytics ingest key (`pa_…`). Required only when Temps does not serve or
6
+ * proxy the app. See `AnalyticsClientOptions.ingestKey`.
7
+ */
8
+ ingestKey?: string;
4
9
  /** Set to true to disable speed analytics. Defaults to false. */
5
10
  disabled?: boolean;
6
11
  }
12
+ /**
13
+ * Reports Web Vitals for the page that mounted the hook. See `SpeedTracker`
14
+ * for what is sent and when: load metrics never wait for an interaction, and
15
+ * every beacon is attributed to the path captured at mount, not the path
16
+ * current when a late CLS/INP value is reported.
17
+ */
7
18
  export declare function useSpeedAnalytics(options?: UseSpeedAnalyticsOptions): void;
8
19
  //# sourceMappingURL=useSpeedAnalytics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSpeedAnalytics.d.ts","sourceRoot":"","sources":["../src/useSpeedAnalytics.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,wBAAwB;IACvC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,QAgEvE"}
1
+ {"version":3,"file":"useSpeedAnalytics.d.ts","sourceRoot":"","sources":["../src/useSpeedAnalytics.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,IAAI,CAQ9E"}
@@ -1,60 +1,20 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { useEffect } from "react";
3
- import { onCLS, onFID, onLCP, onTTFB, onFCP, onINP } from "web-vitals";
4
- import { sendAnalytics } from "./utils";
5
+ import { SpeedTracker } from "@temps-sdk/analytics-core";
6
+ /**
7
+ * Reports Web Vitals for the page that mounted the hook. See `SpeedTracker`
8
+ * for what is sent and when: load metrics never wait for an interaction, and
9
+ * every beacon is attributed to the path captured at mount, not the path
10
+ * current when a late CLS/INP value is reported.
11
+ */
5
12
  export function useSpeedAnalytics(options = {}) {
6
- const { basePath = "/_temps", disabled = false } = options;
13
+ const { basePath = "/_temps", ingestKey, disabled = false } = options;
7
14
  useEffect(() => {
8
15
  if (disabled || typeof window === "undefined")
9
16
  return;
10
- const initialMetrics = {};
11
- const lateMetrics = {};
12
- const sendInitialMetrics = () => {
13
- if (Object.keys(initialMetrics).length === 4) {
14
- const metricsPayload = {
15
- ttfb: initialMetrics.TTFB?.value ?? null,
16
- lcp: initialMetrics.LCP?.value ?? null,
17
- fid: initialMetrics.FID?.value ?? null,
18
- fcp: initialMetrics.FCP?.value ?? null,
19
- path: window.location.pathname,
20
- query: window.location.search,
21
- };
22
- sendAnalytics("speed", metricsPayload, "POST", basePath);
23
- }
24
- };
25
- const sendLateMetric = (metricName, value) => {
26
- const payload = {
27
- [metricName.toLowerCase()]: value,
28
- path: window.location.pathname,
29
- query: window.location.search,
30
- };
31
- sendAnalytics("speed", payload, "POST", basePath);
32
- };
33
- // Track metrics that can be gathered quickly
34
- onTTFB((metric) => {
35
- initialMetrics.TTFB = { value: metric.value, rating: metric.rating };
36
- sendInitialMetrics();
37
- });
38
- onLCP((metric) => {
39
- initialMetrics.LCP = { value: metric.value, rating: metric.rating };
40
- sendInitialMetrics();
41
- });
42
- onFID((metric) => {
43
- initialMetrics.FID = { value: metric.value, rating: metric.rating };
44
- sendInitialMetrics();
45
- });
46
- onFCP((metric) => {
47
- initialMetrics.FCP = { value: metric.value, rating: metric.rating };
48
- sendInitialMetrics();
49
- });
50
- // Track metrics that take longer to stabilize
51
- onCLS((metric) => {
52
- lateMetrics.CLS = { value: metric.value, rating: metric.rating };
53
- sendLateMetric("cls", metric.value);
54
- });
55
- onINP((metric) => {
56
- lateMetrics.INP = { value: metric.value, rating: metric.rating };
57
- sendLateMetric("inp", metric.value);
58
- });
59
- }, [basePath, disabled]);
17
+ const tracker = new SpeedTracker({ basePath, ingestKey });
18
+ return () => tracker.destroy();
19
+ }, [basePath, ingestKey, disabled]);
60
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTrackEvent.d.ts","sourceRoot":"","sources":["../src/useTrackEvent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,aAAa,gBAEI,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,mBACxE"}
1
+ {"version":3,"file":"useTrackEvent.d.ts","sourceRoot":"","sources":["../src/useTrackEvent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,aAAa,IAAI,CAC/B,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,KAC7B,OAAO,CAAC,IAAI,CAAC,CAGjB"}
@@ -1,3 +1,5 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { useCallback } from "react";
3
5
  import { useTempsAnalytics } from "./Provider";
@@ -1 +1 @@
1
- {"version":3,"file":"useTrackPageview.d.ts","sourceRoot":"","sources":["../src/useTrackPageview.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,eAG/B"}
1
+ {"version":3,"file":"useTrackPageview.d.ts","sourceRoot":"","sources":["../src/useTrackPageview.ts"],"names":[],"mappings":"AAOA,wBAAgB,gBAAgB,IAAI,MAAM,IAAI,CAG7C"}
@@ -1,3 +1,5 @@
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
1
3
  "use client";
2
4
  import { useCallback } from "react";
3
5
  import { useTempsAnalytics } from "./Provider";
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,2 @@
1
- import type { JsonValue } from "./types";
2
- export declare function getRequestId(): string | undefined;
3
- export declare function isLocalhostLike(): boolean;
4
- export declare function isTestEnvironment(): boolean;
5
- export declare function sendAnalytics(endpoint: string, data: Record<string, JsonValue>, method: "POST" | "PUT" | "PATCH" | undefined, basePath: string): Promise<void>;
6
- export declare function sendAnalyticsReliable(endpoint: string, data: Record<string, JsonValue>, basePath: string): boolean;
1
+ export { getRequestId, isLocalhostLike, isTestEnvironment, sendAnalytics, sendAnalyticsReliable, ingestKeyHeaders, withIngestKey, } from "@temps-sdk/analytics-core";
7
2
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAcjD;AAED,wBAAgB,eAAe,IAAI,OAAO,CASzC;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAY3C;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,YAAS,EACzC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,QAAQ,EAAE,MAAM,GACf,OAAO,CAqCT"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,GACd,MAAM,2BAA2B,CAAC"}