Skip to main content
The @raindrop-ai/claude-agent-sdk package automatically instruments the Claude Agent SDK to capture events and traces from wrapped query calls. Add eventMetadata() (with a userId) to the specific queries you want tracked in Raindrop. Features:
  • No OpenTelemetry setup required
  • Automatic tool call tracing
  • Automatic conversation tracking using Claude Agent SDK’s session_id
  • Subagent span hierarchies for Task tool invocations
  • Wrap once, then optionally pass eventMetadata() to each query() call you want Raindrop to track

Installation

Quick Start

That’s it. Calls with eventMetadata() are tracked with events and traces. Calls without it run normally and are not tracked in Raindrop.

Configuration

Client Options

Projects

Route events to a specific project by passing its slug as projectId:
This sets the X-Raindrop-Project-Id header on every outbound event. Omit it (or pass "default") to use your org’s default Production project, which is the existing behavior. Single-project orgs need nothing new.

Self Diagnostics (Optional)

Self Diagnostics lets your agent proactively report its own issues — capability gaps, missing context, persistent tool failures — back to your team. It’s most valuable when an agent’s self-reflection provides signal you can’t easily get otherwise. The tool is delivered as an in-process MCP server, so it works alongside any other MCP servers you configure. The tool name defaults to __raindrop_report, and can be overridden with selfDiagnostics.toolName. The SDK automatically prompt-engineers the tool description from your signals definitions; selfDiagnostics.guidance is optional extra guidance.
When invoked, the injected tool tracks a signal on the same eventId:
The self-diagnostics tool is invisible to your integration: it is auto-approved in the PreToolUse hook and its tool_use/tool_result blocks are stripped from the SDK stream, so you never see it and don’t need to handle it.

Per-Query Context

Use eventMetadata() as the second argument when you want a query tracked. userId is required:
You can also set convoId, eventName, properties, or eventId per query. Defaults:
  • If eventMetadata() is omitted, the query runs normally but no events or traces are captured by Raindrop
  • eventName defaults to "agent_query"
  • convoId is auto-captured from Claude’s session_id if not provided
  • eventId is auto-generated if not provided

Identifying Users

Use users.identify to associate traits with a user:

Signals (Feedback)

Track user feedback on AI responses using the same eventId:

Signal Types


Manual Event Updates

Update events after they’re created (use eventId from eventMetadata):
The event is automatically finalized when the query stream completes. Use finish() only when you need to force immediate shipping before the stream ends.

Flush & Shutdown

Always flush before your process exits to ensure all data is sent:

Debugging

Enable debug logging to troubleshoot issues:
Or via environment variable:
This logs:
  • Every event sent to Raindrop
  • Every trace batch shipped
  • Span parent/child relationships (with debugSpans)

Troubleshooting

Events not appearing in dashboard

  1. Ensure tracked queries include eventMetadata()
  2. Check your write key - Ensure RAINDROP_WRITE_KEY is set correctly
  3. Flush before exit - Call await raindrop.flush() before your process ends
  4. Enable debug logging - Set events: { debug: true } to see what’s being sent

Traces missing or incomplete

  1. Enable trace debugging - Set traces: { debug: true, debugSpans: true }
  2. Check for errors - Look for [raindrop-ai/claude-agent-sdk] prefixed logs

Wrapper not capturing tool calls

Ensure the wrapped query is the one you call. Tools are traced via SDK hooks; if you call the unwrapped SDK directly, no tracing occurs.
That’s it! You’re ready to explore your events and traces in the Raindrop dashboard. Ping us on Slack or email us if you get stuck!