@alwaysmeticulous/sdk-bundles-api 2.334.0 → 2.337.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, RecordCustomSnapshotOptions, OnBeforeScreenshotListener, OnBeforeScreenshotListenerOptions, OnReplayCompletionListener, OnReplayCompletionListenerOptions, } from "./window-api/public-window-api";
13
+ export { MeticulousPublicApi, FeatureFlagOverride, 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 { RunCrawlOptions, RunCrawlResult, } from "./crawler/sdk-to-bundle/run-crawl";
16
16
  export { BackendRecorderConfig, BackendRecorderSpanRedactionHook, } from "./backend-recorder/sdk-to-bundle/init-backend-recorder";
@@ -3,7 +3,14 @@ export interface MeticulousWindowConfig {
3
3
  METICULOUS_RECORDING_TOKEN?: string;
4
4
  METICULOUS_UPLOAD_INTERVAL_MS?: number;
5
5
  METICULOUS_APP_COMMIT_HASH?: string;
6
+ METICULOUS_INLINE_IMAGES?: boolean;
6
7
  METICULOUS_SNAPSHOT_LINKED_STYLESHEETS?: boolean;
8
+ /**
9
+ * Re-capture stylesheet contents that rrweb's own capture missed, so
10
+ * CSS-in-JS apps replay styled. Adds the recovered CSS to the payload, so
11
+ * it is off unless a recording asks for it.
12
+ */
13
+ METICULOUS_STYLESHEET_RESYNC?: boolean;
7
14
  METICULOUS_FORCE_RECORDING?: boolean;
8
15
  METICULOUS_IS_PRODUCTION_ENVIRONMENT?: boolean;
9
16
  METICULOUS_NETWORK_RESPONSE_SANITIZERS?: NetworkResponseSanitizer[];
@@ -399,14 +399,67 @@ export interface MeticulousPublicRecordApi {
399
399
  */
400
400
  stopRecording(): void;
401
401
  }
402
+ /**
403
+ * Result of {@link MeticulousPublicContextApi.getFlagOverride}.
404
+ *
405
+ * `overridden: false` means Meticulous has no opinion on this flag and your
406
+ * application should fall back to its own evaluation.
407
+ */
408
+ export type FeatureFlagOverride = {
409
+ overridden: false;
410
+ } | {
411
+ overridden: true;
412
+ value: string | boolean;
413
+ };
402
414
  export interface MeticulousPublicContextApi {
403
415
  /**
404
- * Call this method to record the value of a feature flag. If this method is called multiple times
405
- * with the same label, the value will be overwritten.
416
+ * Record the value of a feature flag that your application actually used. If this
417
+ * method is called multiple times with the same label, the value will be overwritten.
418
+ *
419
+ * If you also call {@link getFlagOverride} in the same resolver, record the value you
420
+ * returned after applying the override — not a later snapshot from your flag SDK.
406
421
  */
407
422
  recordFeatureFlag(label: string, value: string | boolean): {
408
423
  success: boolean;
409
424
  };
425
+ /**
426
+ * Ask Meticulous whether the current replay should force a particular value for a feature flag,
427
+ * *before* your application evaluates that flag itself. Unlike
428
+ * {@link recordFeatureFlag}, which stores a value your application has already computed, this
429
+ * method returns a value for your application to use.
430
+ *
431
+ * Call it at the top of whatever resolves flags in your app — a Statsig `checkGate` wrapper, a
432
+ * LaunchDarkly `variation` wrapper, or your own flag resolver — and use the returned value in
433
+ * preference to your normal evaluation when `overridden` is true. Then record that same
434
+ * resolved value with {@link recordFeatureFlag} before returning it. How you consume `value`
435
+ * depends on the helper you wrap:
436
+ *
437
+ * ```js
438
+ * const override = window.Meticulous?.context?.getFlagOverride?.(flagKey);
439
+ * const value = override?.overridden
440
+ * ? Boolean(override.value) // on/off gate
441
+ * : myOwnFlagEvaluation(flagKey);
442
+ * window.Meticulous?.context?.recordFeatureFlag?.(flagKey, value);
443
+ * return value;
444
+ * ```
445
+ *
446
+ * `Boolean()` is right for an on/off gate (`checkGate`). For a value-read
447
+ * (`getExperimentValue` / `variation`) return and record `override.value` as-is —
448
+ * `Boolean('control')` is `true` and would turn every variant on. For an equality-check
449
+ * (`isTreatment(name, expected)` / `editorExperiment(name, expected)`) compare instead
450
+ * (`override.value === expected`) and record `override.value`, not the comparison boolean;
451
+ * coercing or returning the string makes every expected value match, or type-mismatches
452
+ * callers that expect a boolean. Hook the helper your application actually calls.
453
+ *
454
+ * This lets Meticulous test code paths behind flags that were off (or did not exist) when the
455
+ * session was recorded, without you having to re-record sessions.
456
+ *
457
+ * Returns `{ overridden: false }` whenever Meticulous has no override for `label`, and always
458
+ * does so outside of a replay (for real users being recorded), so it is safe to call from
459
+ * production code. Use optional chaining as above so your app also works when the Meticulous
460
+ * recorder is not loaded at all.
461
+ */
462
+ getFlagOverride(label: string): FeatureFlagOverride;
410
463
  /**
411
464
  * Call this method to record some custom context about the session. For instance, you could use
412
465
  * this to capture whether a user is opted into beta features, or what colour scheme they have
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwaysmeticulous/sdk-bundles-api",
3
- "version": "2.334.0",
3
+ "version": "2.337.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.334.0"
12
+ "@alwaysmeticulous/api": "2.337.0"
13
13
  },
14
14
  "author": {
15
15
  "name": "The Meticulous Team",