raindrop-ai 0.0.39 → 0.0.41

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,221 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __esm = (fn, res) => function __init() {
15
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
16
+ };
17
+ var __commonJS = (cb, mod) => function __require2() {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") {
26
+ for (let key of __getOwnPropNames(from))
27
+ if (!__hasOwnProp.call(to, key) && key !== except)
28
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
29
+ }
30
+ return to;
31
+ };
32
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
33
+ // If the importer is in node compatibility mode or this is not an ESM
34
+ // file that has been converted to a CommonJS file using a Babel-
35
+ // compatible transform (i.e. "__esModule" has not been set), then set
36
+ // "default" to the CommonJS "module.exports" for node compatibility.
37
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
38
+ mod
39
+ ));
40
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
42
+
43
+ // src/tracing/noOpSpan.ts
44
+ import {
45
+ TraceFlags
46
+ } from "@opentelemetry/api";
47
+ var INVALID_SPAN_CONTEXT = {
48
+ traceId: "",
49
+ spanId: "",
50
+ traceFlags: TraceFlags.NONE,
51
+ isRemote: false
52
+ };
53
+ var NoOpSpan = class {
54
+ spanContext() {
55
+ return INVALID_SPAN_CONTEXT;
56
+ }
57
+ setAttribute(_key, _value) {
58
+ return this;
59
+ }
60
+ setAttributes(_attributes) {
61
+ return this;
62
+ }
63
+ addEvent(_name, _attributesOrStartTime, _startTime) {
64
+ return this;
65
+ }
66
+ addLink(_link) {
67
+ return this;
68
+ }
69
+ addLinks(_links) {
70
+ return this;
71
+ }
72
+ setStatus(_status) {
73
+ return this;
74
+ }
75
+ updateName(_name) {
76
+ return this;
77
+ }
78
+ end(_endTime) {
79
+ }
80
+ recordException(_exception, _time) {
81
+ }
82
+ isRecording() {
83
+ return false;
84
+ }
85
+ };
86
+ var NO_OP_SPAN = new NoOpSpan();
87
+
88
+ // src/tracing/nonLiveInteraction.ts
89
+ var NonLiveInteraction = class {
90
+ constructor(context, traceId, analytics) {
91
+ this.context = context;
92
+ this.analytics = analytics;
93
+ }
94
+ withSpan(_params, fn, thisArg, ...args) {
95
+ try {
96
+ return Promise.resolve(fn.apply(thisArg, args));
97
+ } catch (error) {
98
+ return Promise.reject(error);
99
+ }
100
+ }
101
+ startSpan(_params) {
102
+ return NO_OP_SPAN;
103
+ }
104
+ setProperties(_properties) {
105
+ var _a;
106
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
107
+ eventId: this.context.eventId,
108
+ properties: _properties
109
+ });
110
+ }
111
+ setProperty(_key, _value) {
112
+ var _a;
113
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
114
+ eventId: this.context.eventId,
115
+ properties: {
116
+ [_key]: _value
117
+ }
118
+ });
119
+ }
120
+ addAttachments(_attachments) {
121
+ var _a;
122
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
123
+ eventId: this.context.eventId,
124
+ attachments: _attachments
125
+ });
126
+ }
127
+ setInput(_input) {
128
+ var _a;
129
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
130
+ eventId: this.context.eventId,
131
+ input: _input
132
+ });
133
+ }
134
+ finish(resultEvent) {
135
+ var _a;
136
+ (_a = this.analytics) == null ? void 0 : _a._trackAiPartial({
137
+ ...resultEvent,
138
+ eventId: this.context.eventId,
139
+ isPending: false
140
+ });
141
+ }
142
+ };
143
+
144
+ // src/tracing/tracer-core.ts
145
+ var getGlobalRegistry = () => {
146
+ if (typeof window !== "undefined") {
147
+ window.__RAINDROP_TRACING_REGISTRY__ = window.__RAINDROP_TRACING_REGISTRY__ || {
148
+ hasRealImplementation: false,
149
+ realImplementation: null
150
+ };
151
+ return window.__RAINDROP_TRACING_REGISTRY__;
152
+ } else if (typeof global !== "undefined") {
153
+ global.__RAINDROP_TRACING_REGISTRY__ = global.__RAINDROP_TRACING_REGISTRY__ || {
154
+ hasRealImplementation: false,
155
+ realImplementation: null
156
+ };
157
+ return global.__RAINDROP_TRACING_REGISTRY__;
158
+ }
159
+ return {
160
+ hasRealImplementation: false,
161
+ realImplementation: null
162
+ };
163
+ };
164
+ var createTracing = (analytics, _apiUrl, _writeKey, _options, isDebug = false) => ({
165
+ begin(traceContext) {
166
+ if (isDebug) {
167
+ console.log("not using traces");
168
+ }
169
+ if (!traceContext.eventId) {
170
+ traceContext.eventId = crypto.randomUUID();
171
+ }
172
+ analytics._trackAiPartial({
173
+ ...traceContext
174
+ });
175
+ return new NonLiveInteraction(
176
+ traceContext,
177
+ void 0,
178
+ // No traceId in stub
179
+ analytics
180
+ );
181
+ },
182
+ getActiveInteraction(eventId) {
183
+ return new NonLiveInteraction({ eventId }, void 0, analytics);
184
+ },
185
+ async close() {
186
+ }
187
+ });
188
+ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
189
+ const registry = getGlobalRegistry();
190
+ if (registry.hasRealImplementation && registry.realImplementation) {
191
+ if (isDebug) {
192
+ console.log("Raindrop: Using real tracing implementation");
193
+ }
194
+ return registry.realImplementation(analytics, apiUrl, writeKey, options, isDebug);
195
+ }
196
+ if (isDebug) {
197
+ console.log("Raindrop: Using stub implementation");
198
+ }
199
+ return createTracing(analytics, apiUrl, writeKey, options, isDebug);
200
+ };
201
+ var _setImplementation = (impl) => {
202
+ const registry = getGlobalRegistry();
203
+ registry.realImplementation = impl;
204
+ registry.hasRealImplementation = true;
205
+ if (typeof process !== "undefined" && process.env.RAINDROP_DEBUG === "true") {
206
+ console.log("Raindrop: Set real implementation in global registry");
207
+ }
208
+ };
209
+
210
+ export {
211
+ __require,
212
+ __esm,
213
+ __commonJS,
214
+ __export,
215
+ __toESM,
216
+ __toCommonJS,
217
+ __publicField,
218
+ NonLiveInteraction,
219
+ tracing,
220
+ _setImplementation
221
+ };
package/dist/index.js CHANGED
@@ -107,7 +107,7 @@ var CategorizationRequestSchema = import_zod.z.object({
107
107
  // package.json
108
108
  var package_default = {
109
109
  name: "raindrop-ai",
110
- version: "0.0.39",
110
+ version: "0.0.41",
111
111
  main: "dist/index.js",
112
112
  module: "dist/index.mjs",
113
113
  types: "dist/index.d.ts",
@@ -148,9 +148,6 @@ var package_default = {
148
148
  weakref: "^0.2.1",
149
149
  zod: "^3.23.8"
150
150
  },
151
- peerDependencies: {
152
- "@traceloop/node-server-sdk": "^0.12.2"
153
- },
154
151
  optionalDependencies: {
155
152
  "@traceloop/node-server-sdk": "^0.12.2"
156
153
  },
@@ -363,6 +360,25 @@ var NonLiveInteraction = class {
363
360
  };
364
361
 
365
362
  // src/tracing/tracer-core.ts
363
+ var getGlobalRegistry = () => {
364
+ if (typeof window !== "undefined") {
365
+ window.__RAINDROP_TRACING_REGISTRY__ = window.__RAINDROP_TRACING_REGISTRY__ || {
366
+ hasRealImplementation: false,
367
+ realImplementation: null
368
+ };
369
+ return window.__RAINDROP_TRACING_REGISTRY__;
370
+ } else if (typeof global !== "undefined") {
371
+ global.__RAINDROP_TRACING_REGISTRY__ = global.__RAINDROP_TRACING_REGISTRY__ || {
372
+ hasRealImplementation: false,
373
+ realImplementation: null
374
+ };
375
+ return global.__RAINDROP_TRACING_REGISTRY__;
376
+ }
377
+ return {
378
+ hasRealImplementation: false,
379
+ realImplementation: null
380
+ };
381
+ };
366
382
  var createTracing = (analytics, _apiUrl, _writeKey, _options, isDebug = false) => ({
367
383
  begin(traceContext) {
368
384
  if (isDebug) {
@@ -384,11 +400,22 @@ var createTracing = (analytics, _apiUrl, _writeKey, _options, isDebug = false) =
384
400
  getActiveInteraction(eventId) {
385
401
  return new NonLiveInteraction({ eventId }, void 0, analytics);
386
402
  },
387
- close() {
403
+ async close() {
388
404
  }
389
405
  });
390
- var implementation = createTracing;
391
- var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => implementation(analytics, apiUrl, writeKey, options, isDebug);
406
+ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
407
+ const registry = getGlobalRegistry();
408
+ if (registry.hasRealImplementation && registry.realImplementation) {
409
+ if (isDebug) {
410
+ console.log("Raindrop: Using real tracing implementation");
411
+ }
412
+ return registry.realImplementation(analytics, apiUrl, writeKey, options, isDebug);
413
+ }
414
+ if (isDebug) {
415
+ console.log("Raindrop: Using stub implementation");
416
+ }
417
+ return createTracing(analytics, apiUrl, writeKey, options, isDebug);
418
+ };
392
419
 
393
420
  // src/types.ts
394
421
  var import_zod2 = require("zod");
@@ -883,6 +910,7 @@ var Raindrop = class {
883
910
  }
884
911
  }
885
912
  async close() {
913
+ await this._tracing.close();
886
914
  await this.flush();
887
915
  if (this.debugLogs) {
888
916
  console.log("[raindrop] Flushing pending partial events before closing...");
@@ -900,7 +928,6 @@ var Raindrop = class {
900
928
  this.partialEventBuffer.clear();
901
929
  this.partialEventTimeouts.forEach(clearTimeout);
902
930
  this.partialEventTimeouts.clear();
903
- this._tracing.close();
904
931
  if (this.debugLogs) {
905
932
  console.log("Closing Raindrop Analytics");
906
933
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "./chunk-45CPPW3B.mjs";
3
+ } from "./chunk-ZKC66DME.mjs";
4
4
 
5
5
  // ../schemas/src/ingest/index.ts
6
6
  import { z } from "zod";
@@ -83,7 +83,7 @@ var CategorizationRequestSchema = z.object({
83
83
  // package.json
84
84
  var package_default = {
85
85
  name: "raindrop-ai",
86
- version: "0.0.39",
86
+ version: "0.0.41",
87
87
  main: "dist/index.js",
88
88
  module: "dist/index.mjs",
89
89
  types: "dist/index.d.ts",
@@ -124,9 +124,6 @@ var package_default = {
124
124
  weakref: "^0.2.1",
125
125
  zod: "^3.23.8"
126
126
  },
127
- peerDependencies: {
128
- "@traceloop/node-server-sdk": "^0.12.2"
129
- },
130
127
  optionalDependencies: {
131
128
  "@traceloop/node-server-sdk": "^0.12.2"
132
129
  },
@@ -732,6 +729,7 @@ var Raindrop = class {
732
729
  }
733
730
  }
734
731
  async close() {
732
+ await this._tracing.close();
735
733
  await this.flush();
736
734
  if (this.debugLogs) {
737
735
  console.log("[raindrop] Flushing pending partial events before closing...");
@@ -749,7 +747,6 @@ var Raindrop = class {
749
747
  this.partialEventBuffer.clear();
750
748
  this.partialEventTimeouts.forEach(clearTimeout);
751
749
  this.partialEventTimeouts.clear();
752
- this._tracing.close();
753
750
  if (this.debugLogs) {
754
751
  console.log("Closing Raindrop Analytics");
755
752
  }
@@ -6,7 +6,7 @@ import '@opentelemetry/api';
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
- close(): void;
9
+ close(): Promise<void>;
10
10
  };
11
11
  declare function initTracing(): void;
12
12
  type Tracing = ReturnType<typeof tracing>;
@@ -6,7 +6,7 @@ import '@opentelemetry/api';
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
- close(): void;
9
+ close(): Promise<void>;
10
10
  };
11
11
  declare function initTracing(): void;
12
12
  type Tracing = ReturnType<typeof tracing>;