✨ track custom actions from the main process with addAction#167
✨ track custom actions from the main process with addAction#167rgaignault wants to merge 6 commits into
Conversation
Add addAction(name, context?) on the main-process side, emitting a custom RUM action attached to the current view. The renderer already gets custom actions from the Browser SDK; this covers actions that never touch the DOM (native menus, auto-update, background workflows). Action names are free text (no validation) and custom actions carry no frustration/loading_time/counts, matching the Browser, iOS and Android SDKs. Covered by unit tests and an e2e scenario.
|
@codex review |
There was a problem hiding this comment.
Stale comment
PR Review — Score: 4.4 / 5
This is a well-scoped feature that mirrors existing main-process collection patterns (
ErrorCollection,OperationCollection) and wires cleanly throughRumCollection→MainAssembly→ intake, with thorough unit coverage and a focused e2e scenario. I would approve once customer-facing docs are added; there are no blocking correctness or concurrency concerns in the implementation.Why 4.4: The core pipeline is simple, synchronous, and consistent with SDK conventions (
callMonitored,EventManagerRAW events, assembly hooks,ViewCollectioncounter updates). Tests exercise payload shape, parity choices (free-text names, no frustration/loading_time), and end-to-end intake delivery with full RUM context.Why not 5: The public
addActionAPI is not yet documented inREADME.md(the PR checklist still has docs unchecked), and the e2e scenario has a small inconsistency with the error scenario's context assertion style.Note:
dd-gitlab/e2eanddd-gitlab/integrationwere still pending when this review was posted; other GitLab jobs had completed.
Findings
- [Minor] Missing README docs —
addActionis exported but not documented in the customer-facing API section alongsideaddError.- [Nit] Redundant e2e type cast —
RumActionEventalready includescontextviaCommonProperties; the extra cast is unnecessary.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: dbcc4ed6b8
ℹ️ 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 the addAction API section to the README and an @example to its JSDoc (required for new public APIs), and drop a redundant context cast in the action e2e scenario. Addresses PR review feedback.
|
@codex review |
There was a problem hiding this comment.
Stale comment
PR Review — Score: 4.9 / 5
This is a clean, well-tested addition that mirrors existing main-process collection patterns and is ready to merge. The follow-up commit addressed all prior review feedback (README section, JSDoc
@example, simplified e2e context assertion). I would approve.Why 4.9:
ActionCollectionis a straightforward synchronous RAW-event emitter consistent withErrorCollection; wiring throughRumCollection→MainAssembly→ intake is correct, andViewCollectionalready incrementsview.action.countfor main-process SERVERactionevents. Unit tests cover payload shape, SDK parity choices (free-text names, no frustration/loading_time), and lifecycle; the e2e scenario validates intake delivery with full RUM context.Why not 5: Playground validation remains unchecked in the PR checklist — the only remaining process item, not a code concern.
Note: All
dd-gitlab/*jobs were still pending when this review was posted.
Architectural flow
LoadingsequenceDiagram participant App as Main process app participant API as addAction (public API) participant AC as ActionCollection participant EM as EventManager participant MA as MainAssembly participant VC as ViewCollection participant Intake as RUM intake App->>API: addAction(name, context?) API->>AC: callMonitored → emitAction AC->>EM: RAW RUM action event EM->>MA: assemble with session/view context MA->>EM: SERVER RUM action (MAIN) EM->>VC: increment view.action.count (throttled update) EM->>Intake: transport assembled action eventBefore: Custom RUM actions were only available in the renderer via the Browser SDK; main-process events (menus, tray, auto-update, background work) had no
addActionequivalent.After:
addAction(name, context?)on the main process emits acustomaction RAW event that flows through the existing assembly pipeline, attaches to the current main-process view, increments view counters, and reaches intake — matching Browser/iOS/Android semantics for action names and payload shape.Sent by Cursor Automation: electron-sdk reviews
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Reduce the ActionCollection class doc to a one-line description, drop the parity/no-tracking preamble comments in the spec (the describe titles cover it), and remove the use-case prose from the addAction JSDoc.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3b53bac4c
ℹ️ 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".
There was a problem hiding this comment.
PR Review — Score: 4.9 / 5
This is a clean, well-tested addition that mirrors existing main-process collection patterns and is ready to merge. All prior review feedback (README section, JSDoc @example, simplified e2e context assertion) remains addressed on the latest head; the follow-up comment-trim commit is cosmetic only. I would approve.
Why 4.9: ActionCollection is a straightforward synchronous RAW-event emitter consistent with ErrorCollection; wiring through RumCollection → MainAssembly → intake is correct, and ViewCollection already increments view.action.count for main-process SERVER action events. Unit tests cover payload shape, SDK parity choices (free-text names, no frustration/loading_time), and lifecycle; the e2e scenario validates intake delivery with full RUM context.
Why not 5: Playground validation remains unchecked in the PR checklist — the only remaining process item, not a code concern.
Architectural flow
sequenceDiagram
participant App as Main process app
participant API as addAction (public API)
participant AC as ActionCollection
participant EM as EventManager
participant MA as MainAssembly
participant VC as ViewCollection
participant Intake as RUM intake
App->>API: addAction(name, context?)
API->>AC: callMonitored → emitAction
AC->>EM: RAW RUM action event
EM->>MA: assemble with session/view context
MA->>EM: SERVER RUM action (MAIN)
EM->>VC: increment view.action.count (throttled update)
EM->>Intake: transport assembled action event
Before: Custom RUM actions were only available in the renderer via the Browser SDK; main-process events (menus, tray, auto-update, background work) had no addAction equivalent.
After: addAction(name, context?) on the main process emits a custom action RAW event that flows through the existing assembly pipeline, attaches to the current main-process view, increments view counters, and reaches intake — matching Browser/iOS/Android semantics for action names and payload shape.
Sent by Cursor Automation: electron-sdk reviews
Emit END_USER_ACTIVITY before the action event so a main-process addAction after inactivity revives an expired session and is recorded on the new one instead of being dropped. Matches iOS and Android, which treat a manual action (custom included) as user activity that renews the session. Covered by a unit test and an e2e scenario (expire, addAction, assert new session).
Add a "Custom Actions" section that calls addAction over IPC, and a native Datadog menu whose handlers run addAction / stopSession directly in the main process — so a custom action can be triggered without any renderer interaction.


Motivation
The renderer already gets custom actions from the bundled Browser SDK, but the main process had no equivalent. This adds
addActionon the main-process side so customers can record custom actions that never touch the DOM, native menu/tray clicks, auto-update steps, background workflows.Changes
ActionCollection,addAction(name, context?)emits acustomRUM action attached to the current main-process view. Wired intoRumCollectionand exported from the public entry, with aRawRumActionraw type and theRumActionEventtype export.attributes), not wrapped in an options object.ViewCollectionalready incrementsview.action.count.Test instructions
yarn test:unit,ActionCollectionspecs cover payload shape, context defaults, unique ids, free-text names, and no-local-tracking.yarn test:e2e --project=e2e action.scenario, asserts acustomaction reaches the intake with the given name/context and full RUM context (session, view, application,source: electron).Checklist