The Raindrop SDK allows you to track user events and AI interactions in your app. This documentation provides a brief overview of how to use the Typescript SDK.
begin()
- creates an interaction object and logs the initial user input.setProperty
, setProperties
, or addAttachments
.finish()
- records the AI’s final output and closes the interaction.ai
SDKsetProperty
, setProperties
, or addAttachments
.
begin()
, you can resume an interaction by calling resumeInteraction()
.
trackAi
)trackAi()
directly:
Heads‑up: We recommend migrating tobegin()
→finish()
for all new code so you gain partial‑event buffering, tracing helpers, and upcoming features such as automatic token counts.
trackSignal()
with the same eventId
you used in begin()
or trackAi()
.
Parameter | Type | Description |
---|---|---|
eventId | string | The ID of the AI event you’re evaluating |
name | "thumbs_up", "thumbs_down" , string | Name of the signal (e.g. "thumbs_up" ) |
type | "default", "feedback", "edit" | Optional, defaults to "default" |
comment | string | For feedback signals |
after | string | For edit signals – the user’s final content |
sentiment | "POSITIVE", "NEGATIVE" | indicates whether the signal is positive (default is NEGATIVE) |
…others | See API reference |
begin()
interactions and in single‑shot trackAi
calls.
Each attachment is an object with the following properties:
type
(string): The type of attachment. Can be “code”, “text”, “image”, or “iframe”.name
(optional string): A name for the attachment.value
(string): The content or URL of the attachment.role
(string): Either “input” or “output”, indicating whether the attachment is part of the user input or AI output.language
(optional string): For code attachments, specifies the programming language.code
, text
, image
, iframe
.
Analytics
class like so:
debugLogs: true
prints every queued event.await raindrop.close()
before your process exits to flush buffers.raindrop-ai
package to serverExternalPackages
in your Next.js config.
withSpan
for Task Tracing (Beta)withSpan
method allows you to trace specific tasks or operations within your AI application. This is especially useful for tracking LLM requests. Any LLM call within the span will be automatically tracked, no further work required.
Parameter | Type | Description |
---|---|---|
name | string | Name of the task for identification in traces |
properties | Record<string, string> (optional) | Key-value pairs for additional metadata |
inputParameters | unknown[] (optional) | Array of input parameters for the task |
withTool
for Tool Tracing (Beta)withTool
method allows you to trace any actions your agent takes. This could be as simple as saving or retrieving a memory, or using external services like web search or API calls. Tracing these actions helps you understand your agent’s behavior and what led up to the agent’s response.
Parameter | Type | Description |
---|---|---|
name | string | Name of the tool for identification in traces |
version | number (optional) | Version number of the tool |
properties | Record<string, string> (optional) | Key-value pairs for additional metadata |
inputParameters | Record<string, any> (optional) | Record of input parameters for the tool |
traceContent | boolean (optional) | Flag to control whether content is traced |
suppressTracing | boolean (optional) | Flag to suppress tracing for this tool invocation |
disableTracing
option to true
when initializing the SDK.