Skip to content

Commit 3eab106

Browse files
committed
✨ Add AI agent detection context with Tier 1 & Tier 2 signals
Detect AI agents and automation frameworks visiting instrumented pages. Tier 1 (zero false positives): cooperative window global, cooperative cookie, navigator.webdriver, user-agent pattern matching, and automation framework globals (Playwright, Puppeteer, Selenium). Tier 2 (low false positives): WebGL software renderer detection, headless environment heuristics, and CDP connection probing. Detection is gated behind the ai_agent_detection experimental feature flag. When an agent is detected, isAgentSession and aiAgentContext are added to the event context via the Assemble hook.
1 parent 930babc commit 3eab106

8 files changed

Lines changed: 783 additions & 0 deletions

File tree

packages/core/src/tools/experimentalFeatures.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export enum ExperimentalFeature {
1919
START_STOP_ACTION = 'start_stop_action',
2020
START_STOP_RESOURCE = 'start_stop_resource',
2121
TOO_MANY_REQUESTS_INVESTIGATION = 'too_many_requests_investigation',
22+
AI_AGENT_DETECTION = 'ai_agent_detection',
2223
SESSION_RENEWAL_DEBUG_CONTEXT = 'session_renewal_debug_context',
2324
}
2425

packages/rum-core/src/boot/startRum.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
startGlobalContext,
1818
startUserContext,
1919
startTabContext,
20+
isExperimentalFeatureEnabled,
21+
ExperimentalFeature,
2022
} from '@datadog/browser-core'
2123
import { createDOMMutationObservable } from '../browser/domMutationObservable'
2224
import { createWindowOpenObservable } from '../browser/windowOpenObservable'
@@ -39,6 +41,7 @@ import { startCustomerDataTelemetry } from '../domain/startCustomerDataTelemetry
3941
import { startPageStateHistory } from '../domain/contexts/pageStateHistory'
4042
import { startDisplayContext } from '../domain/contexts/displayContext'
4143
import { startVitalCollection } from '../domain/vital/vitalCollection'
44+
import { startAiAgentContext } from '../domain/contexts/aiAgentContext'
4245
import { startCiVisibilityContext } from '../domain/contexts/ciVisibilityContext'
4346
import { startLongTaskCollection } from '../domain/longTask/longTaskCollection'
4447
import { startSyntheticsContext } from '../domain/contexts/syntheticsContext'
@@ -186,6 +189,9 @@ export function startRumEventCollection(
186189

187190
const displayContext = startDisplayContext(hooks, configuration)
188191
cleanupTasks.push(displayContext.stop)
192+
if (isExperimentalFeatureEnabled(ExperimentalFeature.AI_AGENT_DETECTION)) {
193+
startAiAgentContext(hooks)
194+
}
189195
const ciVisibilityContext = startCiVisibilityContext(configuration, hooks)
190196
cleanupTasks.push(ciVisibilityContext.stop)
191197
startSyntheticsContext(hooks)

0 commit comments

Comments
 (0)