@raindrop-ai/ai-sdk 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,14 +16,15 @@ yarn add @raindrop-ai/ai-sdk
16
16
 
17
17
  ```ts
18
18
  import * as ai from "ai";
19
- import { createRaindropAISDK } from "@raindrop-ai/ai-sdk";
19
+ import { createRaindropAISDK, eventMetadata } from "@raindrop-ai/ai-sdk";
20
20
 
21
21
  const raindrop = createRaindropAISDK({
22
22
  writeKey: process.env.RAINDROP_WRITE_KEY!,
23
23
  });
24
24
 
25
25
  const { generateText } = raindrop.wrap(ai, {
26
- context: { userId: "user_123", convoId: "convo_456", eventName: "chat_message" },
26
+ // userId is optional here (but recommended). If omitted here, you can still provide it per-call via eventMetadata(). Otherwise events will be skipped.
27
+ context: { convoId: "convo_456", eventName: "chat_message" },
27
28
  // optional: full control over event input/output, metadata, and attachments
28
29
  buildEvent: (messages) => {
29
30
  const lastUser = [...messages].reverse().find((m) => m.role === "user");
@@ -38,6 +39,10 @@ const { generateText } = raindrop.wrap(ai, {
38
39
  const result = await generateText({
39
40
  model: /* your AI SDK model */,
40
41
  prompt: "Hello!",
42
+ experimental_telemetry: {
43
+ isEnabled: true,
44
+ metadata: eventMetadata({ userId: "user_123" }),
45
+ },
41
46
  });
42
47
 
43
48
  // Identify a user (optional)
@@ -49,6 +54,8 @@ await raindrop.users.identify({
49
54
  await raindrop.flush();
50
55
  ```
51
56
 
57
+ If `userId` is missing from both `wrap()` context and `eventMetadata()`, the SDK logs a warning (once) and skips sending events.
58
+
52
59
  ## Runtime support
53
60
 
54
61
  ### Node.js (recommended)