@alwaysmeticulous/sdk-bundles-api 2.290.2 → 2.292.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.
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export { InProgressTestRun } from "./replay-orchestrator/bundle-to-sdk/execute-s
10
10
  export { InProgressTestRunChunk, ExecuteTestRunChunkResult, TestRunChunkExecution, } from "./replay-orchestrator/bundle-to-sdk/execute-scheduled-test-run-chunk";
11
11
  export { ReplayAndStoreResultsResult, ReplayExecution, BeforeUserEventResult, IndexedReplayableEvent, } from "./replay-orchestrator/bundle-to-sdk/execute-replay";
12
12
  export { ScreenshotDiffData } from "./replay-orchestrator/bundle-to-sdk/execute-replay";
13
- export { MeticulousPublicApi, MeticulousPressureObserver, MeticulousPressureObserverConstructor, MeticulousPressureRecord, MeticulousPressureSource, MeticulousPressureState, } from "./window-api/public-window-api";
13
+ export { MeticulousPublicApi, MeticulousPressureObserver, MeticulousPressureObserverConstructor, MeticulousPressureRecord, MeticulousPressureSource, MeticulousPressureState, RecordCustomSnapshotOptions, OnBeforeScreenshotListener, OnBeforeScreenshotListenerOptions, OnReplayCompletionListener, OnReplayCompletionListenerOptions, } from "./window-api/public-window-api";
14
14
  export { MeticulousPrivateApi } from "./window-api/private-window-api";
15
15
  export { BackendRecorderConfig } from "./backend-recorder/sdk-to-bundle/init-backend-recorder";
16
16
  export { BackendRecorderHandle } from "./backend-recorder/bundle-to-sdk/init-backend-recorder";
@@ -297,6 +297,9 @@ export interface GeneratedByTestRun {
297
297
  export interface GeneratedByReplayCommand {
298
298
  type: "replayCommand";
299
299
  }
300
+ export type SessionStartUrlTransform = {
301
+ type: "extract-hash-route";
302
+ };
300
303
  export interface AppUrlConfig {
301
304
  /**
302
305
  * If set, we will ensure that the appUrl pathname is prefixed with this value for the initial navigation.
@@ -325,6 +328,15 @@ export interface AppUrlConfig {
325
328
  * List of query parameters to set to `""` from the app URL before the initial navigation.
326
329
  */
327
330
  queryParamsToEmpty?: string[];
331
+ /**
332
+ * If set, transforms the session start URL before computing the initial navigation URL.
333
+ *
334
+ * `extract-hash-route`: when the session URL has a hash that begins with `#/` (SPA hash routing),
335
+ * promotes the hash content to the real pathname and discards the original pathname.
336
+ * Example: `https://preview.example.com/pr-123/#/dashboard/settings` → pathname `/dashboard/settings`, no hash.
337
+ * Sessions without a `#/` hash are returned unchanged.
338
+ */
339
+ sessionStartUrlTransform?: SessionStartUrlTransform;
328
340
  }
329
341
  export interface NetworkDebuggingOptions {
330
342
  requestRegexes: string[];
@@ -13,6 +13,43 @@ export interface MeticulousPublicApiCommon {
13
13
  isRunningAsTest?: boolean;
14
14
  context: MeticulousPublicContextApi;
15
15
  }
16
+ /**
17
+ * Options for {@link MeticulousPublicReplayApi.recordCustomSnapshot}.
18
+ */
19
+ export interface RecordCustomSnapshotOptions<T = unknown> {
20
+ /**
21
+ * The kind of snapshot. Used to group snapshots so a custom check can fetch
22
+ * every snapshot of a given type across the test run. Must match
23
+ * `^[a-z0-9-]{1,64}$` and must not collide with a built-in snapshot type
24
+ * (e.g. "network-requests").
25
+ */
26
+ snapshotType: string;
27
+ /** The data to snapshot. Must be JSON-serializable. */
28
+ data: T;
29
+ /**
30
+ * Optional version number for the snapshot's shape/semantics. If the version
31
+ * differs between the base and head replays, a failing custom check can be
32
+ * caveated in the UI (the difference may be due to the snapshot format
33
+ * changing rather than a real regression). Defaults to 0 when omitted.
34
+ */
35
+ versionNumber?: number;
36
+ }
37
+ /** Details passed to an {@link OnBeforeScreenshotListener}. */
38
+ export interface OnBeforeScreenshotListenerOptions {
39
+ /**
40
+ * The stage the upcoming screenshot will be tagged with (e.g.
41
+ * "screenshot-after-event-12"). Snapshots recorded during this listener are
42
+ * tagged with the same stage.
43
+ */
44
+ stageDuringSession: string;
45
+ }
46
+ export type OnBeforeScreenshotListener = (options: OnBeforeScreenshotListenerOptions) => void | Promise<void>;
47
+ /** Details passed to an {@link OnReplayCompletionListener}. */
48
+ export interface OnReplayCompletionListenerOptions {
49
+ /** The id of the session being replayed. */
50
+ sessionId: string;
51
+ }
52
+ export type OnReplayCompletionListener = (options: OnReplayCompletionListenerOptions) => void | Promise<void>;
16
53
  export interface MeticulousPublicReplayApi {
17
54
  /**
18
55
  * Call this method to pause the Meticulous replay while your code performs an asynchronous operation
@@ -48,6 +85,63 @@ export interface MeticulousPublicReplayApi {
48
85
  recordCustomEvent(type: string, serializedData: string): {
49
86
  success: boolean;
50
87
  };
88
+ /**
89
+ * Record a snapshot of custom data at the current point in the replay, for use
90
+ * by a custom check. The snapshot is persisted alongside the replay and
91
+ * auto-tagged with the stage during the session at which it was taken
92
+ * (identified by the next screenshot, e.g. "screenshot-after-event-12" or
93
+ * "final-state"), so a custom check can later align and compare the base and
94
+ * head snapshots of the same {@link RecordCustomSnapshotOptions.snapshotType}
95
+ * across a test run.
96
+ *
97
+ * Use this to capture custom data that Meticulous does not snapshot natively,
98
+ * for use by a custom check.
99
+ *
100
+ * Snapshots are only collected when custom snapshotting is enabled for the
101
+ * project; otherwise this is a no-op (the data is still validated).
102
+ *
103
+ * @throws if `data` is not JSON-serializable, or if `snapshotType` is invalid
104
+ * (it must match `^[a-z0-9-]{1,64}$` and must not collide with a built-in
105
+ * snapshot type such as "network-requests").
106
+ */
107
+ recordCustomSnapshot<T = unknown>(options: RecordCustomSnapshotOptions<T>): {
108
+ success: boolean;
109
+ };
110
+ /**
111
+ * Register a listener invoked immediately before each screenshot is taken,
112
+ * once the page has settled. Use it to inspect the state of the page and
113
+ * {@link recordCustomSnapshot | record a snapshot} of it at each screenshot
114
+ * point. Any snapshots recorded synchronously (or awaited) within the listener
115
+ * are tagged with the screenshot about to be taken.
116
+ *
117
+ * The listener must be **read-only**: it runs after the page has settled but
118
+ * before the screenshot is captured, so mutating the DOM (or triggering a
119
+ * re-render) would change the captured screenshot.
120
+ *
121
+ * Prefer **synchronous** work. The listener is awaited on the screenshot
122
+ * critical path and bounded by an internal timeout, and during replay the
123
+ * page's timers run on (frozen) virtual time — so async work that relies on
124
+ * real timers (e.g. `setTimeout`) to make progress will not complete and will
125
+ * be skipped.
126
+ *
127
+ * Listeners are only invoked when custom snapshotting is enabled for the
128
+ * project.
129
+ */
130
+ addOnBeforeScreenshotListener(listener: OnBeforeScreenshotListener): void;
131
+ /**
132
+ * Register a listener invoked once when the replay completes. Use it to
133
+ * capture end-of-replay information — for example final performance metrics —
134
+ * via {@link recordCustomSnapshot}. Snapshots recorded within the listener are
135
+ * tagged with the "final-state" stage.
136
+ *
137
+ * As with {@link addOnBeforeScreenshotListener}, the listener is bounded by an
138
+ * internal timeout and timer-based async work may not complete under virtual
139
+ * time, so prefer synchronous capture.
140
+ *
141
+ * Listeners are only invoked when custom snapshotting is enabled for the
142
+ * project.
143
+ */
144
+ addOnReplayCompletionListener(listener: OnReplayCompletionListener): void;
51
145
  /**
52
146
  * True only in case the performance data associated with this replay is
53
147
  * significant to benchmark the performance of the application.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwaysmeticulous/sdk-bundles-api",
3
- "version": "2.290.2",
3
+ "version": "2.292.0",
4
4
  "description": "Meticulous common types",
5
5
  "license": "ISC",
6
6
  "main": "dist/index.js",
@@ -9,7 +9,7 @@
9
9
  "dist"
10
10
  ],
11
11
  "dependencies": {
12
- "@alwaysmeticulous/api": "2.290.2"
12
+ "@alwaysmeticulous/api": "2.292.0"
13
13
  },
14
14
  "author": {
15
15
  "name": "The Meticulous Team",