raindrop-ai 0.1.5 → 0.1.6-otelv2

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.
@@ -377,7 +377,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
377
377
  // package.json
378
378
  var package_default = {
379
379
  name: "raindrop-ai",
380
- version: "0.1.5",
380
+ version: "0.1.6",
381
381
  main: "dist/index.js",
382
382
  module: "dist/index.mjs",
383
383
  types: "dist/index.d.ts",
@@ -1499,20 +1499,34 @@ var LiveInteraction = class {
1499
1499
  return this.context.eventId;
1500
1500
  }
1501
1501
  async finish(resultEvent) {
1502
- var _a, _b;
1502
+ var _a, _b, _c, _d;
1503
1503
  if (!this.traceId) {
1504
1504
  this.resolveLiveTraceId();
1505
1505
  }
1506
+ const spanFlush = (async () => {
1507
+ var _a2;
1508
+ try {
1509
+ await ((_a2 = this.analytics) == null ? void 0 : _a2._flushTracingSpans());
1510
+ } catch (e) {
1511
+ }
1512
+ })();
1513
+ if ((_b = (_a = this.analytics) == null ? void 0 : _a._shouldBlockFinishFlush()) != null ? _b : true) {
1514
+ await spanFlush;
1515
+ } else {
1516
+ void spanFlush.catch(() => {
1517
+ });
1518
+ }
1519
+ const eventId = resultEvent.eventId || this.context.eventId;
1506
1520
  try {
1507
- await ((_a = this.analytics) == null ? void 0 : _a.forceFlush());
1521
+ await ((_c = this.analytics) == null ? void 0 : _c._drainInFlightPartials(eventId));
1508
1522
  } catch (e) {
1509
1523
  }
1510
1524
  if (this.traceId) {
1511
1525
  this.setProperty("trace_id", this.traceId);
1512
1526
  }
1513
- await ((_b = this.analytics) == null ? void 0 : _b._trackAiPartial({
1527
+ await ((_d = this.analytics) == null ? void 0 : _d._trackAiPartial({
1514
1528
  ...resultEvent,
1515
- eventId: resultEvent.eventId || this.context.eventId,
1529
+ eventId,
1516
1530
  isPending: false
1517
1531
  }));
1518
1532
  }
@@ -2192,6 +2206,10 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2192
2206
  baseUrl: apiUrl,
2193
2207
  apiKey: writeKey,
2194
2208
  logLevel,
2209
+ // Traceloop's init banner ("Traceloop exporting traces to <baseUrl>") is
2210
+ // misleading inside our wrapper: in external-OTEL mode we create no
2211
+ // exporter at all (tracingEnabled: false). Suppress it.
2212
+ silenceInitializationMessage: true,
2195
2213
  tracingEnabled: false
2196
2214
  // DO NOT create NodeSDK - customer has their own
2197
2215
  });
@@ -2222,6 +2240,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2222
2240
  apiKey: writeKey,
2223
2241
  ...otherOptions,
2224
2242
  logLevel,
2243
+ silenceInitializationMessage: true,
2225
2244
  tracingEnabled: tracingEnabled !== false,
2226
2245
  disableBatch: disableBatching,
2227
2246
  processor: localDebuggerProcessor
@@ -2232,6 +2251,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2232
2251
  baseUrl: apiUrl,
2233
2252
  apiKey: writeKey,
2234
2253
  logLevel,
2254
+ silenceInitializationMessage: true,
2235
2255
  tracingEnabled: false
2236
2256
  });
2237
2257
  traceloopInitialized = true;
@@ -2247,6 +2267,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2247
2267
  apiKey: writeKey,
2248
2268
  ...otherOptions,
2249
2269
  logLevel,
2270
+ silenceInitializationMessage: true,
2250
2271
  tracingEnabled: tracingEnabled !== false,
2251
2272
  disableBatch: disableBatching,
2252
2273
  ...processor ? { processor } : {},
package/dist/index.d.mts CHANGED
@@ -827,6 +827,26 @@ interface AnalyticsConfig {
827
827
  * @default false
828
828
  */
829
829
  bypassOtelForTools?: boolean;
830
+ /**
831
+ * Whether `interaction.finish()` should await the in-flight span/trace flush
832
+ * (i.e. `forceFlush()`, which drains buffered OTLP/tool spans — a `/v1/traces`
833
+ * POST with retries) before resolving. This await was added so a local
834
+ * Workshop daemon doesn't race OTLP ingest; in cloud mode it only adds
835
+ * request latency.
836
+ *
837
+ * Note this gates *only* the span flush. `finish()` always awaits the
838
+ * terminal partial-event POST that records the run, and always orders it
839
+ * after any earlier in-flight POST for the same eventId — to skip the
840
+ * partial POST too, simply don't `await interaction.finish(...)`.
841
+ *
842
+ * - `true` / `undefined` (default) — await the span/trace flush, preserving
843
+ * the historical guaranteed-flush-before-return behavior.
844
+ * - `false` — don't await it; it drains in the background so the caller's
845
+ * request isn't taxed by the round trip + retries. A local Workshop /
846
+ * debugger still forces the await regardless (its read-after-write
847
+ * guarantee depends on it).
848
+ */
849
+ awaitSpanFlush?: boolean;
830
850
  /**
831
851
  * Explicitly specify modules to instrument. Optional.
832
852
  *
@@ -875,9 +895,11 @@ declare class Raindrop {
875
895
  private context;
876
896
  private _tracing;
877
897
  private localDebuggerUrlOpt;
898
+ private awaitSpanFlushOpt;
878
899
  private partialEventBuffer;
879
900
  private partialEventTimeouts;
880
901
  private inFlightRequests;
902
+ private inFlightByEvent;
881
903
  private maxTextFieldChars;
882
904
  private projectId;
883
905
  /**
package/dist/index.d.ts CHANGED
@@ -827,6 +827,26 @@ interface AnalyticsConfig {
827
827
  * @default false
828
828
  */
829
829
  bypassOtelForTools?: boolean;
830
+ /**
831
+ * Whether `interaction.finish()` should await the in-flight span/trace flush
832
+ * (i.e. `forceFlush()`, which drains buffered OTLP/tool spans — a `/v1/traces`
833
+ * POST with retries) before resolving. This await was added so a local
834
+ * Workshop daemon doesn't race OTLP ingest; in cloud mode it only adds
835
+ * request latency.
836
+ *
837
+ * Note this gates *only* the span flush. `finish()` always awaits the
838
+ * terminal partial-event POST that records the run, and always orders it
839
+ * after any earlier in-flight POST for the same eventId — to skip the
840
+ * partial POST too, simply don't `await interaction.finish(...)`.
841
+ *
842
+ * - `true` / `undefined` (default) — await the span/trace flush, preserving
843
+ * the historical guaranteed-flush-before-return behavior.
844
+ * - `false` — don't await it; it drains in the background so the caller's
845
+ * request isn't taxed by the round trip + retries. A local Workshop /
846
+ * debugger still forces the await regardless (its read-after-write
847
+ * guarantee depends on it).
848
+ */
849
+ awaitSpanFlush?: boolean;
830
850
  /**
831
851
  * Explicitly specify modules to instrument. Optional.
832
852
  *
@@ -875,9 +895,11 @@ declare class Raindrop {
875
895
  private context;
876
896
  private _tracing;
877
897
  private localDebuggerUrlOpt;
898
+ private awaitSpanFlushOpt;
878
899
  private partialEventBuffer;
879
900
  private partialEventTimeouts;
880
901
  private inFlightRequests;
902
+ private inFlightByEvent;
881
903
  private maxTextFieldChars;
882
904
  private projectId;
883
905
  /**
package/dist/index.js CHANGED
@@ -10255,7 +10255,7 @@ var SignalEventSchema = external_exports.object({
10255
10255
  // package.json
10256
10256
  var package_default = {
10257
10257
  name: "raindrop-ai",
10258
- version: "0.1.5",
10258
+ version: "0.1.6",
10259
10259
  main: "dist/index.js",
10260
10260
  module: "dist/index.mjs",
10261
10261
  types: "dist/index.d.ts",
@@ -11457,20 +11457,34 @@ var LiveInteraction = class {
11457
11457
  return this.context.eventId;
11458
11458
  }
11459
11459
  async finish(resultEvent) {
11460
- var _a, _b;
11460
+ var _a, _b, _c, _d;
11461
11461
  if (!this.traceId) {
11462
11462
  this.resolveLiveTraceId();
11463
11463
  }
11464
+ const spanFlush = (async () => {
11465
+ var _a2;
11466
+ try {
11467
+ await ((_a2 = this.analytics) == null ? void 0 : _a2._flushTracingSpans());
11468
+ } catch (e) {
11469
+ }
11470
+ })();
11471
+ if ((_b = (_a = this.analytics) == null ? void 0 : _a._shouldBlockFinishFlush()) != null ? _b : true) {
11472
+ await spanFlush;
11473
+ } else {
11474
+ void spanFlush.catch(() => {
11475
+ });
11476
+ }
11477
+ const eventId = resultEvent.eventId || this.context.eventId;
11464
11478
  try {
11465
- await ((_a = this.analytics) == null ? void 0 : _a.forceFlush());
11479
+ await ((_c = this.analytics) == null ? void 0 : _c._drainInFlightPartials(eventId));
11466
11480
  } catch (e) {
11467
11481
  }
11468
11482
  if (this.traceId) {
11469
11483
  this.setProperty("trace_id", this.traceId);
11470
11484
  }
11471
- await ((_b = this.analytics) == null ? void 0 : _b._trackAiPartial({
11485
+ await ((_d = this.analytics) == null ? void 0 : _d._trackAiPartial({
11472
11486
  ...resultEvent,
11473
- eventId: resultEvent.eventId || this.context.eventId,
11487
+ eventId,
11474
11488
  isPending: false
11475
11489
  }));
11476
11490
  }
@@ -12150,6 +12164,10 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12150
12164
  baseUrl: apiUrl,
12151
12165
  apiKey: writeKey,
12152
12166
  logLevel,
12167
+ // Traceloop's init banner ("Traceloop exporting traces to <baseUrl>") is
12168
+ // misleading inside our wrapper: in external-OTEL mode we create no
12169
+ // exporter at all (tracingEnabled: false). Suppress it.
12170
+ silenceInitializationMessage: true,
12153
12171
  tracingEnabled: false
12154
12172
  // DO NOT create NodeSDK - customer has their own
12155
12173
  });
@@ -12180,6 +12198,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12180
12198
  apiKey: writeKey,
12181
12199
  ...otherOptions,
12182
12200
  logLevel,
12201
+ silenceInitializationMessage: true,
12183
12202
  tracingEnabled: tracingEnabled !== false,
12184
12203
  disableBatch: disableBatching,
12185
12204
  processor: localDebuggerProcessor
@@ -12190,6 +12209,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12190
12209
  baseUrl: apiUrl,
12191
12210
  apiKey: writeKey,
12192
12211
  logLevel,
12212
+ silenceInitializationMessage: true,
12193
12213
  tracingEnabled: false
12194
12214
  });
12195
12215
  traceloopInitialized = true;
@@ -12205,6 +12225,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12205
12225
  apiKey: writeKey,
12206
12226
  ...otherOptions,
12207
12227
  logLevel,
12228
+ silenceInitializationMessage: true,
12208
12229
  tracingEnabled: tracingEnabled !== false,
12209
12230
  disableBatch: disableBatching,
12210
12231
  ...processor ? { processor } : {},
@@ -12588,6 +12609,9 @@ var Raindrop = class {
12588
12609
  this.partialEventBuffer = /* @__PURE__ */ new Map();
12589
12610
  this.partialEventTimeouts = /* @__PURE__ */ new Map();
12590
12611
  this.inFlightRequests = /* @__PURE__ */ new Set();
12612
+ // In-flight partial-event POSTs grouped by eventId, so finish() can order its
12613
+ // terminal POST after only that event's earlier POSTs (not unrelated ones).
12614
+ this.inFlightByEvent = /* @__PURE__ */ new Map();
12591
12615
  /**
12592
12616
  * Set once `close()` begins and never cleared. Sends issued after the
12593
12617
  * drain window (stragglers, or flush work the deadline abandoned
@@ -12600,6 +12624,7 @@ var Raindrop = class {
12600
12624
  this.maxTextFieldChars = resolveMaxTextFieldChars(config.maxTextFieldChars);
12601
12625
  this.writeKey = (_a = config.writeKey) != null ? _a : "";
12602
12626
  this.localDebuggerUrlOpt = config.localWorkshopUrl === false ? null : config.localWorkshopUrl;
12627
+ this.awaitSpanFlushOpt = config.awaitSpanFlush;
12603
12628
  this.apiUrl = (_b = this.formatEndpoint(config.endpoint)) != null ? _b : `https://api.raindrop.ai/v1/`;
12604
12629
  this.bufferSize = (_c = config.bufferSize) != null ? _c : 50;
12605
12630
  this.bufferTimeout = (_d = config.bufferTimeout) != null ? _d : 1e3;
@@ -13240,6 +13265,12 @@ var Raindrop = class {
13240
13265
  async flushPartialEvent(eventId) {
13241
13266
  const flushPromise = this._flushPartialEventInternal(eventId);
13242
13267
  this.inFlightRequests.add(flushPromise);
13268
+ let perEvent = this.inFlightByEvent.get(eventId);
13269
+ if (!perEvent) {
13270
+ perEvent = /* @__PURE__ */ new Set();
13271
+ this.inFlightByEvent.set(eventId, perEvent);
13272
+ }
13273
+ perEvent.add(flushPromise);
13243
13274
  try {
13244
13275
  await flushPromise;
13245
13276
  } catch (error) {
@@ -13252,6 +13283,8 @@ var Raindrop = class {
13252
13283
  );
13253
13284
  } finally {
13254
13285
  this.inFlightRequests.delete(flushPromise);
13286
+ perEvent.delete(flushPromise);
13287
+ if (perEvent.size === 0) this.inFlightByEvent.delete(eventId);
13255
13288
  }
13256
13289
  }
13257
13290
  /**
@@ -13410,13 +13443,48 @@ var Raindrop = class {
13410
13443
  * Safe to call multiple times; never throws.
13411
13444
  */
13412
13445
  async forceFlush() {
13446
+ await this._flushTracingSpans();
13447
+ await this._drainInFlightPartials();
13448
+ }
13449
+ /**
13450
+ * Best-effort drain of buffered OTel/tool spans (traceloop + direct shipper).
13451
+ * This is the round-trip-heavy part of `forceFlush()` (e.g. the `/v1/traces`
13452
+ * POST with retries); kept separate so `finish()` can background it.
13453
+ * @internal
13454
+ */
13455
+ async _flushTracingSpans() {
13413
13456
  try {
13414
13457
  await this._tracing.forceFlush();
13415
13458
  } catch (e) {
13416
13459
  }
13417
- if (this.inFlightRequests.size > 0) {
13418
- await Promise.allSettled(Array.from(this.inFlightRequests));
13460
+ }
13461
+ /**
13462
+ * Wait for already-issued partial-event POSTs to settle. Used to order the
13463
+ * terminal partial-event POST after any earlier in-flight POST for the same
13464
+ * eventId so they can't be ingested out of order. Pass `eventId` to wait only
13465
+ * on that event's POSTs (what `finish()` needs); omit it to drain all.
13466
+ * @internal
13467
+ */
13468
+ async _drainInFlightPartials(eventId) {
13469
+ const pending = eventId !== void 0 ? this.inFlightByEvent.get(eventId) : this.inFlightRequests;
13470
+ if (pending && pending.size > 0) {
13471
+ await Promise.allSettled(Array.from(pending));
13472
+ }
13473
+ }
13474
+ /**
13475
+ * Whether `interaction.finish()` should await the in-flight span/trace flush
13476
+ * before resolving. Blocks by default (preserving the historical behavior);
13477
+ * callers opt out with `awaitSpanFlush: false`. A local Workshop/debugger
13478
+ * always forces the await (its read-after-write guarantee depends on it),
13479
+ * even when `awaitSpanFlush: false`. The terminal partial-event POST is
13480
+ * always awaited by `finish()`, independent of this.
13481
+ * @internal
13482
+ */
13483
+ _shouldBlockFinishFlush() {
13484
+ if (resolveLocalDebuggerBaseUrl(this.localDebuggerUrlOpt) !== null) {
13485
+ return true;
13419
13486
  }
13487
+ return this.awaitSpanFlushOpt !== false;
13420
13488
  }
13421
13489
  async close() {
13422
13490
  this.hasShutdown = true;
@@ -13476,6 +13544,7 @@ var Raindrop = class {
13476
13544
  this.partialEventTimeouts.forEach(clearTimeout);
13477
13545
  this.partialEventTimeouts.clear();
13478
13546
  this.inFlightRequests.clear();
13547
+ this.inFlightByEvent.clear();
13479
13548
  if (this.debugLogs) {
13480
13549
  console.log("[raindrop] Closing Raindrop Analytics");
13481
13550
  }
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  setDefaultMaxTextFieldChars,
17
17
  stringifyBounded,
18
18
  tracing
19
- } from "./chunk-5TO4YOAA.mjs";
19
+ } from "./chunk-IRFBHPGQ.mjs";
20
20
  import {
21
21
  __commonJS,
22
22
  __toESM
@@ -10138,6 +10138,9 @@ var Raindrop = class {
10138
10138
  this.partialEventBuffer = /* @__PURE__ */ new Map();
10139
10139
  this.partialEventTimeouts = /* @__PURE__ */ new Map();
10140
10140
  this.inFlightRequests = /* @__PURE__ */ new Set();
10141
+ // In-flight partial-event POSTs grouped by eventId, so finish() can order its
10142
+ // terminal POST after only that event's earlier POSTs (not unrelated ones).
10143
+ this.inFlightByEvent = /* @__PURE__ */ new Map();
10141
10144
  /**
10142
10145
  * Set once `close()` begins and never cleared. Sends issued after the
10143
10146
  * drain window (stragglers, or flush work the deadline abandoned
@@ -10150,6 +10153,7 @@ var Raindrop = class {
10150
10153
  this.maxTextFieldChars = resolveMaxTextFieldChars(config.maxTextFieldChars);
10151
10154
  this.writeKey = (_a = config.writeKey) != null ? _a : "";
10152
10155
  this.localDebuggerUrlOpt = config.localWorkshopUrl === false ? null : config.localWorkshopUrl;
10156
+ this.awaitSpanFlushOpt = config.awaitSpanFlush;
10153
10157
  this.apiUrl = (_b = this.formatEndpoint(config.endpoint)) != null ? _b : `https://api.raindrop.ai/v1/`;
10154
10158
  this.bufferSize = (_c = config.bufferSize) != null ? _c : 50;
10155
10159
  this.bufferTimeout = (_d = config.bufferTimeout) != null ? _d : 1e3;
@@ -10790,6 +10794,12 @@ var Raindrop = class {
10790
10794
  async flushPartialEvent(eventId) {
10791
10795
  const flushPromise = this._flushPartialEventInternal(eventId);
10792
10796
  this.inFlightRequests.add(flushPromise);
10797
+ let perEvent = this.inFlightByEvent.get(eventId);
10798
+ if (!perEvent) {
10799
+ perEvent = /* @__PURE__ */ new Set();
10800
+ this.inFlightByEvent.set(eventId, perEvent);
10801
+ }
10802
+ perEvent.add(flushPromise);
10793
10803
  try {
10794
10804
  await flushPromise;
10795
10805
  } catch (error) {
@@ -10802,6 +10812,8 @@ var Raindrop = class {
10802
10812
  );
10803
10813
  } finally {
10804
10814
  this.inFlightRequests.delete(flushPromise);
10815
+ perEvent.delete(flushPromise);
10816
+ if (perEvent.size === 0) this.inFlightByEvent.delete(eventId);
10805
10817
  }
10806
10818
  }
10807
10819
  /**
@@ -10960,13 +10972,48 @@ var Raindrop = class {
10960
10972
  * Safe to call multiple times; never throws.
10961
10973
  */
10962
10974
  async forceFlush() {
10975
+ await this._flushTracingSpans();
10976
+ await this._drainInFlightPartials();
10977
+ }
10978
+ /**
10979
+ * Best-effort drain of buffered OTel/tool spans (traceloop + direct shipper).
10980
+ * This is the round-trip-heavy part of `forceFlush()` (e.g. the `/v1/traces`
10981
+ * POST with retries); kept separate so `finish()` can background it.
10982
+ * @internal
10983
+ */
10984
+ async _flushTracingSpans() {
10963
10985
  try {
10964
10986
  await this._tracing.forceFlush();
10965
10987
  } catch (e) {
10966
10988
  }
10967
- if (this.inFlightRequests.size > 0) {
10968
- await Promise.allSettled(Array.from(this.inFlightRequests));
10989
+ }
10990
+ /**
10991
+ * Wait for already-issued partial-event POSTs to settle. Used to order the
10992
+ * terminal partial-event POST after any earlier in-flight POST for the same
10993
+ * eventId so they can't be ingested out of order. Pass `eventId` to wait only
10994
+ * on that event's POSTs (what `finish()` needs); omit it to drain all.
10995
+ * @internal
10996
+ */
10997
+ async _drainInFlightPartials(eventId) {
10998
+ const pending = eventId !== void 0 ? this.inFlightByEvent.get(eventId) : this.inFlightRequests;
10999
+ if (pending && pending.size > 0) {
11000
+ await Promise.allSettled(Array.from(pending));
11001
+ }
11002
+ }
11003
+ /**
11004
+ * Whether `interaction.finish()` should await the in-flight span/trace flush
11005
+ * before resolving. Blocks by default (preserving the historical behavior);
11006
+ * callers opt out with `awaitSpanFlush: false`. A local Workshop/debugger
11007
+ * always forces the await (its read-after-write guarantee depends on it),
11008
+ * even when `awaitSpanFlush: false`. The terminal partial-event POST is
11009
+ * always awaited by `finish()`, independent of this.
11010
+ * @internal
11011
+ */
11012
+ _shouldBlockFinishFlush() {
11013
+ if (resolveLocalDebuggerBaseUrl(this.localDebuggerUrlOpt) !== null) {
11014
+ return true;
10969
11015
  }
11016
+ return this.awaitSpanFlushOpt !== false;
10970
11017
  }
10971
11018
  async close() {
10972
11019
  this.hasShutdown = true;
@@ -11026,6 +11073,7 @@ var Raindrop = class {
11026
11073
  this.partialEventTimeouts.forEach(clearTimeout);
11027
11074
  this.partialEventTimeouts.clear();
11028
11075
  this.inFlightRequests.clear();
11076
+ this.inFlightByEvent.clear();
11029
11077
  if (this.debugLogs) {
11030
11078
  console.log("[raindrop] Closing Raindrop Analytics");
11031
11079
  }
@@ -542,7 +542,7 @@ function base64ToHex(base64) {
542
542
  // package.json
543
543
  var package_default = {
544
544
  name: "raindrop-ai",
545
- version: "0.1.5",
545
+ version: "0.1.6",
546
546
  main: "dist/index.js",
547
547
  module: "dist/index.mjs",
548
548
  types: "dist/index.d.ts",
@@ -1489,20 +1489,34 @@ var LiveInteraction = class {
1489
1489
  return this.context.eventId;
1490
1490
  }
1491
1491
  async finish(resultEvent) {
1492
- var _a, _b;
1492
+ var _a, _b, _c, _d;
1493
1493
  if (!this.traceId) {
1494
1494
  this.resolveLiveTraceId();
1495
1495
  }
1496
+ const spanFlush = (async () => {
1497
+ var _a2;
1498
+ try {
1499
+ await ((_a2 = this.analytics) == null ? void 0 : _a2._flushTracingSpans());
1500
+ } catch (e) {
1501
+ }
1502
+ })();
1503
+ if ((_b = (_a = this.analytics) == null ? void 0 : _a._shouldBlockFinishFlush()) != null ? _b : true) {
1504
+ await spanFlush;
1505
+ } else {
1506
+ void spanFlush.catch(() => {
1507
+ });
1508
+ }
1509
+ const eventId = resultEvent.eventId || this.context.eventId;
1496
1510
  try {
1497
- await ((_a = this.analytics) == null ? void 0 : _a.forceFlush());
1511
+ await ((_c = this.analytics) == null ? void 0 : _c._drainInFlightPartials(eventId));
1498
1512
  } catch (e) {
1499
1513
  }
1500
1514
  if (this.traceId) {
1501
1515
  this.setProperty("trace_id", this.traceId);
1502
1516
  }
1503
- await ((_b = this.analytics) == null ? void 0 : _b._trackAiPartial({
1517
+ await ((_d = this.analytics) == null ? void 0 : _d._trackAiPartial({
1504
1518
  ...resultEvent,
1505
- eventId: resultEvent.eventId || this.context.eventId,
1519
+ eventId,
1506
1520
  isPending: false
1507
1521
  }));
1508
1522
  }
@@ -2182,6 +2196,10 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2182
2196
  baseUrl: apiUrl,
2183
2197
  apiKey: writeKey,
2184
2198
  logLevel,
2199
+ // Traceloop's init banner ("Traceloop exporting traces to <baseUrl>") is
2200
+ // misleading inside our wrapper: in external-OTEL mode we create no
2201
+ // exporter at all (tracingEnabled: false). Suppress it.
2202
+ silenceInitializationMessage: true,
2185
2203
  tracingEnabled: false
2186
2204
  // DO NOT create NodeSDK - customer has their own
2187
2205
  });
@@ -2212,6 +2230,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2212
2230
  apiKey: writeKey,
2213
2231
  ...otherOptions,
2214
2232
  logLevel,
2233
+ silenceInitializationMessage: true,
2215
2234
  tracingEnabled: tracingEnabled !== false,
2216
2235
  disableBatch: disableBatching,
2217
2236
  processor: localDebuggerProcessor
@@ -2222,6 +2241,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2222
2241
  baseUrl: apiUrl,
2223
2242
  apiKey: writeKey,
2224
2243
  logLevel,
2244
+ silenceInitializationMessage: true,
2225
2245
  tracingEnabled: false
2226
2246
  });
2227
2247
  traceloopInitialized = true;
@@ -2237,6 +2257,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2237
2257
  apiKey: writeKey,
2238
2258
  ...otherOptions,
2239
2259
  logLevel,
2260
+ silenceInitializationMessage: true,
2240
2261
  tracingEnabled: tracingEnabled !== false,
2241
2262
  disableBatch: disableBatching,
2242
2263
  ...processor ? { processor } : {},
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "../chunk-5TO4YOAA.mjs";
3
+ } from "../chunk-IRFBHPGQ.mjs";
4
4
  import "../chunk-UJCSKKID.mjs";
5
5
 
6
6
  // src/tracing/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raindrop-ai",
3
- "version": "0.1.5",
3
+ "version": "0.1.6-otelv2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -32,9 +32,9 @@
32
32
  "dist/**"
33
33
  ],
34
34
  "devDependencies": {
35
- "ai": "^6.0.0",
36
35
  "@opentelemetry/resources": "^2.0.1",
37
36
  "@types/node": "^20.11.17",
37
+ "ai": "^6.0.0",
38
38
  "msw": "^2.12.8",
39
39
  "tsup": "^8.4.0",
40
40
  "tsx": "^4.20.3",
@@ -42,13 +42,12 @@
42
42
  "vite": "^7.3.2",
43
43
  "vitest": "^4.0.10",
44
44
  "@raindrop-ai/core": "0.0.4",
45
- "@raindrop-ai/redact-pii": "0.1.2",
46
- "@raindrop-ai/schemas": "0.0.1"
45
+ "@raindrop-ai/schemas": "0.0.1",
46
+ "@raindrop-ai/redact-pii": "0.1.2"
47
47
  },
48
48
  "dependencies": {
49
49
  "@opentelemetry/api": "^1.9.0",
50
- "@opentelemetry/exporter-trace-otlp-http": "^0.57.2",
51
- "@traceloop/node-server-sdk": "0.19.0-otel-v1",
50
+ "@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
52
51
  "weakref": "^0.2.1",
53
52
  "zod": "^3.23.8"
54
53
  },
@@ -91,6 +90,9 @@
91
90
  },
92
91
  "clean": true
93
92
  },
93
+ "optionalDependencies": {
94
+ "@traceloop/node-server-sdk": "0.22.2"
95
+ },
94
96
  "scripts": {
95
97
  "build": "tsup",
96
98
  "dev": "tsup --watch",