@databuddy/sdk 2.3.29 → 2.4.0

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.
@@ -0,0 +1,81 @@
1
+ interface FlagResult {
2
+ enabled: boolean;
3
+ value: boolean | string | number;
4
+ payload: Record<string, unknown> | null;
5
+ reason: string;
6
+ variant?: string;
7
+ }
8
+ interface UserContext {
9
+ userId?: string;
10
+ email?: string;
11
+ organizationId?: string;
12
+ teamId?: string;
13
+ properties?: Record<string, unknown>;
14
+ }
15
+ interface FlagsConfig {
16
+ clientId: string;
17
+ apiUrl?: string;
18
+ user?: UserContext;
19
+ disabled?: boolean;
20
+ debug?: boolean;
21
+ /** Skip persistent storage (browser only) */
22
+ skipStorage?: boolean;
23
+ /** Defer evaluation until session resolves */
24
+ isPending?: boolean;
25
+ /** Auto-fetch all flags on init (default: true) */
26
+ autoFetch?: boolean;
27
+ environment?: string;
28
+ /** Cache TTL in ms (default: 60000) */
29
+ cacheTtl?: number;
30
+ /** Stale time in ms — revalidate in background after this (default: cacheTtl/2) */
31
+ staleTime?: number;
32
+ /** Default values by flag key */
33
+ defaults?: Record<string, boolean | string | number>;
34
+ }
35
+ type FlagStatus = "loading" | "ready" | "error" | "pending";
36
+ interface FlagState {
37
+ on: boolean;
38
+ status: FlagStatus;
39
+ loading: boolean;
40
+ value?: boolean | string | number;
41
+ variant?: string;
42
+ }
43
+ interface FlagsContext {
44
+ getFlag: (key: string) => FlagState;
45
+ getValue: <T extends boolean | string | number = boolean>(key: string, defaultValue?: T) => T;
46
+ isOn: (key: string) => boolean;
47
+ fetchFlag: (key: string) => Promise<FlagResult>;
48
+ fetchAllFlags: () => Promise<void>;
49
+ updateUser: (user: UserContext) => void;
50
+ refresh: (forceClear?: boolean) => Promise<void>;
51
+ isReady: boolean;
52
+ }
53
+ interface FlagsSnapshot {
54
+ flags: Record<string, FlagResult>;
55
+ isReady: boolean;
56
+ }
57
+ interface StorageInterface {
58
+ getAll(): Record<string, FlagResult>;
59
+ setAll(flags: Record<string, FlagResult>): void;
60
+ clear(): void;
61
+ }
62
+ interface FlagsManagerOptions {
63
+ config: FlagsConfig;
64
+ storage?: StorageInterface;
65
+ }
66
+ interface FlagsManager {
67
+ getFlag(key: string, user?: UserContext): Promise<FlagResult>;
68
+ isEnabled(key: string): FlagState;
69
+ getValue<T = boolean | string | number>(key: string, defaultValue?: T): T;
70
+ fetchAllFlags(user?: UserContext): Promise<void>;
71
+ updateUser(user: UserContext): void;
72
+ refresh(forceClear?: boolean): Promise<void>;
73
+ updateConfig(config: FlagsConfig): void;
74
+ getMemoryFlags(): Record<string, FlagResult>;
75
+ isReady(): boolean;
76
+ destroy(): void;
77
+ subscribe(callback: () => void): () => void;
78
+ getSnapshot(): FlagsSnapshot;
79
+ }
80
+
81
+ export type { FlagsConfig as F, StorageInterface as S, UserContext as U, FlagState as a, FlagsContext as b, FlagResult as c, FlagsManager as d, FlagsManagerOptions as e, FlagsSnapshot as f };
@@ -1,7 +1,7 @@
1
1
  import * as vue from 'vue';
2
2
  import { App, ComputedRef } from 'vue';
3
- import { F as FlagsConfig, b as FlagState, d as FlagResult } from '../shared/@databuddy/sdk.CdLp6SQb.mjs';
4
- export { c as FlagsContext } from '../shared/@databuddy/sdk.CdLp6SQb.mjs';
3
+ import { F as FlagsConfig, a as FlagState, c as FlagResult } from '../shared/@databuddy/sdk.rnu91OSC.mjs';
4
+ export { b as FlagsContext } from '../shared/@databuddy/sdk.rnu91OSC.mjs';
5
5
 
6
6
  declare const Databuddy: vue.DefineComponent<{
7
7
  clientId?: string | undefined;
@@ -16,7 +16,6 @@ declare const Databuddy: vue.DefineComponent<{
16
16
  trackAttributes?: boolean | undefined;
17
17
  trackOutgoingLinks?: boolean | undefined;
18
18
  trackInteractions?: boolean | undefined;
19
- trackScrollDepth?: boolean | undefined;
20
19
  trackPerformance?: boolean | undefined;
21
20
  trackWebVitals?: boolean | undefined;
22
21
  trackErrors?: boolean | undefined;
@@ -45,7 +44,6 @@ declare const Databuddy: vue.DefineComponent<{
45
44
  trackAttributes?: boolean | undefined;
46
45
  trackOutgoingLinks?: boolean | undefined;
47
46
  trackInteractions?: boolean | undefined;
48
- trackScrollDepth?: boolean | undefined;
49
47
  trackPerformance?: boolean | undefined;
50
48
  trackWebVitals?: boolean | undefined;
51
49
  trackErrors?: boolean | undefined;
@@ -66,39 +64,21 @@ declare const Databuddy: vue.DefineComponent<{
66
64
  interface FlagsPluginOptions extends FlagsConfig {
67
65
  }
68
66
  declare function createFlagsPlugin(options: FlagsPluginOptions): {
69
- install(app: App): void;
67
+ install(_app: App): void;
70
68
  };
71
69
  declare function useFlags(): {
72
- isEnabled: (key: string) => FlagState;
70
+ getFlag: (key: string) => FlagState;
73
71
  fetchAllFlags: () => Promise<void>;
74
72
  updateUser: (user: FlagsConfig["user"]) => void;
75
- refresh: (forceClear?: boolean) => void;
73
+ refresh: (forceClear?: boolean) => Promise<void>;
76
74
  updateConfig: (config: FlagsConfig) => void;
77
75
  memoryFlags: Record<string, FlagResult>;
78
76
  };
79
77
 
80
- interface UseFlagReturn {
81
- /** Whether the flag is on */
78
+ declare function useFlag(key: string): {
82
79
  on: ComputedRef<boolean>;
83
- /** @deprecated Use `on` instead */
84
- enabled: ComputedRef<boolean>;
85
- /** Whether the flag is loading */
86
80
  loading: ComputedRef<boolean>;
87
- /** @deprecated Use `loading` instead */
88
- isLoading: ComputedRef<boolean>;
89
- /** @deprecated Use `status === 'ready'` instead */
90
- isReady: ComputedRef<boolean>;
91
- /** Full flag state */
92
81
  state: ComputedRef<FlagState>;
93
- }
94
- /**
95
- * Vue composable for individual flag usage with reactivity
96
- */
97
- declare function useFlag(key: string): UseFlagReturn;
98
- /**
99
- * Vue composable for boolean flag checking
100
- * @deprecated Use `useFlag(key).on` instead
101
- */
102
- declare function useBooleanFlag(key: string): ComputedRef<boolean>;
82
+ };
103
83
 
104
- export { Databuddy, FlagResult, FlagState, FlagsConfig, createFlagsPlugin, useBooleanFlag, useFlag, useFlags };
84
+ export { Databuddy, FlagResult, FlagState, FlagsConfig, createFlagsPlugin, useFlag, useFlags };
@@ -1,7 +1,7 @@
1
1
  import * as vue from 'vue';
2
2
  import { App, ComputedRef } from 'vue';
3
- import { F as FlagsConfig, b as FlagState, d as FlagResult } from '../shared/@databuddy/sdk.CdLp6SQb.js';
4
- export { c as FlagsContext } from '../shared/@databuddy/sdk.CdLp6SQb.js';
3
+ import { F as FlagsConfig, a as FlagState, c as FlagResult } from '../shared/@databuddy/sdk.rnu91OSC.js';
4
+ export { b as FlagsContext } from '../shared/@databuddy/sdk.rnu91OSC.js';
5
5
 
6
6
  declare const Databuddy: vue.DefineComponent<{
7
7
  clientId?: string | undefined;
@@ -16,7 +16,6 @@ declare const Databuddy: vue.DefineComponent<{
16
16
  trackAttributes?: boolean | undefined;
17
17
  trackOutgoingLinks?: boolean | undefined;
18
18
  trackInteractions?: boolean | undefined;
19
- trackScrollDepth?: boolean | undefined;
20
19
  trackPerformance?: boolean | undefined;
21
20
  trackWebVitals?: boolean | undefined;
22
21
  trackErrors?: boolean | undefined;
@@ -45,7 +44,6 @@ declare const Databuddy: vue.DefineComponent<{
45
44
  trackAttributes?: boolean | undefined;
46
45
  trackOutgoingLinks?: boolean | undefined;
47
46
  trackInteractions?: boolean | undefined;
48
- trackScrollDepth?: boolean | undefined;
49
47
  trackPerformance?: boolean | undefined;
50
48
  trackWebVitals?: boolean | undefined;
51
49
  trackErrors?: boolean | undefined;
@@ -66,39 +64,21 @@ declare const Databuddy: vue.DefineComponent<{
66
64
  interface FlagsPluginOptions extends FlagsConfig {
67
65
  }
68
66
  declare function createFlagsPlugin(options: FlagsPluginOptions): {
69
- install(app: App): void;
67
+ install(_app: App): void;
70
68
  };
71
69
  declare function useFlags(): {
72
- isEnabled: (key: string) => FlagState;
70
+ getFlag: (key: string) => FlagState;
73
71
  fetchAllFlags: () => Promise<void>;
74
72
  updateUser: (user: FlagsConfig["user"]) => void;
75
- refresh: (forceClear?: boolean) => void;
73
+ refresh: (forceClear?: boolean) => Promise<void>;
76
74
  updateConfig: (config: FlagsConfig) => void;
77
75
  memoryFlags: Record<string, FlagResult>;
78
76
  };
79
77
 
80
- interface UseFlagReturn {
81
- /** Whether the flag is on */
78
+ declare function useFlag(key: string): {
82
79
  on: ComputedRef<boolean>;
83
- /** @deprecated Use `on` instead */
84
- enabled: ComputedRef<boolean>;
85
- /** Whether the flag is loading */
86
80
  loading: ComputedRef<boolean>;
87
- /** @deprecated Use `loading` instead */
88
- isLoading: ComputedRef<boolean>;
89
- /** @deprecated Use `status === 'ready'` instead */
90
- isReady: ComputedRef<boolean>;
91
- /** Full flag state */
92
81
  state: ComputedRef<FlagState>;
93
- }
94
- /**
95
- * Vue composable for individual flag usage with reactivity
96
- */
97
- declare function useFlag(key: string): UseFlagReturn;
98
- /**
99
- * Vue composable for boolean flag checking
100
- * @deprecated Use `useFlag(key).on` instead
101
- */
102
- declare function useBooleanFlag(key: string): ComputedRef<boolean>;
82
+ };
103
83
 
104
- export { Databuddy, FlagResult, FlagState, FlagsConfig, createFlagsPlugin, useBooleanFlag, useFlag, useFlags };
84
+ export { Databuddy, FlagResult, FlagState, FlagsConfig, createFlagsPlugin, useFlag, useFlags };
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, onMounted, onUnmounted, watch, reactive, watchEffect, computed } from 'vue';
2
- import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.urY7MmVr.mjs';
3
- import { B as BrowserFlagStorage, C as CoreFlagsManager } from '../shared/@databuddy/sdk.DE24-JrU.mjs';
4
- import '../shared/@databuddy/sdk.CALvx07o.mjs';
2
+ import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.P9GHqNXr.mjs';
3
+ import { B as BrowserFlagStorage } from '../shared/@databuddy/sdk.GM10R1Kp.mjs';
4
+ import { B as BrowserFlagsManager } from '../shared/@databuddy/sdk.Ugr1p2j9.mjs';
5
5
 
6
6
  const Databuddy = defineComponent({
7
7
  props: {},
@@ -39,92 +39,56 @@ const Databuddy = defineComponent({
39
39
  }
40
40
  });
41
41
 
42
- const FLAGS_SYMBOL = Symbol("flags");
43
- let globalState = null;
44
- let globalManager = null;
42
+ let manager = null;
43
+ let state = null;
45
44
  function createFlagsPlugin(options) {
46
45
  return {
47
- install(app) {
46
+ install(_app) {
48
47
  const storage = options.skipStorage ? void 0 : new BrowserFlagStorage();
49
- const state = reactive({
50
- memoryFlags: {},
51
- pendingFlags: /* @__PURE__ */ new Set()
52
- });
53
- const manager = new CoreFlagsManager({
54
- config: options,
55
- storage,
56
- onFlagsUpdate: (flags) => {
57
- state.memoryFlags = flags;
48
+ state = reactive({ flags: {} });
49
+ manager = new BrowserFlagsManager({ config: options, storage });
50
+ manager.subscribe(() => {
51
+ if (state) {
52
+ state.flags = manager?.getSnapshot().flags ?? {};
58
53
  }
59
54
  });
60
- globalManager = manager;
61
- globalState = state;
62
- app.provide(FLAGS_SYMBOL, state);
63
55
  }
64
56
  };
65
57
  }
66
58
  function useFlags() {
67
- if (!globalState) {
59
+ if (!manager) {
68
60
  throw new Error(
69
- "Flags plugin not installed. Install with app.use(createFlagsPlugin(config))"
61
+ "Flags plugin not installed. Call app.use(createFlagsPlugin(config)) first."
70
62
  );
71
63
  }
72
- if (!globalManager) {
73
- throw new Error(
74
- "Flags manager not initialized. Please reinstall the plugin."
75
- );
76
- }
77
- const state = globalState;
78
- const manager = globalManager;
79
- const isEnabled = (key) => manager.isEnabled(key);
80
- const fetchAllFlags = () => manager.fetchAllFlags();
81
- const updateUser = (user) => {
82
- if (user) {
83
- manager.updateUser(user);
84
- }
85
- };
86
- const refresh = (forceClear = false) => {
87
- manager.refresh(forceClear);
88
- };
89
- const updateConfig = (config) => {
90
- manager.updateConfig(config);
91
- };
64
+ const m = manager;
65
+ const s = state;
92
66
  return {
93
- isEnabled,
94
- fetchAllFlags,
95
- updateUser,
96
- refresh,
97
- updateConfig,
98
- memoryFlags: state.memoryFlags
67
+ getFlag: (key) => m.isEnabled(key),
68
+ fetchAllFlags: () => m.fetchAllFlags(),
69
+ updateUser: (user) => {
70
+ if (user) {
71
+ m.updateUser(user);
72
+ }
73
+ },
74
+ refresh: (forceClear = false) => m.refresh(forceClear),
75
+ updateConfig: (config) => m.updateConfig(config),
76
+ memoryFlags: s?.flags ?? {}
99
77
  };
100
78
  }
101
79
 
102
- const defaultState = {
103
- on: false,
104
- enabled: false,
105
- status: "loading",
106
- loading: true,
107
- isLoading: true,
108
- isReady: false
109
- };
80
+ const defaultState = { on: false, status: "loading", loading: true };
110
81
  function useFlag(key) {
111
- const { isEnabled } = useFlags();
82
+ const { getFlag } = useFlags();
112
83
  const flagState = ref(defaultState);
113
84
  watchEffect(() => {
114
- flagState.value = isEnabled(key);
85
+ flagState.value = getFlag(key);
115
86
  });
116
87
  return {
117
88
  on: computed(() => flagState.value.on),
118
- enabled: computed(() => flagState.value.enabled),
119
89
  loading: computed(() => flagState.value.loading),
120
- isLoading: computed(() => flagState.value.isLoading),
121
- isReady: computed(() => flagState.value.isReady),
122
90
  state: computed(() => flagState.value)
123
91
  };
124
92
  }
125
- function useBooleanFlag(key) {
126
- const { on } = useFlag(key);
127
- return on;
128
- }
129
93
 
130
- export { Databuddy, createFlagsPlugin, useBooleanFlag, useFlag, useFlags };
94
+ export { Databuddy, createFlagsPlugin, useFlag, useFlags };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databuddy/sdk",
3
- "version": "2.3.29",
3
+ "version": "2.4.0",
4
4
  "description": "Official Databuddy Analytics SDK",
5
5
  "main": "./dist/core/index.mjs",
6
6
  "types": "./dist/core/index.d.ts",
@@ -11,42 +11,31 @@
11
11
  "scripts": {
12
12
  "build": "unbuild",
13
13
  "test": "bun test",
14
+ "test:e2e": "playwright test",
15
+ "test:e2e:install": "playwright install",
16
+ "serve": "bun test-server.ts",
14
17
  "vscode:prepublish": "bun run build"
15
18
  },
16
19
  "devDependencies": {
17
- "@ai-sdk/provider": "^3.0.2",
20
+ "@playwright/test": "^1.58.2",
18
21
  "@types/node": "^20.0.0",
22
+ "@types/react": "catalog:",
19
23
  "@vitejs/plugin-react": "^5.0.0",
20
- "ai": "^5.0.51",
24
+ "msw": "^2.11.5",
21
25
  "react": "catalog:",
22
- "@types/react": "catalog:",
23
- "tokenlens": "^2.0.0-alpha.3",
24
26
  "typescript": "catalog:",
25
27
  "unbuild": "^3.6.1",
26
- "vue": ">=3",
27
- "msw": "^2.11.5"
28
+ "vue": ">=3"
28
29
  },
29
30
  "peerDependencies": {
30
- "@ai-sdk/provider": "^2.0.0",
31
- "ai": "^5.0.51",
32
31
  "react": ">=18",
33
- "tokenlens": "^2.0.0-alpha.3",
34
32
  "msw": "^2.11.5",
35
33
  "vue": ">=3"
36
34
  },
37
35
  "peerDependenciesMeta": {
38
- "@ai-sdk/provider": {
39
- "optional": true
40
- },
41
- "ai": {
42
- "optional": true
43
- },
44
36
  "react": {
45
37
  "optional": true
46
38
  },
47
- "tokenlens": {
48
- "optional": true
49
- },
50
39
  "msw": {
51
40
  "optional": true
52
41
  },
@@ -70,10 +59,6 @@
70
59
  "./node": {
71
60
  "types": "./dist/node/index.d.ts",
72
61
  "import": "./dist/node/index.mjs"
73
- },
74
- "./ai/vercel": {
75
- "types": "./dist/ai/vercel/index.d.ts",
76
- "import": "./dist/ai/vercel/index.mjs"
77
62
  }
78
63
  },
79
64
  "files": [
@@ -1,236 +0,0 @@
1
- import { LanguageModelV2, LanguageModelV3 } from '@ai-sdk/provider';
2
-
3
- /**
4
- * Type guards and union types for Vercel AI SDK V2/V3 support
5
- *
6
- * Adapted from PostHog's AI SDK implementation:
7
- * https://github.com/PostHog/posthog-js/tree/main/packages/ai
8
- */
9
-
10
- type LanguageModel = LanguageModelV2 | LanguageModelV3;
11
-
12
- /**
13
- * Content types for input/output arrays
14
- */
15
- type MessageContent = {
16
- type: "text";
17
- text: string;
18
- } | {
19
- type: "reasoning";
20
- text: string;
21
- } | {
22
- type: "tool-call";
23
- id: string;
24
- function: {
25
- name: string;
26
- arguments: string;
27
- };
28
- } | {
29
- type: "tool-result";
30
- toolCallId: string;
31
- toolName: string;
32
- output: unknown;
33
- isError?: boolean;
34
- } | {
35
- type: "file";
36
- file: string;
37
- mediaType: string;
38
- } | {
39
- type: "image";
40
- image: string;
41
- mediaType: string;
42
- } | {
43
- type: "source";
44
- sourceType: string;
45
- id: string;
46
- url: string;
47
- title: string;
48
- };
49
- /**
50
- * Message format for input/output
51
- */
52
- interface AIMessage {
53
- role: string;
54
- content: string | MessageContent[];
55
- }
56
- /**
57
- * Token usage from AI model calls
58
- */
59
- interface TokenUsage {
60
- inputTokens: number;
61
- outputTokens: number;
62
- totalTokens: number;
63
- cachedInputTokens?: number;
64
- cacheCreationInputTokens?: number;
65
- reasoningTokens?: number;
66
- webSearchCount?: number;
67
- }
68
- /**
69
- * Cost breakdown from TokenLens
70
- */
71
- interface TokenCost {
72
- inputTokenCostUSD?: number;
73
- outputTokenCostUSD?: number;
74
- totalTokenCostUSD?: number;
75
- }
76
- /**
77
- * Tool call information
78
- */
79
- interface ToolCallInfo {
80
- toolCallCount: number;
81
- toolResultCount: number;
82
- toolCallNames: string[];
83
- availableTools?: string[];
84
- }
85
- /**
86
- * Error information for failed AI calls
87
- */
88
- interface AIError {
89
- name: string;
90
- message: string;
91
- stack?: string;
92
- }
93
- /**
94
- * Complete AI call log entry
95
- */
96
- interface AICall {
97
- timestamp: Date;
98
- traceId: string;
99
- type: "generate" | "stream";
100
- model: string;
101
- provider: string;
102
- finishReason?: string;
103
- input: AIMessage[];
104
- output: AIMessage[];
105
- usage: TokenUsage;
106
- cost: TokenCost;
107
- tools: ToolCallInfo;
108
- error?: AIError;
109
- durationMs: number;
110
- httpStatus?: number;
111
- params?: Record<string, unknown>;
112
- }
113
- /**
114
- * Transport function for sending log entries
115
- */
116
- type Transport = (call: AICall) => Promise<void> | void;
117
- /**
118
- * Configuration options for Databuddy LLM tracking
119
- */
120
- interface DatabuddyLLMOptions {
121
- /**
122
- * API endpoint for sending logs (should include /llm path)
123
- * @default process.env.DATABUDDY_API_URL or 'https://basket.databuddy.cc/llm'
124
- */
125
- apiUrl?: string;
126
- /**
127
- * API key for authentication (determines owner - org or user)
128
- * @default process.env.DATABUDDY_API_KEY
129
- */
130
- apiKey?: string;
131
- /**
132
- * Custom transport function to send log entries
133
- * If provided, overrides default HTTP transport
134
- */
135
- transport?: Transport;
136
- /**
137
- * Whether to compute costs using TokenLens
138
- * @default true
139
- */
140
- computeCosts?: boolean;
141
- /**
142
- * Privacy mode - when true, input/output content is not captured
143
- * @default false
144
- */
145
- privacyMode?: boolean;
146
- /**
147
- * Maximum size for input/output content in bytes
148
- * @default 1048576 (1MB)
149
- */
150
- maxContentSize?: number;
151
- /**
152
- * Called on successful AI calls
153
- */
154
- onSuccess?: (call: AICall) => void;
155
- /**
156
- * Called on failed AI calls
157
- */
158
- onError?: (call: AICall) => void;
159
- }
160
- /**
161
- * Configuration options for tracking individual models
162
- */
163
- interface TrackOptions {
164
- /**
165
- * Transport function to send log entries
166
- * If not provided, uses the transport from DatabuddyLLM instance
167
- */
168
- transport?: Transport;
169
- /**
170
- * Trace ID to link related calls together
171
- */
172
- traceId?: string;
173
- /**
174
- * Whether to compute costs using TokenLens
175
- * @default true
176
- */
177
- computeCosts?: boolean;
178
- /**
179
- * Privacy mode - when true, input/output content is not captured
180
- * @default false
181
- */
182
- privacyMode?: boolean;
183
- /**
184
- * Called on successful AI calls
185
- */
186
- onSuccess?: (call: AICall) => void;
187
- /**
188
- * Called on failed AI calls
189
- */
190
- onError?: (call: AICall) => void;
191
- }
192
-
193
- /**
194
- * Create an HTTP transport that sends logs to an API endpoint
195
- *
196
- * @example
197
- * ```ts
198
- * import { databuddyLLM, httpTransport } from "@databuddy/sdk/ai/vercel";
199
- *
200
- * const { track } = databuddyLLM({
201
- * transport: httpTransport("https://api.example.com/ai-logs", "api-key"),
202
- * });
203
- * ```
204
- */
205
- declare const httpTransport: (url: string, apiKey?: string) => Transport;
206
-
207
- /**
208
- * Vercel AI SDK middleware for Databuddy
209
- *
210
- * Inspired by and adapted from PostHog's AI SDK implementation:
211
- * https://github.com/PostHog/posthog-js/tree/main/packages/ai
212
- */
213
-
214
- /**
215
- * Create a Databuddy LLM tracking instance
216
- *
217
- * @example
218
- * ```ts
219
- * import { databuddyLLM } from "@databuddy/sdk/ai/vercel";
220
- *
221
- * const { track } = databuddyLLM({ apiKey: "your-api-key" });
222
- * const model = track(openai("gpt-4"));
223
- * ```
224
- */
225
- declare const databuddyLLM: (options?: DatabuddyLLMOptions) => {
226
- track: <T extends LanguageModel>(model: T, trackOptions?: TrackOptions) => T;
227
- transport: Transport;
228
- };
229
-
230
- /**
231
- * Generate a simple trace ID
232
- */
233
- declare const generateTraceId: () => string;
234
-
235
- export { databuddyLLM, generateTraceId, httpTransport };
236
- export type { AICall, AIError, DatabuddyLLMOptions, TokenCost, TokenUsage, ToolCallInfo, TrackOptions, Transport };