Skip to content

✨ track custom actions from the main process with addAction#167

Draft
rgaignault wants to merge 6 commits into
mainfrom
roman.gaignault/RUM-15527/track-actions-manually
Draft

✨ track custom actions from the main process with addAction#167
rgaignault wants to merge 6 commits into
mainfrom
roman.gaignault/RUM-15527/track-actions-manually

Conversation

@rgaignault

@rgaignault rgaignault commented Jul 7, 2026

Copy link
Copy Markdown

Motivation

The renderer already gets custom actions from the bundled Browser SDK, but the main process had no equivalent. This adds addAction on 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

  • Add ActionCollection , addAction(name, context?) emits a custom RUM action attached to the current main-process view. Wired into RumCollection and exported from the public entry, with a RawRumAction raw type and the RumActionEvent type export.
  • Context passed directly (like the Browser SDK and mobile attributes), not wrapped in an options object.
  • Events flow through the existing main-process assembly hooks; ViewCollection already increments view.action.count.

Test instructions

  1. yarn test:unit, ActionCollection specs cover payload shape, context defaults, unique ids, free-text names, and no-local-tracking.
  2. yarn test:e2e --project=e2e action.scenario , asserts a custom action reaches the intake with the given name/context and full RUM context (session, view, application, source: electron).

Checklist

  • Tested locally (playground)
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated related documentation.
  • Agentic code review findings addressed or explicitly dismissed.

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.
@rgaignault

Copy link
Copy Markdown
Author

@codex review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 through RumCollectionMainAssembly → 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, EventManager RAW events, assembly hooks, ViewCollection counter 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 addAction API is not yet documented in README.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/e2e and dd-gitlab/integration were still pending when this review was posted; other GitLab jobs had completed.


Findings

  • [Minor] Missing README docsaddAction is exported but not documented in the customer-facing API section alongside addError.
  • [Nit] Redundant e2e type castRumActionEvent already includes context via CommonProperties; the extra cast is unnecessary.
Open in Web View Automation 

Sent by Cursor Automation: electron-sdk reviews

Comment thread src/index.ts
Comment thread e2e/scenarios/action.scenario.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/index.ts
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.
@rgaignault

Copy link
Copy Markdown
Author

@codex review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: ActionCollection is a straightforward synchronous RAW-event emitter consistent with ErrorCollection; wiring through RumCollectionMainAssembly → 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.

Note: All dd-gitlab/* jobs were still pending when this review was posted.


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
Loading

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.

Open in Web View Automation 

Sent by Cursor Automation: electron-sdk reviews

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: dad057b19b

ℹ️ 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".

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.
@rgaignault

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/domain/rum/action/ActionCollection.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 RumCollectionMainAssembly → 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
Loading

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.

Open in Web View Automation 

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.
@rgaignault rgaignault marked this pull request as ready for review July 8, 2026 07:22
@rgaignault rgaignault requested a review from a team as a code owner July 8, 2026 07:22
@rgaignault rgaignault marked this pull request as draft July 8, 2026 11:58
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