@databuddy/sdk 2.2.0 → 2.2.11

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.
@@ -5,57 +5,85 @@ interface Logger {
5
5
  debug(msg: string, data?: Record<string, unknown>): void;
6
6
  }
7
7
 
8
+ /**
9
+ * Middleware function that can transform or filter events
10
+ * Return null to drop the event, or return a modified event
11
+ */
12
+ type Middleware = (event: BatchEventInput) => BatchEventInput | null | Promise<BatchEventInput | null>;
8
13
  interface DatabuddyConfig {
14
+ /** Client ID from Databuddy dashboard */
9
15
  clientId: string;
16
+ /** Custom API endpoint (default: https://basket.databuddy.cc) */
10
17
  apiUrl?: string;
18
+ /** Enable debug logging */
11
19
  debug?: boolean;
20
+ /** Custom logger instance */
12
21
  logger?: Logger;
13
- /**
14
- * Enable automatic batching of events
15
- * Default: true
16
- */
22
+ /** Enable automatic batching (default: true) */
17
23
  enableBatching?: boolean;
18
- /**
19
- * Number of events to batch before auto-flushing
20
- * Default: 10, Max: 100
21
- */
24
+ /** Number of events to batch before flushing (default: 10, max: 100) */
22
25
  batchSize?: number;
23
- /**
24
- * Time in milliseconds before auto-flushing batched events
25
- * Default: 2000ms (2 seconds)
26
- */
26
+ /** Time in ms before auto-flushing batched events (default: 2000) */
27
27
  batchTimeout?: number;
28
- /**
29
- * Maximum number of events to queue before auto-flushing
30
- * Default: 1000
31
- */
28
+ /** Maximum number of events to queue (default: 1000) */
32
29
  maxQueueSize?: number;
30
+ /** Middleware functions to transform events */
31
+ middleware?: Middleware[];
32
+ /** Enable event deduplication based on eventId (default: true) */
33
+ enableDeduplication?: boolean;
34
+ /** Maximum deduplication cache size (default: 10000) */
35
+ maxDeduplicationCacheSize?: number;
33
36
  }
34
37
  interface CustomEventInput {
38
+ /** Event name (required) */
35
39
  name: string;
40
+ /** Unique event ID for deduplication */
36
41
  eventId?: string;
42
+ /** Anonymous user ID */
37
43
  anonymousId?: string | null;
44
+ /** Session ID */
38
45
  sessionId?: string | null;
46
+ /** Event timestamp in milliseconds */
39
47
  timestamp?: number | null;
48
+ /** Event properties/metadata */
40
49
  properties?: Record<string, unknown> | null;
41
50
  }
42
51
  interface EventResponse {
52
+ /** Whether the event was successfully sent */
43
53
  success: boolean;
54
+ /** Server-assigned event ID */
44
55
  eventId?: string;
56
+ /** Error message if failed */
45
57
  error?: string;
46
58
  }
47
59
  interface BatchEventInput {
48
- type: 'custom';
60
+ /** Event type */
61
+ type: "custom";
62
+ /** Event name */
49
63
  name: string;
64
+ /** Unique event ID for deduplication */
50
65
  eventId?: string;
66
+ /** Anonymous user ID */
51
67
  anonymousId?: string | null;
68
+ /** Session ID */
52
69
  sessionId?: string | null;
70
+ /** Event timestamp in milliseconds */
53
71
  timestamp?: number | null;
72
+ /** Event properties/metadata */
54
73
  properties?: Record<string, unknown> | null;
55
74
  }
75
+ /**
76
+ * Global properties that will be attached to all events
77
+ */
78
+ interface GlobalProperties {
79
+ [key: string]: unknown;
80
+ }
56
81
  interface BatchEventResponse {
82
+ /** Whether the batch was successfully sent */
57
83
  success: boolean;
84
+ /** Number of events processed */
58
85
  processed?: number;
86
+ /** Results for each event in the batch */
59
87
  results?: Array<{
60
88
  status: string;
61
89
  type?: string;
@@ -63,11 +91,12 @@ interface BatchEventResponse {
63
91
  message?: string;
64
92
  error?: string;
65
93
  }>;
94
+ /** Error message if batch failed */
66
95
  error?: string;
67
96
  }
68
97
 
69
98
  declare class Databuddy {
70
- private clientId;
99
+ private readonly clientId;
71
100
  private apiUrl;
72
101
  private logger;
73
102
  private enableBatching;
@@ -75,20 +104,21 @@ declare class Databuddy {
75
104
  private batchTimeout;
76
105
  private queue;
77
106
  private flushTimer;
107
+ private globalProperties;
108
+ private middleware;
109
+ private enableDeduplication;
110
+ private deduplicationCache;
111
+ private maxDeduplicationCacheSize;
78
112
  constructor(config: DatabuddyConfig);
79
113
  /**
80
114
  * Track a custom event
81
- * If batching is enabled, queues the event and auto-flushes when batch size is reached or timeout expires
82
- * If batching is disabled, sends the event immediately
83
- *
84
- * @param event - Custom event data
85
- * @returns Response indicating success or failure
86
- *
115
+ * @param event - Event data to track
116
+ * @returns Promise with success/error response
87
117
  * @example
88
118
  * ```typescript
89
119
  * await client.track({
90
120
  * name: 'user_signup',
91
- * properties: { plan: 'pro' }
121
+ * properties: { plan: 'pro', source: 'web' }
92
122
  * });
93
123
  * ```
94
124
  */
@@ -97,26 +127,19 @@ declare class Databuddy {
97
127
  private scheduleFlush;
98
128
  /**
99
129
  * Manually flush all queued events
100
- * Important for serverless/stateless environments where you need to ensure events are sent before the process exits
101
- *
102
- * @returns Response with batch results
103
- *
130
+ * Useful in serverless environments to ensure events are sent before process exits
131
+ * @returns Promise with batch results
104
132
  * @example
105
133
  * ```typescript
106
- * // In serverless function
107
134
  * await client.track({ name: 'api_call' });
108
- * await client.flush(); // Ensure events are sent before function exits
135
+ * await client.flush(); // Ensure events are sent
109
136
  * ```
110
137
  */
111
138
  flush(): Promise<BatchEventResponse>;
112
139
  /**
113
- * Send multiple custom events in a single batch request
114
- * Max 100 events per batch
115
- * Note: Usually you don't need to call this directly - use track() with batching enabled instead
116
- *
117
- * @param events - Array of custom events
118
- * @returns Response with results for each event
119
- *
140
+ * Send multiple events in a single batch request
141
+ * @param events - Array of events to batch (max 100)
142
+ * @returns Promise with batch results
120
143
  * @example
121
144
  * ```typescript
122
145
  * await client.batch([
@@ -126,7 +149,89 @@ declare class Databuddy {
126
149
  * ```
127
150
  */
128
151
  batch(events: BatchEventInput[]): Promise<BatchEventResponse>;
152
+ /**
153
+ * Set global properties attached to all events
154
+ * Properties are merged with existing globals; event properties override globals
155
+ * @param properties - Properties to merge with existing globals
156
+ * @example
157
+ * ```typescript
158
+ * client.setGlobalProperties({ environment: 'production', version: '1.0.0' });
159
+ * // All subsequent events will include these properties
160
+ * ```
161
+ */
162
+ setGlobalProperties(properties: GlobalProperties): void;
163
+ /**
164
+ * Get current global properties
165
+ * @returns Copy of current global properties
166
+ * @example
167
+ * ```typescript
168
+ * const globals = client.getGlobalProperties();
169
+ * console.log(globals); // { environment: 'production', version: '1.0.0' }
170
+ * ```
171
+ */
172
+ getGlobalProperties(): GlobalProperties;
173
+ /**
174
+ * Clear all global properties
175
+ * @example
176
+ * ```typescript
177
+ * client.clearGlobalProperties();
178
+ * // No more global properties will be attached to events
179
+ * ```
180
+ */
181
+ clearGlobalProperties(): void;
182
+ /**
183
+ * Add middleware to transform events
184
+ * Middleware runs before deduplication and is executed in order
185
+ * Return null to drop the event, or return a modified event
186
+ * @param middleware - Middleware function
187
+ * @example
188
+ * ```typescript
189
+ * client.addMiddleware((event) => {
190
+ * // Add custom field
191
+ * event.properties = { ...event.properties, processed: true };
192
+ * return event;
193
+ * });
194
+ *
195
+ * // Drop events matching a condition
196
+ * client.addMiddleware((event) => {
197
+ * if (event.name === 'unwanted_event') return null;
198
+ * return event;
199
+ * });
200
+ * ```
201
+ */
202
+ addMiddleware(middleware: Middleware): void;
203
+ /**
204
+ * Remove all middleware functions
205
+ * @example
206
+ * ```typescript
207
+ * client.clearMiddleware();
208
+ * // All middleware transformations removed
209
+ * ```
210
+ */
211
+ clearMiddleware(): void;
212
+ /**
213
+ * Get current deduplication cache size
214
+ * @returns Number of event IDs in cache
215
+ * @example
216
+ * ```typescript
217
+ * const size = client.getDeduplicationCacheSize();
218
+ * console.log(`Cache size: ${size}`);
219
+ * ```
220
+ */
221
+ getDeduplicationCacheSize(): number;
222
+ /**
223
+ * Clear the deduplication cache
224
+ * Useful for testing or resetting duplicate detection
225
+ * @example
226
+ * ```typescript
227
+ * client.clearDeduplicationCache();
228
+ * // All cached event IDs cleared
229
+ * ```
230
+ */
231
+ clearDeduplicationCache(): void;
232
+ private applyMiddleware;
233
+ private addToDeduplicationCache;
129
234
  }
130
235
 
131
236
  export { Databuddy, Databuddy as db };
132
- export type { BatchEventInput, BatchEventResponse, CustomEventInput, DatabuddyConfig, EventResponse, Logger };
237
+ export type { BatchEventInput, BatchEventResponse, CustomEventInput, DatabuddyConfig, EventResponse, GlobalProperties, Logger, Middleware };
@@ -20,10 +20,7 @@ function createConsoleLogger(debug) {
20
20
  },
21
21
  error(msg, data) {
22
22
  if (debug) {
23
- console.error(
24
- `[Databuddy] ${msg}`,
25
- data ? JSON.stringify(data) : ""
26
- );
23
+ console.error(`[Databuddy] ${msg}`, data ? JSON.stringify(data) : "");
27
24
  }
28
25
  },
29
26
  warn(msg, data) {
@@ -32,10 +29,7 @@ function createConsoleLogger(debug) {
32
29
  }
33
30
  },
34
31
  debug: debug ? (msg, data) => {
35
- console.debug(
36
- `[Databuddy] ${msg}`,
37
- data ? JSON.stringify(data) : ""
38
- );
32
+ console.debug(`[Databuddy] ${msg}`, data ? JSON.stringify(data) : "");
39
33
  } : noop
40
34
  };
41
35
  }
@@ -78,6 +72,7 @@ const DEFAULT_API_URL = "https://basket.databuddy.cc";
78
72
  const DEFAULT_BATCH_SIZE = 10;
79
73
  const DEFAULT_BATCH_TIMEOUT = 2e3;
80
74
  const DEFAULT_MAX_QUEUE_SIZE = 1e3;
75
+ const DEFAULT_MAX_DEDUPLICATION_CACHE_SIZE = 1e4;
81
76
  class Databuddy {
82
77
  clientId;
83
78
  apiUrl;
@@ -87,6 +82,11 @@ class Databuddy {
87
82
  batchTimeout;
88
83
  queue;
89
84
  flushTimer = null;
85
+ globalProperties = {};
86
+ middleware = [];
87
+ enableDeduplication;
88
+ deduplicationCache = /* @__PURE__ */ new Set();
89
+ maxDeduplicationCacheSize;
90
90
  constructor(config) {
91
91
  if (!config.clientId || typeof config.clientId !== "string") {
92
92
  throw new Error("clientId is required and must be a string");
@@ -97,6 +97,9 @@ class Databuddy {
97
97
  this.batchSize = Math.min(config.batchSize || DEFAULT_BATCH_SIZE, 100);
98
98
  this.batchTimeout = config.batchTimeout || DEFAULT_BATCH_TIMEOUT;
99
99
  this.queue = new EventQueue(config.maxQueueSize || DEFAULT_MAX_QUEUE_SIZE);
100
+ this.middleware = config.middleware || [];
101
+ this.enableDeduplication = config.enableDeduplication !== false;
102
+ this.maxDeduplicationCacheSize = config.maxDeduplicationCacheSize || DEFAULT_MAX_DEDUPLICATION_CACHE_SIZE;
100
103
  if (config.logger) {
101
104
  this.logger = config.logger;
102
105
  } else if (config.debug) {
@@ -109,22 +112,20 @@ class Databuddy {
109
112
  apiUrl: this.apiUrl,
110
113
  enableBatching: this.enableBatching,
111
114
  batchSize: this.batchSize,
112
- batchTimeout: this.batchTimeout
115
+ batchTimeout: this.batchTimeout,
116
+ middlewareCount: this.middleware.length,
117
+ enableDeduplication: this.enableDeduplication
113
118
  });
114
119
  }
115
120
  /**
116
121
  * Track a custom event
117
- * If batching is enabled, queues the event and auto-flushes when batch size is reached or timeout expires
118
- * If batching is disabled, sends the event immediately
119
- *
120
- * @param event - Custom event data
121
- * @returns Response indicating success or failure
122
- *
122
+ * @param event - Event data to track
123
+ * @returns Promise with success/error response
123
124
  * @example
124
125
  * ```typescript
125
126
  * await client.track({
126
127
  * name: 'user_signup',
127
- * properties: { plan: 'pro' }
128
+ * properties: { plan: 'pro', source: 'web' }
128
129
  * });
129
130
  * ```
130
131
  */
@@ -142,12 +143,29 @@ class Databuddy {
142
143
  anonymousId: event.anonymousId,
143
144
  sessionId: event.sessionId,
144
145
  timestamp: event.timestamp,
145
- properties: event.properties || null
146
+ properties: {
147
+ ...this.globalProperties,
148
+ ...event.properties || {}
149
+ }
146
150
  };
151
+ const processedEvent = await this.applyMiddleware(batchEvent);
152
+ if (!processedEvent) {
153
+ this.logger.debug("Event dropped by middleware", { name: event.name });
154
+ return { success: true };
155
+ }
156
+ if (this.enableDeduplication && processedEvent.eventId) {
157
+ if (this.deduplicationCache.has(processedEvent.eventId)) {
158
+ this.logger.debug("Event deduplicated", {
159
+ eventId: processedEvent.eventId
160
+ });
161
+ return { success: true };
162
+ }
163
+ this.addToDeduplicationCache(processedEvent.eventId);
164
+ }
147
165
  if (!this.enableBatching) {
148
- return this.send(batchEvent);
166
+ return this.send(processedEvent);
149
167
  }
150
- const shouldFlush = this.queue.add(batchEvent);
168
+ const shouldFlush = this.queue.add(processedEvent);
151
169
  this.logger.debug("Event queued", { queueSize: this.queue.size() });
152
170
  this.scheduleFlush();
153
171
  if (shouldFlush || this.queue.size() >= this.batchSize) {
@@ -218,15 +236,12 @@ class Databuddy {
218
236
  }
219
237
  /**
220
238
  * Manually flush all queued events
221
- * Important for serverless/stateless environments where you need to ensure events are sent before the process exits
222
- *
223
- * @returns Response with batch results
224
- *
239
+ * Useful in serverless environments to ensure events are sent before process exits
240
+ * @returns Promise with batch results
225
241
  * @example
226
242
  * ```typescript
227
- * // In serverless function
228
243
  * await client.track({ name: 'api_call' });
229
- * await client.flush(); // Ensure events are sent before function exits
244
+ * await client.flush(); // Ensure events are sent
230
245
  * ```
231
246
  */
232
247
  async flush() {
@@ -247,13 +262,9 @@ class Databuddy {
247
262
  return this.batch(events);
248
263
  }
249
264
  /**
250
- * Send multiple custom events in a single batch request
251
- * Max 100 events per batch
252
- * Note: Usually you don't need to call this directly - use track() with batching enabled instead
253
- *
254
- * @param events - Array of custom events
255
- * @returns Response with results for each event
256
- *
265
+ * Send multiple events in a single batch request
266
+ * @param events - Array of events to batch (max 100)
267
+ * @returns Promise with batch results
257
268
  * @example
258
269
  * ```typescript
259
270
  * await client.batch([
@@ -289,20 +300,57 @@ class Databuddy {
289
300
  };
290
301
  }
291
302
  }
303
+ const enrichedEvents = events.map((event) => ({
304
+ ...event,
305
+ properties: {
306
+ ...this.globalProperties,
307
+ ...event.properties || {}
308
+ }
309
+ }));
310
+ const processedEvents = [];
311
+ for (const event of enrichedEvents) {
312
+ const processedEvent = await this.applyMiddleware(event);
313
+ if (!processedEvent) {
314
+ continue;
315
+ }
316
+ if (this.enableDeduplication && processedEvent.eventId) {
317
+ if (this.deduplicationCache.has(processedEvent.eventId)) {
318
+ this.logger.debug("Event deduplicated in batch", {
319
+ eventId: processedEvent.eventId
320
+ });
321
+ continue;
322
+ }
323
+ this.addToDeduplicationCache(processedEvent.eventId);
324
+ }
325
+ processedEvents.push(processedEvent);
326
+ }
327
+ if (processedEvents.length === 0) {
328
+ return {
329
+ success: true,
330
+ processed: 0,
331
+ results: []
332
+ };
333
+ }
292
334
  try {
293
335
  const url = `${this.apiUrl}/batch?client_id=${encodeURIComponent(this.clientId)}`;
294
336
  this.logger.info("\u{1F4E6} SENDING BATCH EVENTS:", {
295
- count: events.length,
296
- firstEventName: events[0]?.name,
297
- firstEventProperties: JSON.stringify(events[0]?.properties, null, 2),
298
- firstEventPropertiesCount: Object.keys(events[0]?.properties || {}).length
337
+ count: processedEvents.length,
338
+ firstEventName: processedEvents[0]?.name,
339
+ firstEventProperties: JSON.stringify(
340
+ processedEvents[0]?.properties,
341
+ null,
342
+ 2
343
+ ),
344
+ firstEventPropertiesCount: Object.keys(
345
+ processedEvents[0]?.properties || {}
346
+ ).length
299
347
  });
300
348
  const response = await fetch(url, {
301
349
  method: "POST",
302
350
  headers: {
303
351
  "Content-Type": "application/json"
304
352
  },
305
- body: JSON.stringify(events)
353
+ body: JSON.stringify(processedEvents)
306
354
  });
307
355
  if (!response.ok) {
308
356
  const errorText = await response.text().catch(() => "Unknown error");
@@ -321,7 +369,7 @@ class Databuddy {
321
369
  if (data.status === "success") {
322
370
  return {
323
371
  success: true,
324
- processed: data.processed,
372
+ processed: data.processed || processedEvents.length,
325
373
  results: data.results
326
374
  };
327
375
  }
@@ -339,6 +387,132 @@ class Databuddy {
339
387
  };
340
388
  }
341
389
  }
390
+ /**
391
+ * Set global properties attached to all events
392
+ * Properties are merged with existing globals; event properties override globals
393
+ * @param properties - Properties to merge with existing globals
394
+ * @example
395
+ * ```typescript
396
+ * client.setGlobalProperties({ environment: 'production', version: '1.0.0' });
397
+ * // All subsequent events will include these properties
398
+ * ```
399
+ */
400
+ setGlobalProperties(properties) {
401
+ this.globalProperties = { ...this.globalProperties, ...properties };
402
+ this.logger.debug("Global properties updated", { properties });
403
+ }
404
+ /**
405
+ * Get current global properties
406
+ * @returns Copy of current global properties
407
+ * @example
408
+ * ```typescript
409
+ * const globals = client.getGlobalProperties();
410
+ * console.log(globals); // { environment: 'production', version: '1.0.0' }
411
+ * ```
412
+ */
413
+ getGlobalProperties() {
414
+ return { ...this.globalProperties };
415
+ }
416
+ /**
417
+ * Clear all global properties
418
+ * @example
419
+ * ```typescript
420
+ * client.clearGlobalProperties();
421
+ * // No more global properties will be attached to events
422
+ * ```
423
+ */
424
+ clearGlobalProperties() {
425
+ this.globalProperties = {};
426
+ this.logger.debug("Global properties cleared");
427
+ }
428
+ /**
429
+ * Add middleware to transform events
430
+ * Middleware runs before deduplication and is executed in order
431
+ * Return null to drop the event, or return a modified event
432
+ * @param middleware - Middleware function
433
+ * @example
434
+ * ```typescript
435
+ * client.addMiddleware((event) => {
436
+ * // Add custom field
437
+ * event.properties = { ...event.properties, processed: true };
438
+ * return event;
439
+ * });
440
+ *
441
+ * // Drop events matching a condition
442
+ * client.addMiddleware((event) => {
443
+ * if (event.name === 'unwanted_event') return null;
444
+ * return event;
445
+ * });
446
+ * ```
447
+ */
448
+ addMiddleware(middleware) {
449
+ this.middleware.push(middleware);
450
+ this.logger.debug("Middleware added", {
451
+ totalMiddleware: this.middleware.length
452
+ });
453
+ }
454
+ /**
455
+ * Remove all middleware functions
456
+ * @example
457
+ * ```typescript
458
+ * client.clearMiddleware();
459
+ * // All middleware transformations removed
460
+ * ```
461
+ */
462
+ clearMiddleware() {
463
+ this.middleware = [];
464
+ this.logger.debug("Middleware cleared");
465
+ }
466
+ /**
467
+ * Get current deduplication cache size
468
+ * @returns Number of event IDs in cache
469
+ * @example
470
+ * ```typescript
471
+ * const size = client.getDeduplicationCacheSize();
472
+ * console.log(`Cache size: ${size}`);
473
+ * ```
474
+ */
475
+ getDeduplicationCacheSize() {
476
+ return this.deduplicationCache.size;
477
+ }
478
+ /**
479
+ * Clear the deduplication cache
480
+ * Useful for testing or resetting duplicate detection
481
+ * @example
482
+ * ```typescript
483
+ * client.clearDeduplicationCache();
484
+ * // All cached event IDs cleared
485
+ * ```
486
+ */
487
+ clearDeduplicationCache() {
488
+ this.deduplicationCache.clear();
489
+ this.logger.debug("Deduplication cache cleared");
490
+ }
491
+ async applyMiddleware(event) {
492
+ let processedEvent = event;
493
+ for (const middleware of this.middleware) {
494
+ if (!processedEvent) {
495
+ break;
496
+ }
497
+ try {
498
+ processedEvent = await middleware(processedEvent);
499
+ } catch (error) {
500
+ this.logger.error("Middleware error", {
501
+ error: error instanceof Error ? error.message : String(error)
502
+ });
503
+ }
504
+ }
505
+ return processedEvent;
506
+ }
507
+ addToDeduplicationCache(eventId) {
508
+ if (this.deduplicationCache.size >= this.maxDeduplicationCacheSize) {
509
+ const oldest = this.deduplicationCache.values().next().value;
510
+ if (oldest) {
511
+ this.deduplicationCache.delete(oldest);
512
+ }
513
+ }
514
+ this.deduplicationCache.add(eventId);
515
+ }
342
516
  }
343
517
 
344
518
  export { Databuddy, Databuddy as db };
@@ -1,12 +1,25 @@
1
- export { b as Databuddy } from '../shared/@databuddy/sdk.C8T93n5r.mjs';
1
+ import { D as DatabuddyConfig } from '../shared/@databuddy/sdk.B1NyVg8b.mjs';
2
+ import * as react from 'react';
2
3
  import { ReactNode } from 'react';
3
- import { d as FlagsConfig, c as FlagState } from '../shared/@databuddy/sdk.YfiY9DoZ.mjs';
4
- export { b as FlagResult, e as FlagsContext } from '../shared/@databuddy/sdk.YfiY9DoZ.mjs';
4
+ import * as jotai_vanilla_internals from 'jotai/vanilla/internals';
5
+ import { d as FlagsConfig, c as FlagState } from '../shared/@databuddy/sdk.OK9Nbqlf.mjs';
6
+ export { b as FlagResult, e as FlagsContext } from '../shared/@databuddy/sdk.OK9Nbqlf.mjs';
7
+
8
+ /**
9
+ * <Databuddy /> component for Next.js/React apps
10
+ * Injects the databuddy.js script with all config as data attributes
11
+ * Usage: <Databuddy clientId="..." trackScreenViews trackPerformance ... />
12
+ * Or simply: <Databuddy /> (auto-detects clientId from environment variables)
13
+ */
14
+ declare function Databuddy(props: DatabuddyConfig): null;
5
15
 
6
16
  interface FlagsProviderProps extends FlagsConfig {
7
17
  children: ReactNode;
8
18
  }
9
- declare function FlagsProvider({ children, ...config }: FlagsProviderProps): any;
19
+ declare function FlagsProvider({ children, ...config }: FlagsProviderProps): react.FunctionComponentElement<{
20
+ children?: ReactNode;
21
+ store?: jotai_vanilla_internals.INTERNAL_Store;
22
+ }>;
10
23
  declare function useFlags(): {
11
24
  isEnabled: (key: string) => FlagState;
12
25
  fetchAllFlags: () => Promise<void> | undefined;
@@ -14,4 +27,4 @@ declare function useFlags(): {
14
27
  refresh: (forceClear?: boolean) => void;
15
28
  };
16
29
 
17
- export { FlagState, FlagsConfig, FlagsProvider, useFlags };
30
+ export { Databuddy, FlagState, FlagsConfig, FlagsProvider, useFlags };
@@ -1,12 +1,25 @@
1
- export { b as Databuddy } from '../shared/@databuddy/sdk.C8T93n5r.js';
1
+ import { D as DatabuddyConfig } from '../shared/@databuddy/sdk.B1NyVg8b.js';
2
+ import * as react from 'react';
2
3
  import { ReactNode } from 'react';
3
- import { d as FlagsConfig, c as FlagState } from '../shared/@databuddy/sdk.YfiY9DoZ.js';
4
- export { b as FlagResult, e as FlagsContext } from '../shared/@databuddy/sdk.YfiY9DoZ.js';
4
+ import * as jotai_vanilla_internals from 'jotai/vanilla/internals';
5
+ import { d as FlagsConfig, c as FlagState } from '../shared/@databuddy/sdk.OK9Nbqlf.js';
6
+ export { b as FlagResult, e as FlagsContext } from '../shared/@databuddy/sdk.OK9Nbqlf.js';
7
+
8
+ /**
9
+ * <Databuddy /> component for Next.js/React apps
10
+ * Injects the databuddy.js script with all config as data attributes
11
+ * Usage: <Databuddy clientId="..." trackScreenViews trackPerformance ... />
12
+ * Or simply: <Databuddy /> (auto-detects clientId from environment variables)
13
+ */
14
+ declare function Databuddy(props: DatabuddyConfig): null;
5
15
 
6
16
  interface FlagsProviderProps extends FlagsConfig {
7
17
  children: ReactNode;
8
18
  }
9
- declare function FlagsProvider({ children, ...config }: FlagsProviderProps): any;
19
+ declare function FlagsProvider({ children, ...config }: FlagsProviderProps): react.FunctionComponentElement<{
20
+ children?: ReactNode;
21
+ store?: jotai_vanilla_internals.INTERNAL_Store;
22
+ }>;
10
23
  declare function useFlags(): {
11
24
  isEnabled: (key: string) => FlagState;
12
25
  fetchAllFlags: () => Promise<void> | undefined;
@@ -14,4 +27,4 @@ declare function useFlags(): {
14
27
  refresh: (forceClear?: boolean) => void;
15
28
  };
16
29
 
17
- export { FlagState, FlagsConfig, FlagsProvider, useFlags };
30
+ export { Databuddy, FlagState, FlagsConfig, FlagsProvider, useFlags };