@atlaskit/react-ufo 5.1.3 → 5.2.0

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 (40) hide show
  1. package/AGENTS.md +426 -0
  2. package/CHANGELOG.md +22 -0
  3. package/dist/cjs/create-payload/index.js +3 -3
  4. package/dist/cjs/hidden-timing/index.js +135 -0
  5. package/dist/cjs/interaction-metrics/index.js +11 -3
  6. package/dist/cjs/interaction-metrics-init/index.js +3 -0
  7. package/dist/cjs/set-terminal-error/index.js +11 -3
  8. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +39 -27
  9. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +22 -7
  10. package/dist/es2019/create-payload/index.js +3 -3
  11. package/dist/es2019/hidden-timing/index.js +128 -0
  12. package/dist/es2019/interaction-metrics/index.js +10 -2
  13. package/dist/es2019/interaction-metrics-init/index.js +4 -1
  14. package/dist/es2019/set-terminal-error/index.js +12 -4
  15. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +17 -4
  16. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +22 -7
  17. package/dist/esm/create-payload/index.js +4 -4
  18. package/dist/esm/hidden-timing/index.js +130 -0
  19. package/dist/esm/interaction-metrics/index.js +10 -2
  20. package/dist/esm/interaction-metrics-init/index.js +4 -1
  21. package/dist/esm/set-terminal-error/index.js +12 -4
  22. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +39 -27
  23. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.js +22 -7
  24. package/dist/types/common/react-ufo-payload-schema.d.ts +1 -0
  25. package/dist/types/common/vc/types.d.ts +2 -0
  26. package/dist/types/create-terminal-error-payload/index.d.ts +4 -0
  27. package/dist/types/hidden-timing/index.d.ts +42 -0
  28. package/dist/types/interaction-metrics/index.d.ts +8 -0
  29. package/dist/types/set-terminal-error/index.d.ts +4 -0
  30. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.d.ts +3 -3
  31. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/types.d.ts +12 -0
  32. package/dist/types-ts4.5/common/react-ufo-payload-schema.d.ts +1 -0
  33. package/dist/types-ts4.5/common/vc/types.d.ts +2 -0
  34. package/dist/types-ts4.5/create-terminal-error-payload/index.d.ts +4 -0
  35. package/dist/types-ts4.5/hidden-timing/index.d.ts +42 -0
  36. package/dist/types-ts4.5/interaction-metrics/index.d.ts +8 -0
  37. package/dist/types-ts4.5/set-terminal-error/index.d.ts +4 -0
  38. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/index.d.ts +3 -3
  39. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/types.d.ts +12 -0
  40. package/package.json +10 -1
@@ -21,6 +21,10 @@ export interface TerminalErrorPayload {
21
21
  activeInteractionName: string | null;
22
22
  activeInteractionId: string | null;
23
23
  activeInteractionType: string | null;
24
+ previousInteractionId: string | null;
25
+ previousInteractionName: string | null;
26
+ previousInteractionType: string | null;
27
+ timeSincePreviousInteraction: number | null;
24
28
  labelStack: LabelStack | null;
25
29
  };
26
30
  };
@@ -9,3 +9,45 @@ export declare function isOpenedInBackground(interactionType: InteractionType):
9
9
  export declare function getHasHiddenTimingBeforeSetup(): boolean;
10
10
  export declare function setupHiddenTimingCapture(): void;
11
11
  export declare function getPageVisibilityState(start: number, end: number): PageVisibility;
12
+ export type ThrottleMeasurement = {
13
+ time: number;
14
+ expectedElapsed: number;
15
+ actualElapsed: number;
16
+ isThrottled: boolean;
17
+ };
18
+ /**
19
+ * Sets up the throttle detection mechanism.
20
+ * This should be called early in the page lifecycle.
21
+ * Uses a periodic timer to detect browser throttling by measuring timer drift.
22
+ */
23
+ export declare function setupThrottleDetection(): void;
24
+ /**
25
+ * Stops the throttle detection mechanism.
26
+ * Useful for cleanup in tests or when the feature is no longer needed.
27
+ */
28
+ export declare function stopThrottleDetection(): void;
29
+ /**
30
+ * Checks if the tab was throttled at any point during the specified time window.
31
+ * Returns true if any timer measurement showed significant drift (throttling).
32
+ *
33
+ * @param startTime - The start timestamp of the window to check (DOMHighResTimeStamp)
34
+ * @param endTime - The end timestamp of the window to check (DOMHighResTimeStamp)
35
+ * @returns boolean - true if throttling was detected during the time window, false otherwise
36
+ */
37
+ export declare function isTabThrottled(startTime: number, endTime: number): boolean;
38
+ /**
39
+ * Gets detailed throttle information for debugging purposes.
40
+ * Returns all throttle measurements within the specified time window.
41
+ *
42
+ * @param startTime - The start timestamp of the window to check
43
+ * @param endTime - The end timestamp of the window to check
44
+ * @returns Array of throttle measurements within the time window
45
+ */
46
+ export declare function getThrottleMeasurements(startTime: number, endTime: number): ThrottleMeasurement[];
47
+ /**
48
+ * Injects a fake throttle measurement for testing purposes.
49
+ * This allows integration tests to simulate throttling scenarios.
50
+ *
51
+ * @param measurement - The throttle measurement to inject
52
+ */
53
+ export declare function __injectThrottleMeasurementForTesting(measurement: ThrottleMeasurement): void;
@@ -5,6 +5,14 @@ import type { LabelStack } from '../interaction-context';
5
5
  import InteractionExtraMetrics from './interaction-extra-metrics';
6
6
  import PostInteractionLog from './post-interaction-log';
7
7
  export type { InteractionMetrics, LifecycleMarkType, Span, Mark, MarkType, InteractionType, AbortReasonType, ReactProfilerTiming, RequestInfo, ApdexType, CustomData, CustomTiming, InteractionError, };
8
+ export type PreviousInteractionLogType = {
9
+ id: string | undefined;
10
+ name: string | undefined;
11
+ type: string | undefined;
12
+ isAborted: boolean | undefined;
13
+ timestamp: number | undefined;
14
+ };
15
+ export declare const PreviousInteractionLog: PreviousInteractionLogType;
8
16
  export declare const postInteractionLog: PostInteractionLog;
9
17
  export declare const interactionExtraMetrics: InteractionExtraMetrics;
10
18
  export declare const segmentUnmountCache: Map<string, number>;
@@ -18,6 +18,10 @@ export interface TerminalErrorContext {
18
18
  activeInteractionName: string | null;
19
19
  activeInteractionId: string | null;
20
20
  activeInteractionType: string | null;
21
+ previousInteractionId: string | null;
22
+ previousInteractionName: string | null;
23
+ previousInteractionType: string | null;
24
+ timeSincePreviousInteraction: number | null;
21
25
  }
22
26
  export declare function sinkTerminalErrorHandler(fn: (errorData: TerminalErrorData, context: TerminalErrorContext) => void | Promise<void>): void;
23
27
  export declare function setTerminalError(error: Error, additionalAttributes?: TerminalErrorAdditionalAttributes, labelStack?: LabelStack): void;
@@ -1,9 +1,9 @@
1
1
  import type { RevisionPayloadVCDetails } from '../../../../../common/vc/types';
2
2
  import type { ViewportEntryData } from '../../../types';
3
- import type { CalcTTVCPercentilesArg, CalcTTVCPercentilesArgWithDebugInfo, PercentileCalcResult } from '../types';
3
+ import type { CalcTTVCPercentilesArg, CalcTTVCPercentilesArgWithDebugInfo, PercentileCalcResultWithSpeedIndex } from '../types';
4
4
  declare function calculateTTVCPercentiles({ viewport, orderedEntries, percentiles, startTime, }: CalcTTVCPercentilesArg): Promise<RevisionPayloadVCDetails>;
5
- declare function calculateTTVCPercentilesWithDebugInfo({ viewport, orderedEntries, startTime, }: CalcTTVCPercentilesArgWithDebugInfo): Promise<PercentileCalcResult>;
5
+ declare function calculateTTVCPercentilesWithDebugInfo({ viewport, orderedEntries, startTime, calculateSpeedIndex, }: CalcTTVCPercentilesArgWithDebugInfo): Promise<PercentileCalcResultWithSpeedIndex>;
6
6
  export default calculateTTVCPercentiles;
7
7
  export declare function calculatePercentiles(timePixelCounts: Map<DOMHighResTimeStamp, number>, elementMap: ReadonlyMap<DOMHighResTimeStamp, Set<string>>, unorderedPercentiles: number[], totalPixels: number, startTime: DOMHighResTimeStamp): RevisionPayloadVCDetails;
8
- export declare function calculatePercentilesWithDebugInfo(timePixelCounts: Map<DOMHighResTimeStamp, number>, elementMap: ReadonlyMap<DOMHighResTimeStamp, ViewportEntryData[]>, totalPixels: number, startTime: DOMHighResTimeStamp): PercentileCalcResult;
8
+ export declare function calculatePercentilesWithDebugInfo(timePixelCounts: Map<DOMHighResTimeStamp, number>, elementMap: ReadonlyMap<DOMHighResTimeStamp, ViewportEntryData[]>, totalPixels: number, startTime: DOMHighResTimeStamp, calculateSpeedIndex?: boolean): PercentileCalcResultWithSpeedIndex;
9
9
  export { calculateTTVCPercentilesWithDebugInfo };
@@ -17,6 +17,11 @@ export type CalcTTVCPercentilesArgWithDebugInfo = {
17
17
  orderedEntries: ReadonlyArray<VCObserverEntry>;
18
18
  startTime: DOMHighResTimeStamp;
19
19
  stopTime: DOMHighResTimeStamp;
20
+ /**
21
+ * Whether to calculate speed index metric.
22
+ * Controlled by platform_ufo_ttvc_v4_speed_index feature flag.
23
+ */
24
+ calculateSpeedIndex?: boolean;
20
25
  };
21
26
  export interface PercentileCalcResultItem {
22
27
  time: number;
@@ -27,3 +32,10 @@ export interface PercentileCalcResultItem {
27
32
  * Ordered by time
28
33
  */
29
34
  export type PercentileCalcResult = PercentileCalcResultItem[];
35
+ /**
36
+ * Result of percentile calculation with debug info, including speed index
37
+ */
38
+ export type PercentileCalcResultWithSpeedIndex = {
39
+ entries: PercentileCalcResult;
40
+ speedIndex: number;
41
+ };
@@ -121,6 +121,7 @@ export type ReactUFOPayload = {
121
121
  'ufo:pageVisibilityHiddenTimestamp'?: number;
122
122
  'ufo:wasPageHiddenBeforeInit'?: boolean;
123
123
  'ufo:isOpenedInBackground'?: boolean;
124
+ 'ufo:isTabThrottled'?: boolean;
124
125
  interactionMetrics: {
125
126
  namePrefix: string;
126
127
  segmentPrefix: string;
@@ -117,6 +117,7 @@ export type RevisionPayloadVCDetails = Record<string, {
117
117
  export type CalculateTTVCResult = {
118
118
  vcDetails: RevisionPayloadVCDetails;
119
119
  ssrRatio: number;
120
+ speedIndex: number;
120
121
  };
121
122
  export type RawObservation = {
122
123
  t: number;
@@ -141,6 +142,7 @@ export type RevisionPayloadEntry = {
141
142
  vcDetails?: RevisionPayloadVCDetails;
142
143
  ratios?: VCRatioType;
143
144
  ssrRatio?: number;
145
+ speedIndex?: number;
144
146
  labelStacks?: VCLabelStacks;
145
147
  abortReason?: VCAbortReason | null;
146
148
  abortTimestamp?: number;
@@ -21,6 +21,10 @@ export interface TerminalErrorPayload {
21
21
  activeInteractionName: string | null;
22
22
  activeInteractionId: string | null;
23
23
  activeInteractionType: string | null;
24
+ previousInteractionId: string | null;
25
+ previousInteractionName: string | null;
26
+ previousInteractionType: string | null;
27
+ timeSincePreviousInteraction: number | null;
24
28
  labelStack: LabelStack | null;
25
29
  };
26
30
  };
@@ -9,3 +9,45 @@ export declare function isOpenedInBackground(interactionType: InteractionType):
9
9
  export declare function getHasHiddenTimingBeforeSetup(): boolean;
10
10
  export declare function setupHiddenTimingCapture(): void;
11
11
  export declare function getPageVisibilityState(start: number, end: number): PageVisibility;
12
+ export type ThrottleMeasurement = {
13
+ time: number;
14
+ expectedElapsed: number;
15
+ actualElapsed: number;
16
+ isThrottled: boolean;
17
+ };
18
+ /**
19
+ * Sets up the throttle detection mechanism.
20
+ * This should be called early in the page lifecycle.
21
+ * Uses a periodic timer to detect browser throttling by measuring timer drift.
22
+ */
23
+ export declare function setupThrottleDetection(): void;
24
+ /**
25
+ * Stops the throttle detection mechanism.
26
+ * Useful for cleanup in tests or when the feature is no longer needed.
27
+ */
28
+ export declare function stopThrottleDetection(): void;
29
+ /**
30
+ * Checks if the tab was throttled at any point during the specified time window.
31
+ * Returns true if any timer measurement showed significant drift (throttling).
32
+ *
33
+ * @param startTime - The start timestamp of the window to check (DOMHighResTimeStamp)
34
+ * @param endTime - The end timestamp of the window to check (DOMHighResTimeStamp)
35
+ * @returns boolean - true if throttling was detected during the time window, false otherwise
36
+ */
37
+ export declare function isTabThrottled(startTime: number, endTime: number): boolean;
38
+ /**
39
+ * Gets detailed throttle information for debugging purposes.
40
+ * Returns all throttle measurements within the specified time window.
41
+ *
42
+ * @param startTime - The start timestamp of the window to check
43
+ * @param endTime - The end timestamp of the window to check
44
+ * @returns Array of throttle measurements within the time window
45
+ */
46
+ export declare function getThrottleMeasurements(startTime: number, endTime: number): ThrottleMeasurement[];
47
+ /**
48
+ * Injects a fake throttle measurement for testing purposes.
49
+ * This allows integration tests to simulate throttling scenarios.
50
+ *
51
+ * @param measurement - The throttle measurement to inject
52
+ */
53
+ export declare function __injectThrottleMeasurementForTesting(measurement: ThrottleMeasurement): void;
@@ -5,6 +5,14 @@ import type { LabelStack } from '../interaction-context';
5
5
  import InteractionExtraMetrics from './interaction-extra-metrics';
6
6
  import PostInteractionLog from './post-interaction-log';
7
7
  export type { InteractionMetrics, LifecycleMarkType, Span, Mark, MarkType, InteractionType, AbortReasonType, ReactProfilerTiming, RequestInfo, ApdexType, CustomData, CustomTiming, InteractionError, };
8
+ export type PreviousInteractionLogType = {
9
+ id: string | undefined;
10
+ name: string | undefined;
11
+ type: string | undefined;
12
+ isAborted: boolean | undefined;
13
+ timestamp: number | undefined;
14
+ };
15
+ export declare const PreviousInteractionLog: PreviousInteractionLogType;
8
16
  export declare const postInteractionLog: PostInteractionLog;
9
17
  export declare const interactionExtraMetrics: InteractionExtraMetrics;
10
18
  export declare const segmentUnmountCache: Map<string, number>;
@@ -18,6 +18,10 @@ export interface TerminalErrorContext {
18
18
  activeInteractionName: string | null;
19
19
  activeInteractionId: string | null;
20
20
  activeInteractionType: string | null;
21
+ previousInteractionId: string | null;
22
+ previousInteractionName: string | null;
23
+ previousInteractionType: string | null;
24
+ timeSincePreviousInteraction: number | null;
21
25
  }
22
26
  export declare function sinkTerminalErrorHandler(fn: (errorData: TerminalErrorData, context: TerminalErrorContext) => void | Promise<void>): void;
23
27
  export declare function setTerminalError(error: Error, additionalAttributes?: TerminalErrorAdditionalAttributes, labelStack?: LabelStack): void;
@@ -1,9 +1,9 @@
1
1
  import type { RevisionPayloadVCDetails } from '../../../../../common/vc/types';
2
2
  import type { ViewportEntryData } from '../../../types';
3
- import type { CalcTTVCPercentilesArg, CalcTTVCPercentilesArgWithDebugInfo, PercentileCalcResult } from '../types';
3
+ import type { CalcTTVCPercentilesArg, CalcTTVCPercentilesArgWithDebugInfo, PercentileCalcResultWithSpeedIndex } from '../types';
4
4
  declare function calculateTTVCPercentiles({ viewport, orderedEntries, percentiles, startTime, }: CalcTTVCPercentilesArg): Promise<RevisionPayloadVCDetails>;
5
- declare function calculateTTVCPercentilesWithDebugInfo({ viewport, orderedEntries, startTime, }: CalcTTVCPercentilesArgWithDebugInfo): Promise<PercentileCalcResult>;
5
+ declare function calculateTTVCPercentilesWithDebugInfo({ viewport, orderedEntries, startTime, calculateSpeedIndex, }: CalcTTVCPercentilesArgWithDebugInfo): Promise<PercentileCalcResultWithSpeedIndex>;
6
6
  export default calculateTTVCPercentiles;
7
7
  export declare function calculatePercentiles(timePixelCounts: Map<DOMHighResTimeStamp, number>, elementMap: ReadonlyMap<DOMHighResTimeStamp, Set<string>>, unorderedPercentiles: number[], totalPixels: number, startTime: DOMHighResTimeStamp): RevisionPayloadVCDetails;
8
- export declare function calculatePercentilesWithDebugInfo(timePixelCounts: Map<DOMHighResTimeStamp, number>, elementMap: ReadonlyMap<DOMHighResTimeStamp, ViewportEntryData[]>, totalPixels: number, startTime: DOMHighResTimeStamp): PercentileCalcResult;
8
+ export declare function calculatePercentilesWithDebugInfo(timePixelCounts: Map<DOMHighResTimeStamp, number>, elementMap: ReadonlyMap<DOMHighResTimeStamp, ViewportEntryData[]>, totalPixels: number, startTime: DOMHighResTimeStamp, calculateSpeedIndex?: boolean): PercentileCalcResultWithSpeedIndex;
9
9
  export { calculateTTVCPercentilesWithDebugInfo };
@@ -17,6 +17,11 @@ export type CalcTTVCPercentilesArgWithDebugInfo = {
17
17
  orderedEntries: ReadonlyArray<VCObserverEntry>;
18
18
  startTime: DOMHighResTimeStamp;
19
19
  stopTime: DOMHighResTimeStamp;
20
+ /**
21
+ * Whether to calculate speed index metric.
22
+ * Controlled by platform_ufo_ttvc_v4_speed_index feature flag.
23
+ */
24
+ calculateSpeedIndex?: boolean;
20
25
  };
21
26
  export interface PercentileCalcResultItem {
22
27
  time: number;
@@ -27,3 +32,10 @@ export interface PercentileCalcResultItem {
27
32
  * Ordered by time
28
33
  */
29
34
  export type PercentileCalcResult = PercentileCalcResultItem[];
35
+ /**
36
+ * Result of percentile calculation with debug info, including speed index
37
+ */
38
+ export type PercentileCalcResultWithSpeedIndex = {
39
+ entries: PercentileCalcResult;
40
+ speedIndex: number;
41
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "5.1.3",
3
+ "version": "5.2.0",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -101,6 +101,9 @@
101
101
  "ufo_payload_use_idle_callback": {
102
102
  "type": "boolean"
103
103
  },
104
+ "platform_ufo_is_tab_throttled": {
105
+ "type": "boolean"
106
+ },
104
107
  "platform_ufo_assets_check_for_nan": {
105
108
  "type": "boolean"
106
109
  },
@@ -200,8 +203,14 @@
200
203
  "rovo_search_page_ttvc_ignoring_smart_answers_fix": {
201
204
  "type": "boolean"
202
205
  },
206
+ "ufo_remove_featureflags_from_trimmed_fields": {
207
+ "type": "boolean"
208
+ },
203
209
  "platform_ufo_enable_terminal_errors": {
204
210
  "type": "boolean"
211
+ },
212
+ "platform_ufo_ttvc_v4_speed_index": {
213
+ "type": "boolean"
205
214
  }
206
215
  }
207
216
  }