Skip to content

feat(recordError): accept per-call event metadata - #808

Open
stvnkao wants to merge 1 commit into
aws-observability:mainfrom
stvnkao:feat/record-error-metadata
Open

stvnkao wants to merge 1 commit into
aws-observability:mainfrom
stvnkao:feat/record-error-metadata

Conversation

@stvnkao

@stvnkao stvnkao commented Apr 16, 2026 •

Copy link
Copy Markdown

recordError could not carry caller-supplied attributes, and js_error_event sets additionalProperties: false, so extra keys cannot ride in the event details. Event metadata is the channel built for this, and EventCache already
merges and sanitizes a per-call metadata argument for recordEvent. The argument is named metadata rather than eventDetails because it populates RumEvent.metadata, and "details" already names RumEvent.details.

Scope

  • recordError(error, metadata?) on slim's Orchestration. The behaviorally
    identical packages/web override is deleted, so the full package inherits it.
  • Plugin.record and InternalPlugin.record take a second
    metadata?: EventMetadata, mirroring RecordEvent. An external plugin
    implementing record(data) still satisfies it.
  • cwr('recordError', { error, metadata }). The snippet forwards one payload, so
    only an object literal with both own keys is read as an envelope. A CDN caller
    who previously passed such a literal as the error is the one behavior change.
  • VirtualPageLoadTimer's private record becomes recordEvent, since a
    non-generic InternalPlugin.record makes a private field of that name an
    illegal override.

@github-actions

Copy link
Copy Markdown

══════════════════════════════════════════════════════════════════════
  FULL BUNDLE: cwr.js
══════════════════════════════════════════════════════════════════════
  Total:  161.8 KB raw  /  49.3 KB gzip  (EXACT)
──────────────────────────────────────────────────────────────────────
  Category                              Raw % of total
──────────────────────────────────────────────────────────────────────
  rrweb                             67.3 KB      41.6%
  app: plugins                      27.1 KB      16.7%
  aws-sdk/smithy                    17.6 KB      10.9%
  web-vitals                        10.8 KB       6.7%
  app: dispatch                     10.2 KB       6.3%
  app: sessions                      5.7 KB       3.5%
  app: orchestration                 5.3 KB       3.3%
  app: auth                          4.6 KB       2.8%
  app: event-cache                   4.0 KB       2.5%
  app: utils                         2.8 KB       1.7%
  app: other                         1.7 KB       1.1%
  tslib                              1.5 KB       0.9%
  shimmer                            1.4 KB       0.9%
  uuid                               0.8 KB       0.5%
  app: event-bus                     0.4 KB       0.3%
  app: remote-config                 0.4 KB       0.2%
  webpack runtime                    0.1 KB       0.1%
  (unattributed/boilerplate)         0.1 KB       0.1%
──────────────────────────────────────────────────────────────────────
  Sizes are EXACT (from source map character attribution).
  Gzip total is EXACT. Per-category gzip is not shown (not additive).

  All modules (110):
       15.5 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js
       11.2 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observer.js
       10.8 KB  ../../node_modules/web-vitals/dist/web-vitals.attribution.js
        7.7 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/mutation.js
        6.8 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/index.js
        6.8 KB  ../../node_modules/rrweb/es/rrweb/_virtual/image-bitmap-data-url-worker.js
        4.2 KB  ../core/src/dispatch/Dispatch.ts
        4.1 KB  ../core/src/plugins/event-plugins/NavigationPlugin.ts
        4.0 KB  ../core/src/event-cache/EventCache.ts
        3.8 KB  ../core/src/plugins/event-plugins/XhrPlugin.ts
        3.4 KB  ../core/src/plugins/event-plugins/RRWebPlugin.ts
        3.4 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/utils.js
        3.4 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/iframe-manager.js
        3.3 KB  ../core/src/sessions/SessionManager.ts
        3.2 KB  ../slim/src/orchestration/Orchestration.ts
        3.1 KB  ../../node_modules/@smithy/signature-v4/dist-es/SignatureV4.js
        2.9 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js
        2.8 KB  ../core/src/plugins/event-plugins/FetchPlugin.ts
        2.5 KB  ../core/src/plugins/event-plugins/WebVitalsPlugin.ts
        2.4 KB  ../core/src/sessions/PageManager.ts
        2.4 KB  ../core/src/dispatch/CognitoIdentityClient.ts
        2.3 KB  ../../node_modules/@smithy/signature-v4/dist-es/HeaderFormatter.js
        2.2 KB  ../../node_modules/@smithy/fetch-http-handler/dist-es/fetch-http-handler.js
        2.2 KB  ../core/src/plugins/utils/http-utils.ts
        2.0 KB  ../core/src/plugins/event-plugins/DomEventPlugin.ts
        1.8 KB  ../../node_modules/@aws-crypto/sha256-js/build/module/RawSha256.js
        1.8 KB  ../core/src/dispatch/DataPlaneClient.ts
        1.6 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js
        1.5 KB  ../../node_modules/tslib/tslib.es6.mjs
        1.4 KB  ../../node_modules/shimmer/index.js
        1.4 KB  ./src/orchestration/Orchestration.ts
        1.3 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js
        1.2 KB  ../core/src/plugins/event-plugins/ResourcePlugin.ts
        1.2 KB  ../core/src/utils/common-utils.ts
        1.2 KB  ../../node_modules/@smithy/signature-v4/dist-es/SignatureV4Base.js
        1.2 KB  ../../node_modules/rrweb/es/rrweb/packages/types/dist/types.js
        1.2 KB  ../slim/src/CommandQueue.ts
        1.1 KB  ../core/src/plugins/event-plugins/JsErrorPlugin.ts
        1.0 KB  ../core/src/dispatch/FetchHttpHandler.ts
        1.0 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/cross-origin-iframe-mirror.js
        1.0 KB  ../core/src/dispatch/Authentication.ts
        0.9 KB  ../core/src/plugins/event-plugins/PageViewPlugin.ts
        0.9 KB  ../core/src/utils/InternalLogger.ts
        0.9 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js
        0.9 KB  ../core/src/dispatch/StsClient.ts
        0.9 KB  ../core/src/plugins/PluginManager.ts
        0.9 KB  ../../node_modules/@aws-crypto/sha256-js/build/module/jsSha256.js
        0.9 KB  ../../node_modules/@smithy/protocol-http/dist-es/httpRequest.js
        0.8 KB  ../../node_modules/@aws-crypto/sha256-js/build/module/constants.js
        0.8 KB  ../core/src/plugins/utils/js-error-utils.ts
        0.8 KB  ../core/src/dispatch/BasicAuthentication.ts
        0.7 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js
        0.7 KB  ../core/src/dispatch/compression.ts
        0.6 KB  ../../node_modules/rrweb/es/rrweb/ext/tslib/tslib.es6.js
        0.6 KB  ../../node_modules/@smithy/signature-v4/dist-es/constants.js
        0.6 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js
        0.5 KB  ../core/src/dispatch/EnhancedAuthentication.ts
        0.5 KB  ../../node_modules/@smithy/util-hex-encoding/dist-es/index.js
        0.5 KB  ../core/src/dispatch/RetryHttpHandler.ts
        0.5 KB  ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js
        0.4 KB  ../core/src/orchestration/config.ts
        0.4 KB  ../../node_modules/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js
        0.4 KB  ../core/src/plugins/utils/constant.ts
        0.4 KB  ../core/src/event-bus/EventBus.ts
        0.4 KB  ../core/src/utils/cookies-utils.ts
        0.4 KB  ../core/src/plugins/MonkeyPatched.ts
        0.4 KB  ../../node_modules/@smithy/signature-v4/dist-es/credentialDerivation.js
        0.4 KB  ./src/remote-config/remote-config.ts
        0.3 KB  ../core/src/dispatch/BeaconHttpHandler.ts
        0.3 KB  ./src/orchestration/config.ts
        0.3 KB  ../../node_modules/rrweb/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js
        0.3 KB  ../../node_modules/@smithy/signature-v4/dist-es/getCanonicalQuery.js
        0.3 KB  ./src/dispatch/signing.ts
        0.3 KB  ../../node_modules/@smithy/signature-v4/dist-es/getPayloadHash.js
        0.3 KB  ../../node_modules/uuid/dist/esm-browser/rng.js
        0.3 KB  ./src/CommandQueue.ts
        0.3 KB  ../../node_modules/@aws-crypto/util/build/module/convertToBuffer.js
        0.3 KB  ../../node_modules/uuid/dist/esm-browser/stringify.js
        0.3 KB  ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js
        0.3 KB  ../core/src/plugins/utils/performance-utils.ts
        0.3 KB  ../../node_modules/@smithy/protocol-http/dist-es/httpResponse.js
        0.3 KB  ../core/src/plugins/InternalPlugin.ts
        0.2 KB  ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js
        0.2 KB  ../../node_modules/@smithy/signature-v4/dist-es/moveHeadersToQuery.js
        0.2 KB  ../../node_modules/@smithy/querystring-builder/dist-es/index.js
        0.2 KB  ../../node_modules/@smithy/signature-v4/dist-es/getCanonicalHeaders.js
        0.2 KB  ./src/index-browser.ts
        0.2 KB  ../core/src/dispatch/utils.ts
        0.2 KB  ../../node_modules/uuid/dist/esm-browser/v4.js
        0.2 KB  ../../node_modules/@smithy/signature-v4/dist-es/utilDate.js
        0.2 KB  ../../node_modules/@smithy/fetch-http-handler/dist-es/request-timeout.js
        0.1 KB  ../../node_modules/@smithy/util-utf8/dist-es/toUint8Array.js
        0.1 KB  ../core/src/dispatch/request-timeout.ts
        0.1 KB  ../core/src/utils/random.ts
        0.1 KB  webpack/bootstrap
        0.1 KB  ../../node_modules/@smithy/is-array-buffer/dist-es/index.js
        0.1 KB  ../../node_modules/@smithy/signature-v4/dist-es/prepareRequest.js
        0.1 KB  ../../node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
        0.1 KB  ../../node_modules/@smithy/signature-v4/dist-es/headerUtil.js
        0.1 KB  ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js
        0.1 KB  ../../node_modules/uuid/dist/esm-browser/native.js
        0.1 KB  ../core/src/errors/XhrError.ts
        0.1 KB  ../../node_modules/@smithy/util-middleware/dist-es/normalizeProvider.js
        0.1 KB  ../core/src/utils/constants.ts
        0.1 KB  ../../node_modules/@aws-crypto/util/build/module/isEmptyData.js
        0.0 KB  ../../node_modules/rrweb/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js
        0.0 KB  ../../node_modules/@smithy/fetch-http-handler/dist-es/create-request.js
        0.0 KB  ../../node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js
        0.0 KB  ../../node_modules/@aws-crypto/util/node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js
        0.0 KB  ../core/src/utils/version.ts


══════════════════════════════════════════════════════════════════════
  SLIM BUNDLE: cwr-slim.js
══════════════════════════════════════════════════════════════════════
  Total:  31.7 KB raw  /  9.7 KB gzip  (EXACT)
──────────────────────────────────────────────────────────────────────
  Category                              Raw % of total
──────────────────────────────────────────────────────────────────────
  app: dispatch                      8.7 KB      27.3%
  app: sessions                      5.7 KB      18.1%
  app: event-cache                   4.0 KB      12.7%
  app: orchestration                 3.6 KB      11.2%
  app: plugins                       2.7 KB       8.4%
  aws-sdk/smithy                     1.4 KB       4.6%
  app: utils                         1.4 KB       4.4%
  shimmer                            1.4 KB       4.4%
  app: other                         1.4 KB       4.4%
  uuid                               0.8 KB       2.7%
  app: event-bus                     0.4 KB       1.3%
  webpack runtime                    0.1 KB       0.4%
──────────────────────────────────────────────────────────────────────
  Sizes are EXACT (from source map character attribution).
  Gzip total is EXACT. Per-category gzip is not shown (not additive).

  All modules (35):
        4.2 KB  web-slim/../core/src/dispatch/Dispatch.ts
        4.0 KB  web-slim/../core/src/event-cache/EventCache.ts
        3.3 KB  web-slim/../core/src/sessions/SessionManager.ts
        3.1 KB  web-slim/./src/orchestration/Orchestration.ts
        2.4 KB  web-slim/../core/src/sessions/PageManager.ts
        1.8 KB  web-slim/../core/src/dispatch/DataPlaneClient.ts
        1.4 KB  web-slim/../../node_modules/shimmer/index.js
        1.2 KB  web-slim/./src/CommandQueue.ts
        1.0 KB  web-slim/../core/src/dispatch/FetchHttpHandler.ts
        0.9 KB  web-slim/../core/src/plugins/event-plugins/PageViewPlugin.ts
        0.9 KB  web-slim/../core/src/utils/InternalLogger.ts
        0.9 KB  web-slim/../core/src/plugins/PluginManager.ts
        0.9 KB  web-slim/../../node_modules/@smithy/protocol-http/dist-es/httpRequest.js
        0.7 KB  web-slim/../core/src/dispatch/compression.ts
        0.5 KB  web-slim/../core/src/dispatch/RetryHttpHandler.ts
        0.4 KB  web-slim/../core/src/orchestration/config.ts
        0.4 KB  web-slim/../core/src/event-bus/EventBus.ts
        0.4 KB  web-slim/../core/src/utils/cookies-utils.ts
        0.4 KB  web-slim/../core/src/plugins/MonkeyPatched.ts
        0.3 KB  web-slim/../core/src/dispatch/BeaconHttpHandler.ts
        0.3 KB  web-slim/../../node_modules/uuid/dist/esm-browser/rng.js
        0.3 KB  web-slim/../../node_modules/uuid/dist/esm-browser/stringify.js
        0.3 KB  web-slim/../../node_modules/@smithy/protocol-http/dist-es/httpResponse.js
        0.2 KB  web-slim/../core/src/plugins/InternalPlugin.ts
        0.2 KB  web-slim/../../node_modules/@smithy/querystring-builder/dist-es/index.js
        0.2 KB  web-slim/./src/index-browser.ts
        0.2 KB  web-slim/../../node_modules/uuid/dist/esm-browser/v4.js
        0.1 KB  web-slim/../core/src/dispatch/request-timeout.ts
        0.1 KB  web-slim/../core/src/plugins/utils/http-utils.ts
        0.1 KB  web-slim/webpack/bootstrap
        0.1 KB  web-slim/../../node_modules/@smithy/util-uri-escape/dist-es/escape-uri.js
        0.1 KB  web-slim/../core/src/plugins/utils/constant.ts
        0.1 KB  web-slim/../../node_modules/uuid/dist/esm-browser/native.js
        0.1 KB  web-slim/../core/src/utils/constants.ts
        0.0 KB  web-slim/../core/src/utils/version.ts

  Slim saves 80% gzip vs full (EXACT).

Report written to reports/bundle-stats-both.txt

@stvnkao
stvnkao force-pushed the feat/record-error-metadata branch 3 times, most recently from c1a7ec3 to 35e0e5d Compare September 22, 2026 13:47
@stvnkao stvnkao changed the title feat: add optional eventDetails parameter to recordError feat(recordError): accept per-call event metadata Sep 22, 2026
## Why

`recordError` could not carry caller-supplied attributes, and `js_error_event`
sets `additionalProperties: false`, so extra keys cannot ride in the event
details. Event metadata is the channel built for this, and `EventCache` already
merges and sanitizes a per-call metadata argument for `recordEvent`. The
argument is named `metadata` rather than `eventDetails` because it populates
`RumEvent.metadata`, and "details" already names `RumEvent.details`.

## Scope

- `recordError(error, metadata?)` on slim's `Orchestration`. The behaviorally
  identical `packages/web` override is deleted, so the full package inherits it.
- `Plugin.record` and `InternalPlugin.record` take a second
  `metadata?: EventMetadata`, mirroring `RecordEvent`. An external plugin
  implementing `record(data)` still satisfies it.
- `cwr('recordError', { error, metadata })`. The snippet forwards one payload, so
  only an object literal with both own keys is read as an envelope. A CDN caller
  who previously passed such a literal as the error is the one behavior change.
- `VirtualPageLoadTimer`'s private `record` becomes `recordEvent`, since a
  non-generic `InternalPlugin.record` makes a private field of that name an
  illegal override.

## Verification

763 unit tests and the `JsErrorPlugin` integ suite pass in chromium, including a
new case driving the CDN envelope end to end.
@stvnkao
stvnkao force-pushed the feat/record-error-metadata branch from 35e0e5d to 607c680 Compare September 23, 2026 02:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant