✨ split RumEvent into RendererRumEvent and MainRumEvent - #207
Conversation
bf7c83b to
2409b57
Compare
|
@codex review |
There was a problem hiding this comment.
Stale comment
PR Review — Score: 4.7 / 5
This is a well-motivated type-boundary refactor that correctly splits browser vs electron RUM schemas, threads the distinction through
ServerRumEventviasource, and removes the now-dead main-processactioncounter path. Tests and assembly call sites are updated consistently, and the change is compile-time safe without altering runtime intake behavior. I would approve.Why 4.7: Clear motivation tied to rum-events-format#437, disciplined file moves under
src/domain/rum/types/, discriminatedServerRumEventinevent.types.ts, targetedViewCollectioncleanup, and unit tests that now assert the main-process subset (error/resourceonly).Why not 5: Shared
FormatHooksstill types RUM assembly with the broadRumEventunion, which forces a cast inMainAssemblyand leaves hook callbacks process-agnostic.docs/DEVELOPMENT.mdstill documents the oldsrc/rumEvent.types.tspath.
Findings
- [Minor] Stale schema docs —
docs/DEVELOPMENT.mdstill references the removedsrc/rumEvent.types.tspath instead of the newsrc/domain/rum/types/layout.- [Minor] Hook pipeline still process-agnostic —
FormatHookscontinues to useRecursivePartial<RumEvent>, so main-process assembly needs an explicit cast rather than getting compile-time guarantees end-to-end.- [Nit] Renderer pipeline typing —
RendererPipelinestill casts bridge payloads to the broadRumEventunion;RendererRumEventwould complete the split on the renderer side.
Architectural flow
LoadingsequenceDiagram participant Raw as RawRumData participant MainAsm as MainAssembly participant Hooks as FormatHooks participant EM as EventManager participant Pipe as RendererPipeline participant VC as ViewCollection Raw->>MainAsm: main-process raw RUM MainAsm->>Hooks: triggerRum MAIN Hooks-->>MainAsm: hook overrides MainAsm->>EM: ServerMainRumEvent Pipe->>Hooks: triggerRum RENDERER Pipe->>EM: ServerRendererRumEvent EM->>VC: ServerRumEvent by source Note over VC: main only counts error and resourceBefore: A single
RumEventunion backed by the browser schema was used for both processes, so main-process code could type-check impossible event kinds (action,long_task).ServerRumEvent.datawas untyped with respect to origin.After: Browser and electron schemas generate
RendererRumEventandMainRumEvent;ServerRumEventis a discriminated union onsource, and main-only collection paths (e.g. view counters) narrow to the electron subset.Sent by Cursor Automation: electron-sdk reviews
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2409b5708f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
db22459 to
f881df5
Compare
There was a problem hiding this comment.
PR Review — Score: 4.9 / 5
This is a well-executed type-boundary refactor that splits browser vs electron RUM schemas, threads the distinction through ServerRumEvent via source, and removes the dead main-process action counter path. Follow-up commits since the first review addressed the documentation, static-analysis ignore list, renderer pipeline typing, and barrel-export rationale. Runtime intake behavior is unchanged and the compile-time guarantees are materially stronger. I would approve.
Why 4.9: Clear motivation tied to rum-events-format#437, disciplined relocation under src/domain/rum/types/, discriminated ServerRumEvent in event.types.ts, targeted ViewCollection cleanup, renderer pipeline now typed with RendererRumEvent, and prior Codex/automation feedback incorporated in the latest head.
Why not 5: FormatHooks.triggerRum still returns the broad RumEvent union (you noted this can wait for a follow-up), so MainAssembly keeps a narrow cast at the hook boundary. That is an intentional tradeoff, not a functional gap.
Architectural flow
sequenceDiagram
participant Raw as RawRumData
participant MainAsm as MainAssembly
participant Hooks as FormatHooks
participant EM as EventManager
participant Pipe as RendererPipeline
participant VC as ViewCollection
Raw->>MainAsm: main-process raw RUM
MainAsm->>Hooks: triggerRum MAIN
Hooks-->>MainAsm: hook overrides
MainAsm->>EM: ServerMainRumEvent
Pipe->>Hooks: triggerRum RENDERER
Pipe->>EM: ServerRendererRumEvent
EM->>VC: ServerRumEvent by source
Note over VC: main counts error and resource only
Before: A single browser-schema RumEvent union backed both processes, so main-process code could type-check impossible event kinds (action, long_task). ServerRumEvent.data was not tied to source.
After: Browser and electron schemas generate RendererRumEvent and MainRumEvent. ServerRumEvent is a discriminated union on source, and main-only collection paths narrow to the electron subset.
Sent by Cursor Automation: electron-sdk reviews
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f881df5c25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- Add rum-events-electron-schema.json entrypoint (error, resource, view, view_update, vital) as the source for main-process events, keeping the browser schema for renderer events - Move generated/raw RUM types under src/domain/rum/types/ as a self-contained package boundary (barrel-only imports enforced by no-internal-modules) - Make ServerRumEvent a discriminated union on source (RENDERER -> RendererRumEvent, MAIN -> MainRumEvent), closing a gap where main-process code could construct action/long_task events that never actually occur - Drop the now-impossible 'action' branch in ViewCollection's main-only counter path Submodule ref points to the not-yet-reviewed bcaudan/electron-schema-entrypoint branch; will be updated to master once that PR merges.
f881df5 to
44926eb
Compare


Motivation
This allows the Electron SDK to properly type events coming from the main process versus the renderer process, and to support future execution-context events that will be handled by the main process. Main-process code could previously construct RUM events of any type in the full
RumEventunion, includingaction/long_task, even though those never actually originate from the main process.This builds on rum-events-format#437 (merged), which introduces
schemas/rum-events-electron-schema.json: aRumEventunion schema mirroring the browser schema but limited to the event types the main process actually emit.Changes
RendererRumEvent(browser schema, unchanged) andMainRumEvent(new electron schema), and makeServerRumEventa discriminated union onsource.src/domain/rum/types/.actionbranch fromViewCollection's main-only counter path.Test instructions
action.countstill increments (renderer-origin action events are unaffected by the split).error.source_type: nodejs.action-typedServerRumEventand confirmyarn typechecknow rejects it.Checklist