-
Notifications
You must be signed in to change notification settings - Fork 171
✨ Add datadog-sdk-event-inspection skill for Claude Code #4263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mormubis
wants to merge
7
commits into
main
Choose a base branch
from
adlrb/verify-skill
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
916d8ca
✨ Add datadog-sdk-event-inspection skill for Claude Code
mormubis 13dabaa
🧹 Format SKILL.md
mormubis cb36c5b
🐛 Fix incorrect API names and replay payload in skill
mormubis e92dd87
📝 Add event inspection skill reference to AGENTS.md
mormubis 58493ba
🧹 Address PR feedback: mermaid diagram + Jasmine/Karma in AGENTS.md
mormubis 770e0cb
👌 Address review feedback: gitmoji table, Path B tooling, stopSession…
mormubis 2cc1269
🧹 Remove skill mention from AGENTS.md
mormubis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- | ||
| name: datadog-sdk-event-inspection | ||
| description: Use when verifying SDK event payloads in the Browser SDK sandbox, debugging what events are emitted, or validating custom attributes and event fields via chrome_devtools MCP. | ||
| --- | ||
|
|
||
| # Datadog Browser SDK — Event Inspection | ||
|
|
||
| ## Overview | ||
|
|
||
| The SDK calls `window.__ddBrowserSdkExtensionCallback(msg)` for every event before | ||
| batching. Setting this callback captures full event payloads before they reach intake. | ||
|
|
||
| **Core principle:** Set the callback BEFORE the SDK emits the event you want to inspect. | ||
|
|
||
| **Do not use network request interception for this.** Events are not flushed immediately (view events only finalize on navigation/session end). The callback approach is reliable and gives you events the moment they are emitted. | ||
|
|
||
| ## When to Use | ||
|
|
||
| - Verifying a change emits the correct event type or fields | ||
| - Checking custom attributes or user attributes appear on an event | ||
| - Debugging why an action/error/log was or wasn't captured | ||
| - Validating SDK behavior in the sandbox (`yarn dev` → `http://localhost:8080`) | ||
|
|
||
| ## Setup — Choose Your Injection Path | ||
|
|
||
| ```mermaid | ||
| flowchart TD | ||
| Q["Need initial view event<br/>or events from init()?"] | ||
| Q -- "yes" --> B["Path B: CDP pre-load injection"] | ||
| Q -- "no" --> A["Path A: Console injection"] | ||
| ``` | ||
|
|
||
| ### Path A — Console Injection (post-load events only) | ||
|
|
||
| For actions, errors, logs, and events triggered **after** the page has fully loaded. | ||
|
|
||
| Paste in the DevTools console after the page loads: | ||
|
|
||
| ```js | ||
| window.__ddBrowserSdkExtensionCallback = (msg) => { | ||
| console.log('[SDK Event]', JSON.stringify(msg)) | ||
| } | ||
| ``` | ||
|
|
||
| Then trigger the interaction. Read `[SDK Event]` lines from console output. | ||
|
|
||
| ### Path B — CDP Pre-load Injection (initial view + events from init) | ||
|
|
||
| The sandbox calls `DD_RUM.init()` synchronously in `<head>`. The initial view event fires during page load — before any post-load console injection runs. | ||
|
|
||
| **Before navigating**, use the `chrome-devtools_navigate_page` tool with the `initScript` parameter. This injects the script into every new document before any other code runs — before `DD_RUM.init()` fires. | ||
|
|
||
| ``` | ||
| Tool: chrome-devtools_navigate_page | ||
| Params: | ||
| type: "url" | ||
| url: "http://localhost:8080" | ||
| initScript: "window.__ddBrowserSdkExtensionCallback = (msg) => { console.log('[SDK Event]', JSON.stringify(msg)) }" | ||
| ``` | ||
|
|
||
| Every event — including the initial view — will appear in console logs. | ||
|
|
||
| **Do not inject via console and then reload.** Reloading clears the injected console code. | ||
|
|
||
| ## Event Message Structure | ||
|
|
||
| ``` | ||
| { type: 'rum', payload: RumEvent } // view, action, error, resource, long_task | ||
| { type: 'logs', payload: LogsEvent } | ||
| { type: 'telemetry', payload: TelemetryEvent } | ||
| { type: 'record', payload: { record } } // Session Replay only | ||
| ``` | ||
|
|
||
| ## Key Fields Quick Reference | ||
|
|
||
| | What to check | Field path | | ||
| | --------------------------------------------------------- | -------------------------------- | | ||
| | Event category | `msg.type` | | ||
| | RUM sub-type | `msg.payload.type` | | ||
| | User attribute (via `setUser`) | `msg.payload.usr.<key>` | | ||
| | Global context attribute (via `setGlobalContextProperty`) | `msg.payload.context.<key>` | | ||
| | Action name | `msg.payload.action.target.name` | | ||
| | Error message | `msg.payload.error.message` | | ||
| | View URL | `msg.payload.view.url` | | ||
| | Log message | `msg.payload.message` | | ||
| | Telemetry status | `msg.payload.telemetry.status` | | ||
|
|
||
| Note: user attributes use `usr` (not `user`) in the serialized payload. | ||
|
|
||
| ## Flush Caveat | ||
|
|
||
| **View events are only finalized when the view ends** (navigation or session end). | ||
| The initial view event will be updated multiple times as the page runs — earlier emissions are incomplete. | ||
|
|
||
| To get the final view event: trigger a navigation, or — **only as a last resort for debugging, as it permanently ends the current session** — call `window.DD_RUM.stopSession()` in the console. | ||
|
|
||
| ## Common Mistakes | ||
|
|
||
| | Mistake | Fix | | ||
| | -------------------------------------------------- | --------------------------------------------------------------------- | | ||
| | Using network requests to verify events | Events may not be flushed yet; use the callback instead | | ||
| | Console injection + reload to capture early events | Reload clears injected code — use Path B (CDP pre-load) | | ||
| | Missing the initial view event | Use Path B: `Page.addScriptToEvaluateOnNewDocument` before navigating | | ||
| | Seeing no `[SDK Event]` logs after reload | The callback was cleared by reload — re-run Path B setup | | ||
| | Incomplete view event data | View updates until view ends — navigate away or call `stopSession()` | | ||
| | Looking for `user.plan` in payload | It's `usr.plan` in serialized RUM events | |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔨 warning: It's missing mention of Jasmine and Karma. Without that Claude used to be confused in test APIs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already there — AGENTS.md has
- **Test framework**: Jasmine + Karmain the Unit Tests section.