Skip to content

feat(rum,js-core): Add the betaTrackAgentSignals option to collect agent signals on actions - #5372

Draft
avirmauxdd wants to merge 6 commits into
mainfrom
aladin.virmaux/rum-agentic-detection
Draft

avirmauxdd wants to merge 6 commits into
mainfrom
aladin.virmaux/rum-agentic-detection

Conversation

@avirmauxdd

@avirmauxdd avirmauxdd commented Dec 3, 2026 •

Copy link
Copy Markdown

Motivation

More and more sessions are driven by automation and AI agents (headless browsers, CDP/WebDriver tools, agentic browsers), and today RUM cannot tell them apart from human sessions. They skew user analytics, and customers want to identify them.

This PR adds an opt-in, beta init option, betaTrackAgentSignals, that collects a small set of aggregated interaction signals on actions. Classification is not done in the SDK: these signals let downstream analytics tell automated traffic apart from human traffic later.

Changes

With betaTrackAgentSignals: true (default false):

  • Mouse click actions get _dd.action.pointer (emitted for pointerType === 'mouse' only; touch, pen, and keyboard-activated clicks omit it):

    • pointer_type: 'mouse'
    • move_sample_count: mouse moves sampled every 50 ms since the previous primary mouse pointerdown
    • time_since_last_move_ms
    • coalesced_max_count, clamped to 2
    • down_jump_px: the distance between the last mouse move and the pointerdown

    Automation often clicks without moving the pointer, or teleports it.

  • Every action gets _dd.action.signals, counted since the previous sent action:

    • keydown_count, input_count, input_without_keydown_count (text-entry controls only, 250 ms keydown window), paste_count, autofill_count
    • key_interval_ms { count, mean, cv } and key_hold_ms { count, mean }, only when there are at least 5 samples
    • submit_without_gesture_count
    • Supplementary interaction context (not standalone automation evidence): scroll_without_gesture_count, scroll_max_step_px, route_change_without_gesture_count, route_change_time_since_gesture_ms
    • untrusted_event_count: script-dispatched pointer, mouse, key, touch, click, input, submit and wheel events that the SDK already drops. Omitted when allowUntrustedEvents is true.
  • js-core: adds internal helpers so that addEventListener can count the untrusted events it drops. Counting is off unless RUM enables it.

Commits (each builds and passes its tests on its own):

  1. feat(js-core): DOM events and the opt-in untrusted event counter
  2. feat(rum): the betaTrackAgentSignals init option
  3. feat(rum): pointer signals on mouse click actions
  4. feat(rum): keyboard, input and untrusted event signals
  5. feat(rum): form submit, scroll and route change signals
  6. test(rum): e2e scenario

Privacy & accessibility model

  • Off by default. When off, no listener is added and no field is sent. The behaviour is the same as main.
  • Only counts, durations and distances are collected. Key values, text, coordinates and element content are never collected.
  • Fields at the mask, hidden, ignore and mask-unless-allowlisted privacy levels are skipped. So are elements that may hide a field, such as closed shadow root hosts. Typing intervals that cross a masked field are reset.
  • Key timing statistics are only sent from 5 samples upwards, so short sequences such as one-time codes do not expose single timings.
  • Pointer signals are emitted only on mouse pointerdown clicks (pointerType === 'mouse'). Touch, pen, and keyboard-activated clicks (detail === 0 clicks do not emit pointerdown, and pointerdown.detail is always 0 per W3C Pointer Events) are excluded, and non-mouse pointerdown events do not reset accumulated mouse move samples.
  • input_without_keydown_count is restricted to text-entry controls (<textarea>, contenteditable, and text/search/url <input>) using a 250 ms window after the last keydown.
  • Document scroll metrics and full-page navigations are supplementary context and are never treated as standalone automation evidence (programmatic or browser-restored scrolls and full-page navigations are normal in human sessions, and initial loads are excluded from route-change tracking).

Bundle size

bundle gzip Δ vs main
rum +1.87 KB (+2.7%)
rum-slim +1.82 KB (+3.5%)

When the flag is off, the runtime cost is negligible, but the code still ships in the bundle. A follow-up could lazy-load it as a chunk, as the recorder does. That would lose the signals of the first action.

Open questions / not settled

  • Schema: the new _dd.action.pointer and _dd.action.signals fields are not in rum-events-format yet. They are hand-typed in rawRumEvent.types.ts. The option is not reported in configuration telemetry yet. This PR needs a rum-events-format change, including the telemetry field, before it leaves beta and before field names are final.
  • Key timing in mask-user-input fields: with the default privacy level, typing rhythm aggregates are still collected from ordinary text fields, with the minimum sample threshold. This needs a privacy review. The alternative is to skip every field that session replay masks, which removes most of the keyboard signal.
  • Known limits:
    • Script-driven history.back() counts as a navigation gesture.
    • autofill_count also includes spell-check replacements (insertReplacementText).
    • Full-page navigations by URL are not route changes (they appear as initial_load views) and are not automation evidence.
  • _dd fields are not editable in beforeSend, so the flag is the only control.

Test instructions

  • Unit tests cover each signal, the privacy and accessibility guards (masked levels, open and closed shadow roots, stale key state, non-mouse pointers, non-text controls, 250 ms input window), the flag-off path and cleanup on stop.
  • test/e2e/scenario/rum/agentSignals.scenario.ts checks the payload in Chromium, Firefox, and WebKit:
    • With the flag on, trusted mouse and keyboard input plus a script-dispatched click produce the expected signals.
    • With the flag off, nothing is sent.
  • To try it manually: init RUM with betaTrackAgentSignals: true and allowUntrustedEvents: false. Then interact with a page, and drive it with Playwright page.click() without a mouse move. Compare _dd.action.pointer and _dd.action.signals on the action events.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 195.72 KiB 200.76 KiB +5.04 KiB +2.58% ✅
Rum 195.70 KiB 200.74 KiB +5.04 KiB +2.58% ✅
Rum Salesforce Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Profiler 7.93 KiB 7.93 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Rum Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Logs 60.24 KiB 60.41 KiB +175 B +0.28% ✅
Rum Slim 151.09 KiB 156.00 KiB +4.90 KiB +3.24% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 227.25 KiB 232.28 KiB +5.04 KiB +2.22% ✅
Rum Shopify Profiler 7.93 KiB 7.93 KiB -1 B -0.01% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅
Early Collection 309 B 309 B 0 B 0.00% ✅

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Tests  Pipelines

⚠️ Warnings

Your PR has warnings. Please review the issues below.

❄️ 6 New flaky tests detected

agentSignalsCollection > inputs > counts a fill after a select-all shortcut as an input without keydown from packages/browser-rum-core/src/domain/agentSignals/agentSignalsCollection.spec.ts
The string did not match the expected pattern.

SyntaxError: The string did not match the expected pattern.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 12, INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2, HIERARCHY_REQUEST_ERR: 3, WRONG_DOCUMENT_ERR: 4, INVALID_CHARACTER_ERR: 5, NO_DATA_ALLOWED_ERR: 6, NO_MODIFICATION_ALLOWED_ERR: 7, NOT_FOUND_ERR: 8, NOT_SUPPORTED_ERR: 9, INUSE_ATTRIBUTE_ERR: 10, INVALID_STATE_ERR: 11, SYNTAX_ERR: 12, INVALID_MODIFICATION_ERR: 13, NAMESPACE_ERR: 14, INVALID_ACCESS_ERR: 15, VALIDATION_ERR: 16, TYPE_MISMATCH_ERR: 17, SECURITY_ERR: 18, NETWORK_ERR: 19, ABORT_ERR: 20, URL_MISMATCH_ERR: 21, QUOTA_EXCEEDED_ERR: 22, TIMEOUT_ERR: 23, INVALID_NODE_TYPE_ERR: 24, DATA_CLONE_ERR: 25 }
agentSignalsCollection > inputs > counts inputs on textareas and contenteditable elements from packages/browser-rum-core/src/domain/agentSignals/agentSignalsCollection.spec.ts
The string did not match the expected pattern.

SyntaxError: The string did not match the expected pattern.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 12, INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2, HIERARCHY_REQUEST_ERR: 3, WRONG_DOCUMENT_ERR: 4, INVALID_CHARACTER_ERR: 5, NO_DATA_ALLOWED_ERR: 6, NO_MODIFICATION_ALLOWED_ERR: 7, NOT_FOUND_ERR: 8, NOT_SUPPORTED_ERR: 9, INUSE_ATTRIBUTE_ERR: 10, INVALID_STATE_ERR: 11, SYNTAX_ERR: 12, INVALID_MODIFICATION_ERR: 13, NAMESPACE_ERR: 14, INVALID_ACCESS_ERR: 15, VALIDATION_ERR: 16, TYPE_MISMATCH_ERR: 17, SECURITY_ERR: 18, NETWORK_ERR: 19, ABORT_ERR: 20, URL_MISMATCH_ERR: 21, QUOTA_EXCEEDED_ERR: 22, TIMEOUT_ERR: 23, INVALID_NODE_TYPE_ERR: 24, DATA_CLONE_ERR: 25 }

View in Flaky Test Management

ℹ️ Info

No other issues found (see more)

🧪 All tests passed

🎯 Code Coverage (details)
• Patch Coverage: 75.98%
• Overall Coverage: 78.03% (-0.08%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: b685b1b | Docs | View more details | Give us feedback!

…d event counter

Agent signal collection listens to keyup, pointermove, submit and wheel events, and counts the
untrusted events that addEventListener ignores: script-dispatched device events are a strong
automation signal that listeners never see.

Only device and input events (pointer, mouse, key, touch, click, input, submit and wheel) are
counted: other events, such as resize or focus, are often dispatched by scripts on pages used by
humans. Counting is disabled by default (setTrackDroppedUntrustedEvents), so the drop branch does
no extra work for SDKs that do not read the counter. areUntrustedEventsAllowed tells consumers
when no event is dropped at all, so that a zero count is not misread.

The new functions are internal: the Browser SDK is their only consumer.
Gates the collection of aggregated interaction signals that help tell automated (agentic)
traffic apart from human traffic. It is a beta option, disabled by default, since the event
fields are not part of the RUM event schema yet. It is not reported in configuration telemetry
because the telemetry schema has no field for it yet.
With betaTrackAgentSignals, click actions get _dd.action.pointer: the pointer type and, for mice,
the moves sampled every 50 ms since the previous pointerdown, the time since the last move,
whether moves came batched (largest coalesced event count, clamped to 2) and the jump between
the last move and the pointerdown. Automation tools often click without moving the pointer, or
teleport it, while humans move it before clicking. No coordinates are kept.
@avirmauxdd
avirmauxdd force-pushed the aladin.virmaux/rum-agentic-detection branch from f3aa4b9 to c3c39c2 Compare December 4, 2026 13:09
With betaTrackAgentSignals, every action gets _dd.action.signals: the keydowns, text inputs,
pastes, autofills, text insertions without a recent keydown and untrusted device and input events
dropped since the previous sent action, plus key interval and hold time statistics. Agents fill
fields without typing, or type with machine-regular timings.

Only counts and durations are kept, never keys or text. Key timing statistics are only reported
with at least 5 samples, with their count. Fields under the mask, hidden, ignore or
mask-unless-allowlisted privacy levels are left out so their length and typing rhythm do not leak,
and so are elements that may hide one, such as closed shadow root hosts. Signals are reset once
an action is sent, so a discarded action does not lose them. Signals are not added to view events
because intake drops their unknown _dd fields.
Add gesture-attribution interaction context to actions: count form submits and document scrolls
occurring without a recent pointer, key, wheel or touch gesture, report the largest document
scroll step, and count and time SPA route changes relative to the last gesture. Scroll and
route-change signals provide supplementary interaction context alongside other signals rather
than standalone automation evidence, since programmatic or restored scrolls and full-page
navigations are normal in human sessions.

The end of a press (pointerup, keyup, trusted click) counts as a gesture too, since clicks on
links and buttons scroll and submit after it. Back/forward navigations only count as gestures
for route changes, and the collection starts before the location change observable so that they
are known before the route change view is created, whatever the listener order.

ViewCreatedEvent now carries the view loading type, so SPA route changes can be told apart from
initial loads.
Checks in a real browser that trusted pointer and keyboard input and script-dispatched events
are reported on actions with betaTrackAgentSignals, and that nothing is reported without it.
@avirmauxdd
avirmauxdd force-pushed the aladin.virmaux/rum-agentic-detection branch from c3c39c2 to b685b1b Compare December 4, 2026 13: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