Skip to content

Commit 4a453f7

Browse files
committed
Move live debugger code to proper package
1 parent 5d2c4af commit 4a453f7

31 files changed

+5198
-929
lines changed

packages/live-debugger/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Live Debugger Browser Monitoring
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+
## Usage
6+
7+
To start using the live debugger, add [`@datadog/browser-live-debugger`](https://www.npmjs.com/package/@datadog/browser-live-debugger) to your `package.json` file, then initialize it with:
8+
9+
```javascript
10+
import { datadogLiveDebugger } from '@datadog/browser-live-debugger'
11+
12+
datadogLiveDebugger.init({
13+
clientToken: '<DATADOG_CLIENT_TOKEN>',
14+
site: '<DATADOG_SITE>',
15+
service: 'my-web-application',
16+
env: 'production',
17+
version: '1.0.0',
18+
})
19+
20+
// Add probes programmatically
21+
datadogLiveDebugger.addProbe({
22+
id: 'probe-1',
23+
version: 0,
24+
type: 'LOG_PROBE',
25+
where: { typeName: 'MyClass', methodName: 'myMethod' },
26+
template: 'Method executed with duration: {@duration}ms',
27+
segments: [
28+
{ str: 'Method executed with duration: ' },
29+
{ dsl: '@duration', json: { ref: '@duration' } },
30+
{ str: 'ms' },
31+
],
32+
captureSnapshot: true,
33+
capture: { maxReferenceDepth: 3 },
34+
sampling: { snapshotsPerSecond: 5000 },
35+
evaluateAt: 'EXIT',
36+
})
37+
```
38+
39+
**Note**: Dynamic probe management from remote configuration will be added in a future release.
40+
41+
## Integration with RUM
42+
43+
The Live Debugger integrates seamlessly with Datadog RUM to provide enhanced context and correlation:
44+
45+
```javascript
46+
import { datadogRum } from '@datadog/browser-rum'
47+
import { datadogLiveDebugger } from '@datadog/browser-live-debugger'
48+
49+
// Initialize RUM first
50+
datadogRum.init({
51+
applicationId: '<DATADOG_APPLICATION_ID>',
52+
clientToken: '<DATADOG_CLIENT_TOKEN>',
53+
site: '<DATADOG_SITE>',
54+
service: 'my-web-application',
55+
env: 'production',
56+
})
57+
58+
// Then initialize Live Debugger
59+
datadogLiveDebugger.init({
60+
clientToken: '<DATADOG_CLIENT_TOKEN>',
61+
site: '<DATADOG_SITE>',
62+
service: 'my-web-application',
63+
env: 'production',
64+
})
65+
66+
// Add your probe configurations
67+
// datadogLiveDebugger.addProbe({ ... })
68+
```
69+
70+
When both are initialized, debugger snapshots will automatically include RUM context (session, view, user action).
71+
72+
## Features
73+
74+
- **Dynamic Instrumentation**: Capture function entry/exit without code changes
75+
- **Conditional Breakpoints**: Evaluate conditions before capturing snapshots
76+
- **Template Expressions**: Evaluate custom messages with runtime context
77+
- **Rate Limiting**: Built-in sampling to prevent performance impact
78+
- **Stack Traces**: Automatic stack trace capture for debugging
79+
- **Variable Capture**: Deep capture of arguments, locals, and return values
80+
81+
<!-- Note: all URLs should be absolute -->
82+
83+
[1]: https://docs.datadoghq.com/dynamic_instrumentation/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@datadog/browser-live-debugger",
3+
"version": "6.24.1",
4+
"license": "Apache-2.0",
5+
"main": "cjs/entries/main.js",
6+
"module": "esm/entries/main.js",
7+
"types": "cjs/entries/main.d.ts",
8+
"scripts": {
9+
"build": "node ../../scripts/build/build-package.ts --modules --bundle datadog-live-debugger.js",
10+
"build:bundle": "node ../../scripts/build/build-package.ts --bundle datadog-live-debugger.js"
11+
},
12+
"dependencies": {
13+
"@datadog/browser-core": "6.24.1"
14+
},
15+
"peerDependencies": {
16+
"@datadog/browser-rum": "6.24.1"
17+
},
18+
"peerDependenciesMeta": {
19+
"@datadog/browser-rum": {
20+
"optional": true
21+
}
22+
},
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/DataDog/browser-sdk.git",
26+
"directory": "packages/live-debugger"
27+
},
28+
"volta": {
29+
"extends": "../../package.json"
30+
},
31+
"publishConfig": {
32+
"access": "public"
33+
}
34+
}

0 commit comments

Comments
 (0)