Repository navigation
feat(rum,js-core): Add the betaTrackAgentSignals option to collect agent signals on actions - #5372
Draft
avirmauxdd wants to merge 6 commits into
Draft
avirmauxdd wants to merge 6 commits into
avirmauxdd wants to merge 6 commits into
Conversation
Bundles Sizes Evolution
|
|
…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
force-pushed
the
aladin.virmaux/rum-agentic-detection
branch
from
December 4, 2026 13:09
f3aa4b9 to
c3c39c2
Compare
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
force-pushed
the
aladin.virmaux/rum-agentic-detection
branch
from
December 4, 2026 13:29
c3c39c2 to
b685b1b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(defaultfalse):Mouse click actions get
_dd.action.pointer(emitted forpointerType === '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 mousepointerdowntime_since_last_move_mscoalesced_max_count, clamped to 2down_jump_px: the distance between the last mouse move and thepointerdownAutomation 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_countkey_interval_ms { count, mean, cv }andkey_hold_ms { count, mean }, only when there are at least 5 samplessubmit_without_gesture_countscroll_without_gesture_count,scroll_max_step_px,route_change_without_gesture_count,route_change_time_since_gesture_msuntrusted_event_count: script-dispatched pointer, mouse, key, touch, click, input, submit and wheel events that the SDK already drops. Omitted whenallowUntrustedEventsis true.js-core: adds internal helpers so that
addEventListenercan count the untrusted events it drops. Counting is off unless RUM enables it.Commits (each builds and passes its tests on its own):
feat(js-core): DOM events and the opt-in untrusted event counterfeat(rum): thebetaTrackAgentSignalsinit optionfeat(rum): pointer signals on mouse click actionsfeat(rum): keyboard, input and untrusted event signalsfeat(rum): form submit, scroll and route change signalstest(rum): e2e scenarioPrivacy & accessibility model
main.mask,hidden,ignoreandmask-unless-allowlistedprivacy 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.pointerdownclicks (pointerType === 'mouse'). Touch, pen, and keyboard-activated clicks (detail === 0clicks do not emitpointerdown, andpointerdown.detailis always0per W3C Pointer Events) are excluded, and non-mousepointerdownevents do not reset accumulated mouse move samples.input_without_keydown_countis restricted to text-entry controls (<textarea>,contenteditable, andtext/search/url<input>) using a 250 ms window after the last keydown.Bundle size
mainrumrum-slimWhen 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
_dd.action.pointerand_dd.action.signalsfields are not inrum-events-formatyet. They are hand-typed inrawRumEvent.types.ts. The option is not reported in configuration telemetry yet. This PR needs arum-events-formatchange, including the telemetry field, before it leaves beta and before field names are final.mask-user-inputfields: 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.history.back()counts as a navigation gesture.autofill_countalso includes spell-check replacements (insertReplacementText).initial_loadviews) and are not automation evidence._ddfields are not editable inbeforeSend, so the flag is the only control.Test instructions
test/e2e/scenario/rum/agentSignals.scenario.tschecks the payload in Chromium, Firefox, and WebKit:betaTrackAgentSignals: trueandallowUntrustedEvents: false. Then interact with a page, and drive it with Playwrightpage.click()without a mouse move. Compare_dd.action.pointerand_dd.action.signalson the action events.Checklist