raindrop-ai 0.0.43 → 0.0.45

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.
@@ -1819,6 +1819,17 @@ var NonLiveInteraction = class {
1819
1819
  }
1820
1820
  };
1821
1821
 
1822
+ // src/tracing/nonLiveTracer.ts
1823
+ var NoOpTracer = class {
1824
+ withSpan(_params, fn, thisArg, ...args) {
1825
+ try {
1826
+ return Promise.resolve(fn.apply(thisArg, args));
1827
+ } catch (error) {
1828
+ return Promise.reject(error);
1829
+ }
1830
+ }
1831
+ };
1832
+
1822
1833
  // src/tracing/tracer-core.ts
1823
1834
  var getGlobalRegistry = () => {
1824
1835
  if (typeof window !== "undefined") {
@@ -1860,6 +1871,9 @@ var createTracing = (analytics, _apiUrl, _writeKey, _options, isDebug = false) =
1860
1871
  getActiveInteraction(eventId) {
1861
1872
  return new NonLiveInteraction({ eventId }, void 0, analytics);
1862
1873
  },
1874
+ tracer(globalProperties) {
1875
+ return new NoOpTracer();
1876
+ },
1863
1877
  async close() {
1864
1878
  }
1865
1879
  });
@@ -21,6 +21,7 @@ interface TrackEvent {
21
21
  type BasicSignal = {
22
22
  eventId: string;
23
23
  name: "thumbs_up" | "thumbs_down" | string;
24
+ sentiment?: "POSITIVE" | "NEGATIVE";
24
25
  timestamp?: string;
25
26
  properties?: {
26
27
  [key: string]: any;
@@ -93,11 +94,15 @@ type TraceContextOutput = Omit<PartialAiTrackEvent, "eventId"> & {
93
94
  * @property kind - Category of the task (llm, tool, retrival, or internal)
94
95
  * @property properties - Optional key-value pairs for additional metadata
95
96
  * @property inputParameters - Optional array of input parameters for the task
97
+ * @property traceContent - Optional flag to control whether content is traced
98
+ * @property suppressTracing - Optional flag to suppress tracing for this task
96
99
  */
97
100
  interface SpanParams {
98
101
  name: string;
99
102
  properties?: Record<string, string>;
100
103
  inputParameters?: unknown[];
104
+ traceContent?: boolean;
105
+ suppressTracing?: boolean;
101
106
  }
102
107
  /**
103
108
  * Configuration for a traced tool.
@@ -304,6 +309,15 @@ type Interaction = {
304
309
  */
305
310
  finish(resultEvent: TraceContextOutput): void;
306
311
  };
312
+ type Tracer = {
313
+ /**
314
+ * Creates a traced task that executes the provided function.
315
+ *
316
+ * @param params TaskParams object with task configuration
317
+ * @returns A span that can be used to record a task
318
+ */
319
+ withSpan<T>(params: SpanParams, fn: (...args: any[]) => Promise<T> | T, thisArg?: any, ...args: any[]): Promise<T>;
320
+ };
307
321
 
308
322
  interface AnalyticsConfig {
309
323
  writeKey: string;
@@ -339,6 +353,15 @@ declare class Raindrop {
339
353
  event: string;
340
354
  userId: string;
341
355
  }): Interaction;
356
+ /**
357
+ * Returns a tracer object that can be used to create spans and tools that aren't tied to any interaction.
358
+ * For chat interaction use-case `begin` should be used.
359
+ * This is meant for batch jobs or other non-interactive use-cases where you only care about tracing and token usage.
360
+ *
361
+ * @param globalProperties - Optional global properties to be associated with all spans and tools.
362
+ * @returns The tracer object.
363
+ */
364
+ tracer(globalProperties?: Record<string, string>): Tracer;
342
365
  /**
343
366
  * Resumes an existing interaction.
344
367
  *
@@ -399,4 +422,4 @@ declare class Raindrop {
399
422
  close(): Promise<void>;
400
423
  }
401
424
 
402
- export { type Interaction as I, MAX_INGEST_SIZE_BYTES as M, type PartialAiTrackEvent as P, Raindrop as R };
425
+ export { type Interaction as I, MAX_INGEST_SIZE_BYTES as M, type PartialAiTrackEvent as P, Raindrop as R, type Tracer as T };
@@ -21,6 +21,7 @@ interface TrackEvent {
21
21
  type BasicSignal = {
22
22
  eventId: string;
23
23
  name: "thumbs_up" | "thumbs_down" | string;
24
+ sentiment?: "POSITIVE" | "NEGATIVE";
24
25
  timestamp?: string;
25
26
  properties?: {
26
27
  [key: string]: any;
@@ -93,11 +94,15 @@ type TraceContextOutput = Omit<PartialAiTrackEvent, "eventId"> & {
93
94
  * @property kind - Category of the task (llm, tool, retrival, or internal)
94
95
  * @property properties - Optional key-value pairs for additional metadata
95
96
  * @property inputParameters - Optional array of input parameters for the task
97
+ * @property traceContent - Optional flag to control whether content is traced
98
+ * @property suppressTracing - Optional flag to suppress tracing for this task
96
99
  */
97
100
  interface SpanParams {
98
101
  name: string;
99
102
  properties?: Record<string, string>;
100
103
  inputParameters?: unknown[];
104
+ traceContent?: boolean;
105
+ suppressTracing?: boolean;
101
106
  }
102
107
  /**
103
108
  * Configuration for a traced tool.
@@ -304,6 +309,15 @@ type Interaction = {
304
309
  */
305
310
  finish(resultEvent: TraceContextOutput): void;
306
311
  };
312
+ type Tracer = {
313
+ /**
314
+ * Creates a traced task that executes the provided function.
315
+ *
316
+ * @param params TaskParams object with task configuration
317
+ * @returns A span that can be used to record a task
318
+ */
319
+ withSpan<T>(params: SpanParams, fn: (...args: any[]) => Promise<T> | T, thisArg?: any, ...args: any[]): Promise<T>;
320
+ };
307
321
 
308
322
  interface AnalyticsConfig {
309
323
  writeKey: string;
@@ -339,6 +353,15 @@ declare class Raindrop {
339
353
  event: string;
340
354
  userId: string;
341
355
  }): Interaction;
356
+ /**
357
+ * Returns a tracer object that can be used to create spans and tools that aren't tied to any interaction.
358
+ * For chat interaction use-case `begin` should be used.
359
+ * This is meant for batch jobs or other non-interactive use-cases where you only care about tracing and token usage.
360
+ *
361
+ * @param globalProperties - Optional global properties to be associated with all spans and tools.
362
+ * @returns The tracer object.
363
+ */
364
+ tracer(globalProperties?: Record<string, string>): Tracer;
342
365
  /**
343
366
  * Resumes an existing interaction.
344
367
  *
@@ -399,4 +422,4 @@ declare class Raindrop {
399
422
  close(): Promise<void>;
400
423
  }
401
424
 
402
- export { type Interaction as I, MAX_INGEST_SIZE_BYTES as M, type PartialAiTrackEvent as P, Raindrop as R };
425
+ export { type Interaction as I, MAX_INGEST_SIZE_BYTES as M, type PartialAiTrackEvent as P, Raindrop as R, type Tracer as T };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-CPL3oZVf.mjs';
1
+ export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-gF5ZqfKW.mjs';
2
2
  import '@dawn/schemas/ingest';
3
3
  import '@opentelemetry/api';
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-CPL3oZVf.js';
1
+ export { M as MAX_INGEST_SIZE_BYTES, R as Raindrop, R as default } from './index-gF5ZqfKW.js';
2
2
  import '@dawn/schemas/ingest';
3
3
  import '@opentelemetry/api';
package/dist/index.js CHANGED
@@ -86,8 +86,9 @@ var SignalEventSchema = import_zod.z.object({
86
86
  event_id: import_zod.z.string(),
87
87
  signal_name: import_zod.z.string(),
88
88
  timestamp: import_zod.z.coerce.date().optional(),
89
- properties: import_zod.z.record(import_zod.z.any()).optional(),
90
- attachment_id: import_zod.z.string().optional(),
89
+ properties: import_zod.z.record(import_zod.z.any()).optional().nullable(),
90
+ attachment_id: import_zod.z.string().optional().nullable(),
91
+ sentiment: import_zod.z.enum(["POSITIVE", "NEGATIVE"]).optional().nullable(),
91
92
  signal_type: import_zod.z.enum(["default", "feedback", "edit", "standard"]).default("default")
92
93
  });
93
94
  var LegacyAiTrackEventSchema = TrackEventSchema.extend({
@@ -107,7 +108,7 @@ var CategorizationRequestSchema = import_zod.z.object({
107
108
  // package.json
108
109
  var package_default = {
109
110
  name: "raindrop-ai",
110
- version: "0.0.43",
111
+ version: "0.0.45",
111
112
  main: "dist/index.js",
112
113
  module: "dist/index.mjs",
113
114
  types: "dist/index.d.ts",
@@ -370,6 +371,17 @@ var NonLiveInteraction = class {
370
371
  }
371
372
  };
372
373
 
374
+ // src/tracing/nonLiveTracer.ts
375
+ var NoOpTracer = class {
376
+ withSpan(_params, fn, thisArg, ...args) {
377
+ try {
378
+ return Promise.resolve(fn.apply(thisArg, args));
379
+ } catch (error) {
380
+ return Promise.reject(error);
381
+ }
382
+ }
383
+ };
384
+
373
385
  // src/tracing/tracer-core.ts
374
386
  var getGlobalRegistry = () => {
375
387
  if (typeof window !== "undefined") {
@@ -411,6 +423,9 @@ var createTracing = (analytics, _apiUrl, _writeKey, _options, isDebug = false) =
411
423
  getActiveInteraction(eventId) {
412
424
  return new NonLiveInteraction({ eventId }, void 0, analytics);
413
425
  },
426
+ tracer(globalProperties) {
427
+ return new NoOpTracer();
428
+ },
414
429
  async close() {
415
430
  }
416
431
  });
@@ -508,6 +523,17 @@ var Raindrop = class {
508
523
  begin(traceContext) {
509
524
  return this._tracing.begin(traceContext);
510
525
  }
526
+ /**
527
+ * Returns a tracer object that can be used to create spans and tools that aren't tied to any interaction.
528
+ * For chat interaction use-case `begin` should be used.
529
+ * This is meant for batch jobs or other non-interactive use-cases where you only care about tracing and token usage.
530
+ *
531
+ * @param globalProperties - Optional global properties to be associated with all spans and tools.
532
+ * @returns The tracer object.
533
+ */
534
+ tracer(globalProperties) {
535
+ return this._tracing.tracer(globalProperties);
536
+ }
511
537
  /**
512
538
  * Resumes an existing interaction.
513
539
  *
@@ -621,6 +647,7 @@ var Raindrop = class {
621
647
  event_id: s.eventId,
622
648
  signal_name: s.name,
623
649
  timestamp: s.timestamp,
650
+ sentiment: s.sentiment,
624
651
  properties: {
625
652
  ...s.properties,
626
653
  ..."comment" in s ? { comment: s.comment } : {},
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "./chunk-UQBASHHQ.mjs";
3
+ } from "./chunk-BCJTP4MY.mjs";
4
4
 
5
5
  // ../schemas/src/ingest/index.ts
6
6
  import { z } from "zod";
@@ -62,8 +62,9 @@ var SignalEventSchema = z.object({
62
62
  event_id: z.string(),
63
63
  signal_name: z.string(),
64
64
  timestamp: z.coerce.date().optional(),
65
- properties: z.record(z.any()).optional(),
66
- attachment_id: z.string().optional(),
65
+ properties: z.record(z.any()).optional().nullable(),
66
+ attachment_id: z.string().optional().nullable(),
67
+ sentiment: z.enum(["POSITIVE", "NEGATIVE"]).optional().nullable(),
67
68
  signal_type: z.enum(["default", "feedback", "edit", "standard"]).default("default")
68
69
  });
69
70
  var LegacyAiTrackEventSchema = TrackEventSchema.extend({
@@ -83,7 +84,7 @@ var CategorizationRequestSchema = z.object({
83
84
  // package.json
84
85
  var package_default = {
85
86
  name: "raindrop-ai",
86
- version: "0.0.43",
87
+ version: "0.0.45",
87
88
  main: "dist/index.js",
88
89
  module: "dist/index.mjs",
89
90
  types: "dist/index.d.ts",
@@ -314,6 +315,17 @@ var Raindrop = class {
314
315
  begin(traceContext) {
315
316
  return this._tracing.begin(traceContext);
316
317
  }
318
+ /**
319
+ * Returns a tracer object that can be used to create spans and tools that aren't tied to any interaction.
320
+ * For chat interaction use-case `begin` should be used.
321
+ * This is meant for batch jobs or other non-interactive use-cases where you only care about tracing and token usage.
322
+ *
323
+ * @param globalProperties - Optional global properties to be associated with all spans and tools.
324
+ * @returns The tracer object.
325
+ */
326
+ tracer(globalProperties) {
327
+ return this._tracing.tracer(globalProperties);
328
+ }
317
329
  /**
318
330
  * Resumes an existing interaction.
319
331
  *
@@ -427,6 +439,7 @@ var Raindrop = class {
427
439
  event_id: s.eventId,
428
440
  signal_name: s.name,
429
441
  timestamp: s.timestamp,
442
+ sentiment: s.sentiment,
430
443
  properties: {
431
444
  ...s.properties,
432
445
  ..."comment" in s ? { comment: s.comment } : {},
@@ -1,11 +1,12 @@
1
1
  import * as traceloop from '@traceloop/node-server-sdk';
2
- import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction } from '../index-CPL3oZVf.mjs';
2
+ import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction, T as Tracer } from '../index-gF5ZqfKW.mjs';
3
3
  import '@dawn/schemas/ingest';
4
4
  import '@opentelemetry/api';
5
5
 
6
6
  declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, options: traceloop.InitializeOptions, isDebug?: boolean) => {
7
7
  begin(traceContext: PartialAiTrackEvent): Interaction;
8
8
  getActiveInteraction(eventId: string): Interaction;
9
+ tracer(globalProperties?: Record<string, string>): Tracer;
9
10
  close(): Promise<void>;
10
11
  };
11
12
  declare function initTracing(): void;
@@ -1,11 +1,12 @@
1
1
  import * as traceloop from '@traceloop/node-server-sdk';
2
- import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction } from '../index-CPL3oZVf.js';
2
+ import { R as Raindrop, P as PartialAiTrackEvent, I as Interaction, T as Tracer } from '../index-gF5ZqfKW.js';
3
3
  import '@dawn/schemas/ingest';
4
4
  import '@opentelemetry/api';
5
5
 
6
6
  declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, options: traceloop.InitializeOptions, isDebug?: boolean) => {
7
7
  begin(traceContext: PartialAiTrackEvent): Interaction;
8
8
  getActiveInteraction(eventId: string): Interaction;
9
+ tracer(globalProperties?: Record<string, string>): Tracer;
9
10
  close(): Promise<void>;
10
11
  };
11
12
  declare function initTracing(): void;
@@ -147578,7 +147578,9 @@ var LiveInteraction = class {
147578
147578
  {
147579
147579
  name: taskName,
147580
147580
  associationProperties: properties,
147581
- inputParameters
147581
+ inputParameters,
147582
+ traceContent: params.traceContent,
147583
+ suppressTracing: params.suppressTracing
147582
147584
  },
147583
147585
  fn,
147584
147586
  thisArg,
@@ -147664,6 +147666,35 @@ var LiveInteraction = class {
147664
147666
  }
147665
147667
  };
147666
147668
 
147669
+ // src/tracing/liveTracer.ts
147670
+ var LiveTracer = class {
147671
+ constructor(globalProperties) {
147672
+ this.globalProperties = globalProperties || {};
147673
+ }
147674
+ async withSpan(params, fn, thisArg, ...args) {
147675
+ const taskName = typeof params === "string" ? params : params.name;
147676
+ const properties = typeof params === "string" ? {
147677
+ ...this.globalProperties
147678
+ } : {
147679
+ ...this.globalProperties,
147680
+ ...params.properties || {}
147681
+ };
147682
+ const inputParameters = typeof params === "string" ? void 0 : params.inputParameters;
147683
+ return withTask(
147684
+ {
147685
+ name: taskName,
147686
+ associationProperties: properties,
147687
+ inputParameters,
147688
+ traceContent: params.traceContent,
147689
+ suppressTracing: params.suppressTracing
147690
+ },
147691
+ fn,
147692
+ thisArg,
147693
+ ...args
147694
+ );
147695
+ }
147696
+ };
147697
+
147667
147698
  // src/tracing/noOpSpan.ts
147668
147699
  init_esm();
147669
147700
  var INVALID_SPAN_CONTEXT2 = {
@@ -147841,6 +147872,9 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
147841
147872
  }
147842
147873
  return activeInteractions.get(traceId) || new NonLiveInteraction({ eventId }, void 0, analytics);
147843
147874
  },
147875
+ tracer(globalProperties) {
147876
+ return new LiveTracer(globalProperties);
147877
+ },
147844
147878
  async close() {
147845
147879
  activeInteractions.clear();
147846
147880
  await forceFlush();
@@ -29,7 +29,7 @@ import {
29
29
  metrics,
30
30
  propagation,
31
31
  trace
32
- } from "../chunk-UQBASHHQ.mjs";
32
+ } from "../chunk-BCJTP4MY.mjs";
33
33
 
34
34
  // ../../node_modules/@opentelemetry/sdk-node/node_modules/@opentelemetry/core/build/esm/trace/suppress-tracing.js
35
35
  function suppressTracing(context2) {
@@ -145893,7 +145893,9 @@ var LiveInteraction = class {
145893
145893
  {
145894
145894
  name: taskName,
145895
145895
  associationProperties: properties,
145896
- inputParameters
145896
+ inputParameters,
145897
+ traceContent: params.traceContent,
145898
+ suppressTracing: params.suppressTracing
145897
145899
  },
145898
145900
  fn,
145899
145901
  thisArg,
@@ -145979,6 +145981,35 @@ var LiveInteraction = class {
145979
145981
  }
145980
145982
  };
145981
145983
 
145984
+ // src/tracing/liveTracer.ts
145985
+ var LiveTracer = class {
145986
+ constructor(globalProperties) {
145987
+ this.globalProperties = globalProperties || {};
145988
+ }
145989
+ async withSpan(params, fn, thisArg, ...args) {
145990
+ const taskName = typeof params === "string" ? params : params.name;
145991
+ const properties = typeof params === "string" ? {
145992
+ ...this.globalProperties
145993
+ } : {
145994
+ ...this.globalProperties,
145995
+ ...params.properties || {}
145996
+ };
145997
+ const inputParameters = typeof params === "string" ? void 0 : params.inputParameters;
145998
+ return withTask(
145999
+ {
146000
+ name: taskName,
146001
+ associationProperties: properties,
146002
+ inputParameters,
146003
+ traceContent: params.traceContent,
146004
+ suppressTracing: params.suppressTracing
146005
+ },
146006
+ fn,
146007
+ thisArg,
146008
+ ...args
146009
+ );
146010
+ }
146011
+ };
146012
+
145982
146013
  // src/tracing/index.ts
145983
146014
  var activeInteractions = new WeakValueMap();
145984
146015
  function getCurrentTraceId() {
@@ -146021,6 +146052,9 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
146021
146052
  }
146022
146053
  return activeInteractions.get(traceId) || new NonLiveInteraction({ eventId }, void 0, analytics);
146023
146054
  },
146055
+ tracer(globalProperties) {
146056
+ return new LiveTracer(globalProperties);
146057
+ },
146024
146058
  async close() {
146025
146059
  activeInteractions.clear();
146026
146060
  await forceFlush();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raindrop-ai",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -60,4 +60,4 @@
60
60
  "dts": true,
61
61
  "clean": true
62
62
  }
63
- }
63
+ }