Skip to content

docs(rum): add Electron SDK integration docs (zh + en) - #222

Draft
Fiona2016 wants to merge 2 commits into
mainfrom
feat/rum-electron-sdk-docs
Draft

docs(rum): add Electron SDK integration docs (zh + en)#222
Fiona2016 wants to merge 2 commits into
mainfrom
feat/rum-electron-sdk-docs

Conversation

@Fiona2016

@Fiona2016 Fiona2016 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What

Adds the Electron platform to the RUM SDK docs. zh/rum/sdk/ and en/rum/sdk/ previously covered web / android / ios / flutter / harmony / wechat-miniprogram — there was no electron.

Four pages per language under rum/sdk/electron/, mirroring the harmony/flutter page set, registered in docs.json for both languages:

Page Content
sdk-integration Two-process install, the instrument entry point, bundler plugins, renderer setup, bridge behavior
advanced-config Full init options, batching, proxy, manual reporting, operation monitoring, source map upload
compatible Support scope, bundler matrix, v1 limits
data-collection Per-process event types, fields, session rules, upload behavior

Why this platform needed more than a copy-paste

Electron is the first RUM platform with a genuinely two-process integration:

  • The main process uses @flashcatcloud/electron-sdk, whose @flashcatcloud/electron-sdk/instrument entry point must be imported before require('electron') — otherwise dd-trace cannot hook BrowserWindow and preload injection silently fails.
  • Renderers use @flashcatcloud/browser-rum and hand events to the main process over IPC through the DatadogEventBridge object that the dd-trace preload exposes. This requires no configuration — the preload always allows the window's own host.
  • Integrating only one side is the expected failure mode. Both sdk-integration and data-collection are written to prevent it.

The two source values

This is the subtlest thing in these docs, and it is easy to get wrong. Assembly.assembleRendererRumEvent() overrides only session.id and application.id on bridged renderer events and adds container — the renderer's own source is preserved:

Origin source container.source view.url
Main process electron absent electron://main-process
Renderer window browser electron the page URL

Filtering on source:electron alone returns main-process events only. The docs consistently use source:electron OR container.source:electron for whole-application queries.

container.source doubles as the diagnostic for a broken bridge: if renderer events lack it, the preload was never injected — the main process is not integrated, or it was bundled without the plugin.

Sources

Content is derived from the SDK source (sdk/fc-sdk-electron) rather than upstream Datadog docs — the fork changed intake URL rules, restricted the site allowlist, switched to an NDJSON body, and dropped the spans track. Console doc links in utils/docs.ts map to rum/sdk/electron/sdk-integration and rum/sdk/electron/data-collection; both paths exist here.

Package versions are left unpinned, following the convention used by the other npm-based platform docs.

v1 limits documented explicitly

  • No native crash symbolication — crashes are collected and stored, but stacks are shown as raw addresses
  • No Session Replay (defaultPrivacyLevel is forwarded but inert)
  • No APM / distributed tracing — only HTTP spans become RUM resources, IPC and command spans are dropped
  • No source map resolution for main-process stacks: they are raw V8 format, which the backend JavaScript stack parser does not recognize
  • file:// source map matching depends on the runtime install path, which varies per machine. This affects source map resolution only — collection and the bridge are unaffected

Review note

The second commit corrects two factual errors in the first, both caught by the W1 staging smoke test: the bridge was described as opt-in via allowedWebViewHosts (it is not — the preload always allows the window's own host, file:// included), and bridged renderer events were described as carrying source: electron (they keep source: browser plus container.source: electron). Reviewing the squashed diff is more useful than reviewing commit by commit.

Verification

mint broken-links passes.

🤖 Generated with Claude Code

Electron is the first RUM platform that requires a two-process
integration: `@flashcatcloud/electron-sdk` in the main process and
`@flashcatcloud/browser-rum` in renderers, bridged over IPC through the
`DatadogEventBridge` object that dd-trace injects via preload. Integrating
only one side is the failure mode these pages are written to prevent.

Adds four pages per language under `rum/sdk/electron/`, mirroring the
harmony/flutter page set, and registers the group in docs.json for both
languages:

- sdk-integration: install, the `instrument` entry point that must precede
  `require('electron')`, bundler plugins (vite / webpack / esbuild), renderer
  setup, and the `allowedWebViewHosts` allowlist that gates the bridge
- advanced-config: full init options, batching, proxy, manual reporting,
  operation monitoring, source map upload
- compatible: support scope and v1 limits
- data-collection: per-process event types, fields, session rules, upload
  behavior

Content is derived from the SDK source rather than upstream Datadog docs,
since the fork changed intake URL rules, the site allowlist, and dropped the
spans track.

v1 limits documented explicitly: no native crash symbolication (crashes are
stored and shown as raw addresses), no Session Replay, no APM/distributed
tracing, and no source map resolution for main-process stacks. The
`file://` install-path instability that breaks source map matching for
`loadFile()` builds is called out with the custom-protocol workaround.

Doc paths match the console's `utils/docs.ts` mapping for the electron
platform. Package versions are left unpinned, per npm platform convention.

Verified with `mint broken-links`.
Two factual errors from the first commit, both found by W1's staging smoke
test and confirmed against the source.

1. The bridge is not opt-in. The earlier text read `validateAllowedWebViewHosts()`
   returning `[]` for `undefined` as "the bridge is disabled by default", but
   that is the SDK-side config default, not the allowlist the browser SDK
   actually sees. dd-trace's preload builds it as:

       const allowedHosts = [...new Set([location.hostname, ...configuredHosts])]

   The window's own hostname is always included, so a window's own page always
   self-matches and the bridge works with no configuration. `file://` included:
   `location.hostname` is `""` there, the allowlist becomes `[""]`, and
   `canUseEventBridge("")` still matches. `allowedWebViewHosts` is for
   additional third-party hosts in `<webview>` / `BrowserView`, not a switch.

2. Bridged renderer events keep `source: browser`. `Assembly.assembleRendererRumEvent()`
   overrides only `session.id` and `application.id` and adds
   `container.{source, view.id}` — the renderer's own `source` is preserved.
   Main-process events are `source: electron` with
   `view.url: electron://main-process`. Filtering on `source:electron` alone
   therefore returns main-process events only; the correct filter is
   `source:electron OR container.source:electron`.

Changes:
- Replace the "enable the bridge" sections with "the bridge needs no
  configuration" plus a "what a broken bridge looks like" section, since the
  real failure mode is a missing preload injection (main process not
  integrated, or bundled without the plugin), diagnosable via a missing
  `container.source`
- Add a source/container.source/view.url table to both the integration and
  data-collection pages, and correct the verification steps to use the OR filter
- Drop `allowedWebViewHosts` from the basic init examples; it is not needed
- Decouple the `app://` custom-protocol recommendation from the bridge. It now
  stands only on source map path stability, with an explicit note that the
  bridge works fine under `file://`
- Mark the `file://` install-path limitation as affecting source map
  resolution only, not collection
- Align the proxy section with the README: `site` stays required but is unused
  for URL building once `proxy` is set, and name the self-hosted use case

Verified with `mint broken-links`.
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