Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint-local-rules/disallowSideEffects.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const pathsWithSideEffect = new Set([
`${packagesRoot}/logs/src/entries/main.ts`,
`${packagesRoot}/rum/src/entries/main.ts`,
`${packagesRoot}/rum-slim/src/entries/main.ts`,
`${packagesRoot}/debugger/src/entries/main.ts`,
])

// Those packages are known to have no side effects when evaluated
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/domain/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export interface InitConfiguration {
*
* @internal
*/
source?: 'browser' | 'flutter' | 'unity' | undefined
source?: 'browser' | 'flutter' | 'unity' | 'dd_debugger' | undefined

/**
* [Internal option] Additional configuration for the SDK.
Expand Down Expand Up @@ -331,7 +331,7 @@ export interface Configuration extends TransportConfiguration {

// internal
sdkVersion: string | undefined
source: 'browser' | 'flutter' | 'unity'
source: 'browser' | 'flutter' | 'unity' | 'dd_debugger'
variant: string | undefined
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface TransportConfiguration {
datacenter?: string | undefined
replica?: ReplicaConfiguration
site: Site
source: 'browser' | 'flutter' | 'unity'
source: 'browser' | 'flutter' | 'unity' | 'dd_debugger'
}

export interface ReplicaConfiguration {
Expand All @@ -38,7 +38,7 @@ export function computeTransportConfiguration(initConfiguration: InitConfigurati
}

function validateSource(source: string | undefined) {
if (source === 'flutter' || source === 'unity') {
if (source === 'flutter' || source === 'unity' || source === 'dd_debugger') {
return source
}
return 'browser'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ export interface CommonTelemetryProperties {
| 'kotlin-multiplatform'
| 'electron'
| 'rum-cpp'
| 'dd_debugger'
/**
* The version of the SDK generating the telemetry event
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export {
isSampleRate,
buildEndpointHost,
isIntakeUrl,
computeTransportConfiguration,
} from './domain/configuration'
export * from './domain/intakeSites'
export type { TrackingConsentState } from './domain/trackingConsent'
Expand Down Expand Up @@ -57,7 +58,7 @@ export {
SESSION_NOT_TRACKED,
SessionPersistence,
} from './domain/session/sessionConstants'
export type { BandwidthStats, HttpRequest, HttpRequestEvent, Payload, FlushEvent, FlushReason } from './transport'
export type { Batch, BandwidthStats, HttpRequest, HttpRequestEvent, Payload, FlushEvent, FlushReason } from './transport'
export {
createHttpRequest,
canUseEventBridge,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type { BandwidthStats, HttpRequest, HttpRequestEvent, Payload, RetryInfo
export { createHttpRequest } from './httpRequest'
export type { BrowserWindowWithEventBridge, DatadogEventBridge } from './eventBridge'
export { canUseEventBridge, bridgeSupports, getEventBridge, BridgeCapability } from './eventBridge'
export type { Batch } from './batch'
export { createBatch } from './batch'
export type { FlushController, FlushEvent, FlushReason } from './flushController'
export { createFlushController, FLUSH_DURATION_LIMIT } from './flushController'
88 changes: 88 additions & 0 deletions packages/debugger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Live Debugger Browser Monitoring

Datadog Live Debugger enables you to capture function execution snapshots, evaluate conditions, and collect runtime data from your application without modifying source code.

## Usage

To start using the live debugger, add [`@datadog/browser-debugger`](https://www.npmjs.com/package/@datadog/browser-debugger) to your `package.json` file, then initialize it with:

```javascript
import { datadogLiveDebugger } from '@datadog/browser-debugger'

datadogLiveDebugger.init({
clientToken: '<DATADOG_CLIENT_TOKEN>',
applicationId: '<DATADOG_APPLICATION_ID>',
service: 'my-web-application',
site: '<DATADOG_SITE>',
env: 'production',
version: '1.0.0',
})
```

The debugger automatically polls for probe updates from the Delivery API.

You can also add probes programmatically:

```javascript
datadogLiveDebugger.addProbe({
id: 'probe-1',
version: 0,
type: 'LOG_PROBE',
where: { typeName: 'MyClass', methodName: 'myMethod' },
template: 'Method executed with duration: {@duration}ms',
segments: [
{ str: 'Method executed with duration: ' },
{ dsl: '@duration', json: { ref: '@duration' } },
{ str: 'ms' },
],
captureSnapshot: true,
capture: { maxReferenceDepth: 3 },
sampling: { snapshotsPerSecond: 5000 },
evaluateAt: 'EXIT',
})
```

## Integration with RUM

The Live Debugger integrates seamlessly with Datadog RUM to provide enhanced context and correlation:

```javascript
import { datadogRum } from '@datadog/browser-rum'
import { datadogLiveDebugger } from '@datadog/browser-debugger'

// Initialize RUM first
datadogRum.init({
applicationId: '<DATADOG_APPLICATION_ID>',
clientToken: '<DATADOG_CLIENT_TOKEN>',
site: '<DATADOG_SITE>',
service: 'my-web-application',
env: 'production',
})

// Then initialize Live Debugger
datadogLiveDebugger.init({
clientToken: '<DATADOG_CLIENT_TOKEN>',
applicationId: '<DATADOG_APPLICATION_ID>',
service: 'my-web-application',
site: '<DATADOG_SITE>',
env: 'production',
})

// Add your probe configurations
// datadogLiveDebugger.addProbe({ ... })
```

When both are initialized, debugger snapshots will automatically include RUM context (session, view, user action).

## Features

- **Dynamic Instrumentation**: Capture function entry/exit without code changes
- **Conditional Breakpoints**: Evaluate conditions before capturing snapshots
- **Template Expressions**: Evaluate custom messages with runtime context
- **Rate Limiting**: Built-in sampling to prevent performance impact
- **Stack Traces**: Automatic stack trace capture for debugging
- **Variable Capture**: Deep capture of arguments, locals, and return values

<!-- Note: all URLs should be absolute -->

[1]: https://docs.datadoghq.com/dynamic_instrumentation/
26 changes: 26 additions & 0 deletions packages/debugger/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@datadog/browser-debugger",
"version": "6.30.1",
"license": "Apache-2.0",
"main": "cjs/entries/main.js",
"module": "esm/entries/main.js",
"types": "cjs/entries/main.d.ts",
"scripts": {
"build": "node ../../scripts/build/build-package.ts --modules --bundle datadog-debugger.js",
"build:bundle": "node ../../scripts/build/build-package.ts --bundle datadog-debugger.js"
},
"dependencies": {
"@datadog/browser-core": "6.30.1"
},
"repository": {
"type": "git",
"url": "https://github.com/DataDog/browser-sdk.git",
"directory": "packages/debugger"
},
"volta": {
"extends": "../../package.json"
},
"publishConfig": {
"access": "public"
}
}
Loading
Loading