Skip to content

Commit b539c14

Browse files
committed
Add Live Debugger package
Introduce the browser debugger SDK and probe execution pipeline so browser code can evaluate conditions, capture snapshots, and render probe messages at runtime. Add Delivery API polling plus sandbox and performance tooling to support probe delivery and testing.
1 parent abcbafe commit b539c14

63 files changed

Lines changed: 7744 additions & 34 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/skills/manual-testing/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cat > sandbox/test-<topic>.html << 'EOF'
2828
<title>Test <topic></title>
2929
<script src="/datadog-rum.js"></script>
3030
<script>
31-
DD_RUM.init({ clientToken: 'xxx', applicationId: 'xxx', proxy: '/proxy', trackUserInteractions: true })
31+
DD_RUM.init({ applicationId: 'xxx', clientToken: 'xxx', proxy: '/proxy', trackUserInteractions: true })
3232
</script>
3333
</head>
3434
<body>

eslint-local-rules/disallowSideEffects.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const pathsWithSideEffect = new Set([
2929
`${packagesRoot}/logs/src/entries/main.ts`,
3030
`${packagesRoot}/rum/src/entries/main.ts`,
3131
`${packagesRoot}/rum-slim/src/entries/main.ts`,
32+
`${packagesRoot}/debugger/src/entries/main.ts`,
3233
])
3334

3435
// Those packages are known to have no side effects when evaluated

packages/core/src/domain/configuration/configuration.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export interface InitConfiguration {
276276
*
277277
* @internal
278278
*/
279-
source?: 'browser' | 'flutter' | 'unity' | undefined
279+
source?: 'browser' | 'flutter' | 'unity' | 'dd_debugger' | undefined
280280

281281
/**
282282
* [Internal option] Additional configuration for the SDK.
@@ -311,6 +311,8 @@ export interface ReplicaUserConfiguration {
311311
clientToken: string
312312
}
313313

314+
export type SdkSource = 'browser' | 'flutter' | 'unity'
315+
314316
export interface Configuration extends TransportConfiguration {
315317
// Built from init configuration
316318
beforeSend: GenericBeforeSendCallback | undefined
@@ -331,10 +333,14 @@ export interface Configuration extends TransportConfiguration {
331333

332334
// internal
333335
sdkVersion: string | undefined
334-
source: 'browser' | 'flutter' | 'unity'
336+
source: SdkSource
335337
variant: string | undefined
336338
}
337339

340+
function toSdkSource(source: TransportConfiguration['source']): SdkSource {
341+
return source === 'dd_debugger' ? 'browser' : source
342+
}
343+
338344
function isString(tag: unknown, tagName: string): tag is string | undefined | null {
339345
if (tag !== undefined && tag !== null && typeof tag !== 'string') {
340346
display.error(`${tagName} must be defined as a string`)
@@ -398,6 +404,8 @@ export function validateAndBuildConfiguration(
398404
return
399405
}
400406

407+
const transportConfiguration = computeTransportConfiguration(initConfiguration)
408+
401409
return {
402410
beforeSend:
403411
initConfiguration.beforeSend && catchUserErrors(initConfiguration.beforeSend, 'beforeSend threw an error:'),
@@ -423,7 +431,8 @@ export function validateAndBuildConfiguration(
423431
variant: initConfiguration.variant,
424432
sdkVersion: initConfiguration.sdkVersion,
425433

426-
...computeTransportConfiguration(initConfiguration),
434+
...transportConfiguration,
435+
source: toSdkSource(transportConfiguration.source),
427436
}
428437
}
429438

packages/core/src/domain/configuration/endpointBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { InitConfiguration } from './configuration'
88
// replaced at build time
99
declare const __BUILD_ENV__SDK_VERSION__: string
1010

11-
export type TrackType = 'logs' | 'rum' | 'replay' | 'profile' | 'exposures' | 'flagevaluation'
11+
export type TrackType = 'logs' | 'rum' | 'replay' | 'profile' | 'exposures' | 'flagevaluation' | 'debugger'
1212
export type ApiType =
1313
| 'fetch'
1414
| 'beacon'

packages/core/src/domain/configuration/transportConfiguration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ describe('transportConfiguration', () => {
5555
const configuration = computeTransportConfiguration({
5656
clientToken,
5757
replica: {
58-
clientToken: 'replica-client-token',
5958
applicationId: replicaApplicationId,
59+
clientToken: 'replica-client-token',
6060
},
6161
})
6262
expect(configuration.replica!.rumEndpointBuilder.build('fetch', DEFAULT_PAYLOAD)).toContain(

packages/core/src/domain/configuration/transportConfiguration.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ export interface TransportConfiguration {
1111
profilingEndpointBuilder: EndpointBuilder
1212
exposuresEndpointBuilder: EndpointBuilder
1313
flagEvaluationEndpointBuilder: EndpointBuilder
14+
debuggerEndpointBuilder: EndpointBuilder
1415
datacenter?: string | undefined
1516
replica?: ReplicaConfiguration
1617
site: Site
17-
source: 'browser' | 'flutter' | 'unity'
18+
source: 'browser' | 'flutter' | 'unity' | 'dd_debugger'
1819
}
1920

2021
export interface ReplicaConfiguration {
@@ -38,7 +39,7 @@ export function computeTransportConfiguration(initConfiguration: InitConfigurati
3839
}
3940

4041
function validateSource(source: string | undefined) {
41-
if (source === 'flutter' || source === 'unity') {
42+
if (source === 'flutter' || source === 'unity' || source === 'dd_debugger') {
4243
return source
4344
}
4445
return 'browser'
@@ -52,6 +53,7 @@ function computeEndpointBuilders(initConfiguration: InitConfiguration) {
5253
sessionReplayEndpointBuilder: createEndpointBuilder(initConfiguration, 'replay'),
5354
exposuresEndpointBuilder: createEndpointBuilder(initConfiguration, 'exposures'),
5455
flagEvaluationEndpointBuilder: createEndpointBuilder(initConfiguration, 'flagevaluation'),
56+
debuggerEndpointBuilder: createEndpointBuilder(initConfiguration, 'debugger'),
5557
}
5658
}
5759

packages/core/src/domain/telemetry/telemetryEvent.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ export interface CommonTelemetryProperties {
585585
| 'kotlin-multiplatform'
586586
| 'electron'
587587
| 'rum-cpp'
588+
| 'dd_debugger'
588589
/**
589590
* The version of the SDK generating the telemetry event
590591
*/

packages/core/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export {
77
isSampleRate,
88
buildEndpointHost,
99
isIntakeUrl,
10+
computeTransportConfiguration,
1011
} from './domain/configuration'
1112
export * from './domain/intakeSites'
1213
export type { TrackingConsentState } from './domain/trackingConsent'
@@ -57,7 +58,7 @@ export {
5758
SESSION_NOT_TRACKED,
5859
SessionPersistence,
5960
} from './domain/session/sessionConstants'
60-
export type { BandwidthStats, HttpRequest, HttpRequestEvent, Payload, FlushEvent, FlushReason } from './transport'
61+
export type { Batch, BandwidthStats, HttpRequest, HttpRequestEvent, Payload, FlushEvent, FlushReason } from './transport'
6162
export {
6263
createHttpRequest,
6364
canUseEventBridge,

packages/core/src/transport/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type { BandwidthStats, HttpRequest, HttpRequestEvent, Payload, RetryInfo
22
export { createHttpRequest } from './httpRequest'
33
export type { BrowserWindowWithEventBridge, DatadogEventBridge } from './eventBridge'
44
export { canUseEventBridge, bridgeSupports, getEventBridge, BridgeCapability } from './eventBridge'
5+
export type { Batch } from './batch'
56
export { createBatch } from './batch'
67
export type { FlushController, FlushEvent, FlushReason } from './flushController'
78
export { createFlushController, FLUSH_DURATION_LIMIT } from './flushController'

packages/debugger/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Browser Live Debugger
2+
3+
Datadog Live Debugger enables you to capture function execution snapshots, evaluate conditions, and collect runtime data from your application without modifying source code.
4+
5+
See the [dedicated Datadog documentation][1] for more details.
6+
7+
## Usage
8+
9+
To start collecting data, add [`@datadog/browser-debugger`][2] to your `package.json` file, then initialize it with:
10+
11+
```js
12+
import { datadogDebugger } from '@datadog/browser-debugger'
13+
14+
datadogDebugger.init({
15+
applicationId: '<DATADOG_APPLICATION_ID>',
16+
clientToken: '<DATADOG_CLIENT_TOKEN>',
17+
site: '<DATADOG_SITE>',
18+
service: 'my-web-application',
19+
// env: 'production',
20+
// version: '1.0.0',
21+
})
22+
```
23+
24+
If [Datadog RUM][3] is also initialized on the page, debugger snapshots automatically include RUM context (session, view, user action) without any additional configuration.
25+
26+
## Troubleshooting
27+
28+
Need help? Contact [Datadog Support][4].
29+
30+
<!-- Note: all URLs should be absolute -->
31+
32+
[1]: https://docs.datadoghq.com/tracing/live_debugger/
33+
[2]: https://www.npmjs.com/package/@datadog/browser-debugger
34+
[3]: https://docs.datadoghq.com/real_user_monitoring/browser
35+
[4]: https://docs.datadoghq.com/help/

0 commit comments

Comments
 (0)