raindrop-ai 0.1.2 → 0.1.3

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.
@@ -1,4 +1,4 @@
1
- // ../core/dist/chunk-U5HUTMR5.js
1
+ // ../core/dist/chunk-SK6EJEO7.js
2
2
  var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
3
3
  var MAX_RETRY_DELAY_MS = 3e4;
4
4
  function wait(ms) {
@@ -343,6 +343,25 @@ function sendLocalDebuggerLiveEvent(event, options = {}) {
343
343
  ).catch(() => {
344
344
  });
345
345
  }
346
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
347
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
348
+ function isValidProjectIdSlug(value) {
349
+ return PROJECT_ID_SLUG_PATTERN.test(value);
350
+ }
351
+ function normalizeProjectId(raw, opts) {
352
+ if (typeof raw !== "string") return void 0;
353
+ const trimmed = raw.trim();
354
+ if (!trimmed) return void 0;
355
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
356
+ console.warn(
357
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
358
+ );
359
+ }
360
+ return trimmed;
361
+ }
362
+ function projectIdHeaders(projectId) {
363
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
364
+ }
346
365
  var SHUTDOWN_DEADLINE_MS = 1e4;
347
366
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
348
367
  var DEFAULT_REDACT_ATTRIBUTE_KEYS = [
@@ -358,7 +377,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
358
377
  // package.json
359
378
  var package_default = {
360
379
  name: "raindrop-ai",
361
- version: "0.1.2",
380
+ version: "0.1.3",
362
381
  main: "dist/index.js",
363
382
  module: "dist/index.mjs",
364
383
  types: "dist/index.d.ts",
@@ -732,6 +751,7 @@ var DirectTraceShipper = class {
732
751
  this.enabled = (_b = opts.enabled) != null ? _b : true;
733
752
  this.cloudEnabled = (_c = opts.cloudEnabled) != null ? _c : true;
734
753
  this.debug = opts.debug;
754
+ this.projectId = opts.projectId;
735
755
  this.flushIntervalMs = (_d = opts.flushIntervalMs) != null ? _d : 1e3;
736
756
  this.maxBatchSize = (_e = opts.maxBatchSize) != null ? _e : 50;
737
757
  this.maxQueueSize = (_f = opts.maxQueueSize) != null ? _f : 5e3;
@@ -862,7 +882,12 @@ var DirectTraceShipper = class {
862
882
  }
863
883
  const body = buildExportTraceServiceRequest2(batch);
864
884
  const url = `${this.baseUrl}traces`;
865
- const p = postJson2(url, body, { Authorization: `Bearer ${this.writeKey}` }, opts);
885
+ const p = postJson2(
886
+ url,
887
+ body,
888
+ { Authorization: `Bearer ${this.writeKey}`, ...projectIdHeaders(this.projectId) },
889
+ opts
890
+ );
866
891
  this.inFlight.add(p);
867
892
  try {
868
893
  try {
@@ -2135,9 +2160,20 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2135
2160
  directEndpoint,
2136
2161
  localDebuggerUrl,
2137
2162
  cloudEnabled,
2163
+ projectId,
2138
2164
  ...otherOptions
2139
2165
  } = options;
2140
2166
  const cloudEnabledResolved = cloudEnabled != null ? cloudEnabled : true;
2167
+ const withProjectIdHeaders = (existing) => {
2168
+ if (!projectId) {
2169
+ return existing;
2170
+ }
2171
+ return {
2172
+ Authorization: `Bearer ${writeKey}`,
2173
+ ...existing != null ? existing : {},
2174
+ ...projectIdHeaders(projectId)
2175
+ };
2176
+ };
2141
2177
  if (isDebug) {
2142
2178
  const mode = useExternalOtel ? "(external OTEL mode)" : tracingEnabled === false ? "(tracing disabled)" : "";
2143
2179
  console.log("[raindrop] Initializing tracing", mode);
@@ -2151,7 +2187,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2151
2187
  debug: isDebug,
2152
2188
  enabled: tracingEnabled !== false,
2153
2189
  localDebuggerUrl,
2154
- cloudEnabled: cloudEnabledResolved
2190
+ cloudEnabled: cloudEnabledResolved,
2191
+ projectId
2155
2192
  }) : void 0;
2156
2193
  let traceloopInitialized = false;
2157
2194
  try {
@@ -2209,6 +2246,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2209
2246
  otherOptions.processor,
2210
2247
  localDebuggerProcessor
2211
2248
  );
2249
+ const headers = withProjectIdHeaders(otherOptions.headers);
2212
2250
  traceloop3.initialize({
2213
2251
  baseUrl: apiUrl,
2214
2252
  apiKey: writeKey,
@@ -2216,7 +2254,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2216
2254
  logLevel,
2217
2255
  tracingEnabled: tracingEnabled !== false,
2218
2256
  disableBatch: disableBatching,
2219
- ...processor ? { processor } : {}
2257
+ ...processor ? { processor } : {},
2258
+ ...headers ? { headers } : {}
2220
2259
  });
2221
2260
  traceloopInitialized = true;
2222
2261
  }
@@ -2311,11 +2350,13 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2311
2350
  }
2312
2351
  };
2313
2352
  }
2353
+ const headers = withProjectIdHeaders(processorOptions == null ? void 0 : processorOptions.headers);
2314
2354
  const productionProcessor = traceloop3.createSpanProcessor({
2315
2355
  baseUrl: apiUrl,
2316
2356
  apiKey: writeKey,
2317
2357
  disableBatch: disableBatching,
2318
- ...processorOptions != null ? processorOptions : {}
2358
+ ...processorOptions != null ? processorOptions : {},
2359
+ ...headers ? { headers } : {}
2319
2360
  });
2320
2361
  const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
2321
2362
  writeKey,
@@ -2416,6 +2457,8 @@ export {
2416
2457
  stringifyBounded,
2417
2458
  resolveLocalDebuggerBaseUrl,
2418
2459
  mirrorPartialEventToLocalDebugger,
2460
+ normalizeProjectId,
2461
+ projectIdHeaders,
2419
2462
  SHUTDOWN_DEADLINE_MS,
2420
2463
  POST_SHUTDOWN_TIMEOUT_MS,
2421
2464
  package_default,
package/dist/index.d.mts CHANGED
@@ -757,6 +757,19 @@ interface AnalyticsConfig {
757
757
  * OR `NODE_ENV=development` enables the default `:5899` daemon).
758
758
  */
759
759
  localWorkshopUrl?: string | false | null;
760
+ /**
761
+ * Optional project slug. When set, every outbound cloud ingest request
762
+ * (event POSTs and the direct trace shipper) carries an
763
+ * `X-Raindrop-Project-Id: <projectId>` header so the backend routes the
764
+ * data to that project. Empty / whitespace-only values are ignored and the
765
+ * backend falls back to the account's default project. Slug format is
766
+ * validated on construction but never throws — invalid values are warned
767
+ * about (when `debugLogs` is true) and sent anyway (the backend returns
768
+ * HTTP 400 if the value is actually unusable). Local Workshop mirror
769
+ * requests deliberately skip this header (project routing is a cloud-only
770
+ * concept), mirroring the `@raindrop-ai/core` convention.
771
+ */
772
+ projectId?: string;
760
773
  /**
761
774
  * @deprecated Renamed to `useExternalOtel`. Use that instead.
762
775
  * This option will be removed in a future version.
@@ -866,6 +879,7 @@ declare class Raindrop {
866
879
  private partialEventTimeouts;
867
880
  private inFlightRequests;
868
881
  private maxTextFieldChars;
882
+ private projectId;
869
883
  /**
870
884
  * Epoch ms deadline while `close()` is draining; undefined otherwise.
871
885
  * Checked before every POST issued during the final flush so a dead or
package/dist/index.d.ts CHANGED
@@ -757,6 +757,19 @@ interface AnalyticsConfig {
757
757
  * OR `NODE_ENV=development` enables the default `:5899` daemon).
758
758
  */
759
759
  localWorkshopUrl?: string | false | null;
760
+ /**
761
+ * Optional project slug. When set, every outbound cloud ingest request
762
+ * (event POSTs and the direct trace shipper) carries an
763
+ * `X-Raindrop-Project-Id: <projectId>` header so the backend routes the
764
+ * data to that project. Empty / whitespace-only values are ignored and the
765
+ * backend falls back to the account's default project. Slug format is
766
+ * validated on construction but never throws — invalid values are warned
767
+ * about (when `debugLogs` is true) and sent anyway (the backend returns
768
+ * HTTP 400 if the value is actually unusable). Local Workshop mirror
769
+ * requests deliberately skip this header (project routing is a cloud-only
770
+ * concept), mirroring the `@raindrop-ai/core` convention.
771
+ */
772
+ projectId?: string;
760
773
  /**
761
774
  * @deprecated Renamed to `useExternalOtel`. Use that instead.
762
775
  * This option will be removed in a future version.
@@ -866,6 +879,7 @@ declare class Raindrop {
866
879
  private partialEventTimeouts;
867
880
  private inFlightRequests;
868
881
  private maxTextFieldChars;
882
+ private projectId;
869
883
  /**
870
884
  * Epoch ms deadline while `close()` is draining; undefined otherwise.
871
885
  * Checked before every POST issued during the final flush so a dead or
package/dist/index.js CHANGED
@@ -5771,7 +5771,7 @@ __export(index_exports, {
5771
5771
  });
5772
5772
  module.exports = __toCommonJS(index_exports);
5773
5773
 
5774
- // ../core/dist/chunk-U5HUTMR5.js
5774
+ // ../core/dist/chunk-SK6EJEO7.js
5775
5775
  var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
5776
5776
  var MAX_RETRY_DELAY_MS = 3e4;
5777
5777
  function wait(ms) {
@@ -6116,6 +6116,25 @@ function sendLocalDebuggerLiveEvent(event, options = {}) {
6116
6116
  ).catch(() => {
6117
6117
  });
6118
6118
  }
6119
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
6120
+ var PROJECT_ID_SLUG_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
6121
+ function isValidProjectIdSlug(value) {
6122
+ return PROJECT_ID_SLUG_PATTERN.test(value);
6123
+ }
6124
+ function normalizeProjectId(raw, opts) {
6125
+ if (typeof raw !== "string") return void 0;
6126
+ const trimmed = raw.trim();
6127
+ if (!trimmed) return void 0;
6128
+ if (!isValidProjectIdSlug(trimmed) && opts.debug) {
6129
+ console.warn(
6130
+ `${opts.prefix} projectId "${trimmed}" does not match slug ${PROJECT_ID_SLUG_PATTERN.source}; sending anyway \u2014 backend may reject with HTTP 400`
6131
+ );
6132
+ }
6133
+ return trimmed;
6134
+ }
6135
+ function projectIdHeaders(projectId) {
6136
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
6137
+ }
6119
6138
  var SHUTDOWN_DEADLINE_MS = 1e4;
6120
6139
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
6121
6140
  var DEFAULT_REDACT_ATTRIBUTE_KEYS = [
@@ -10236,7 +10255,7 @@ var SignalEventSchema = external_exports.object({
10236
10255
  // package.json
10237
10256
  var package_default = {
10238
10257
  name: "raindrop-ai",
10239
- version: "0.1.2",
10258
+ version: "0.1.3",
10240
10259
  main: "dist/index.js",
10241
10260
  module: "dist/index.mjs",
10242
10261
  types: "dist/index.d.ts",
@@ -10696,6 +10715,7 @@ var DirectTraceShipper = class {
10696
10715
  this.enabled = (_b = opts.enabled) != null ? _b : true;
10697
10716
  this.cloudEnabled = (_c = opts.cloudEnabled) != null ? _c : true;
10698
10717
  this.debug = opts.debug;
10718
+ this.projectId = opts.projectId;
10699
10719
  this.flushIntervalMs = (_d = opts.flushIntervalMs) != null ? _d : 1e3;
10700
10720
  this.maxBatchSize = (_e = opts.maxBatchSize) != null ? _e : 50;
10701
10721
  this.maxQueueSize = (_f = opts.maxQueueSize) != null ? _f : 5e3;
@@ -10826,7 +10846,12 @@ var DirectTraceShipper = class {
10826
10846
  }
10827
10847
  const body = buildExportTraceServiceRequest2(batch);
10828
10848
  const url = `${this.baseUrl}traces`;
10829
- const p = postJson2(url, body, { Authorization: `Bearer ${this.writeKey}` }, opts);
10849
+ const p = postJson2(
10850
+ url,
10851
+ body,
10852
+ { Authorization: `Bearer ${this.writeKey}`, ...projectIdHeaders(this.projectId) },
10853
+ opts
10854
+ );
10830
10855
  this.inFlight.add(p);
10831
10856
  try {
10832
10857
  try {
@@ -12093,9 +12118,20 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12093
12118
  directEndpoint,
12094
12119
  localDebuggerUrl,
12095
12120
  cloudEnabled,
12121
+ projectId,
12096
12122
  ...otherOptions
12097
12123
  } = options;
12098
12124
  const cloudEnabledResolved = cloudEnabled != null ? cloudEnabled : true;
12125
+ const withProjectIdHeaders = (existing) => {
12126
+ if (!projectId) {
12127
+ return existing;
12128
+ }
12129
+ return {
12130
+ Authorization: `Bearer ${writeKey}`,
12131
+ ...existing != null ? existing : {},
12132
+ ...projectIdHeaders(projectId)
12133
+ };
12134
+ };
12099
12135
  if (isDebug) {
12100
12136
  const mode = useExternalOtel ? "(external OTEL mode)" : tracingEnabled === false ? "(tracing disabled)" : "";
12101
12137
  console.log("[raindrop] Initializing tracing", mode);
@@ -12109,7 +12145,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12109
12145
  debug: isDebug,
12110
12146
  enabled: tracingEnabled !== false,
12111
12147
  localDebuggerUrl,
12112
- cloudEnabled: cloudEnabledResolved
12148
+ cloudEnabled: cloudEnabledResolved,
12149
+ projectId
12113
12150
  }) : void 0;
12114
12151
  let traceloopInitialized = false;
12115
12152
  try {
@@ -12167,6 +12204,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12167
12204
  otherOptions.processor,
12168
12205
  localDebuggerProcessor
12169
12206
  );
12207
+ const headers = withProjectIdHeaders(otherOptions.headers);
12170
12208
  traceloop3.initialize({
12171
12209
  baseUrl: apiUrl,
12172
12210
  apiKey: writeKey,
@@ -12174,7 +12212,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12174
12212
  logLevel,
12175
12213
  tracingEnabled: tracingEnabled !== false,
12176
12214
  disableBatch: disableBatching,
12177
- ...processor ? { processor } : {}
12215
+ ...processor ? { processor } : {},
12216
+ ...headers ? { headers } : {}
12178
12217
  });
12179
12218
  traceloopInitialized = true;
12180
12219
  }
@@ -12269,11 +12308,13 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
12269
12308
  }
12270
12309
  };
12271
12310
  }
12311
+ const headers = withProjectIdHeaders(processorOptions == null ? void 0 : processorOptions.headers);
12272
12312
  const productionProcessor = traceloop3.createSpanProcessor({
12273
12313
  baseUrl: apiUrl,
12274
12314
  apiKey: writeKey,
12275
12315
  disableBatch: disableBatching,
12276
- ...processorOptions != null ? processorOptions : {}
12316
+ ...processorOptions != null ? processorOptions : {},
12317
+ ...headers ? { headers } : {}
12277
12318
  });
12278
12319
  const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
12279
12320
  writeKey,
@@ -12571,6 +12612,10 @@ var Raindrop = class {
12571
12612
  this.disabled = (_e = config.disabled) != null ? _e : false;
12572
12613
  this.wizardSession = (_f = config.wizardSession) != null ? _f : null;
12573
12614
  this.debugLogs = (_g = config.debugLogs) != null ? _g : false;
12615
+ this.projectId = normalizeProjectId(config.projectId, {
12616
+ debug: this.debugLogs,
12617
+ prefix: "[raindrop]"
12618
+ });
12574
12619
  this.redactPii = (_h = config.redactPii) != null ? _h : false;
12575
12620
  this.context = this.getContext();
12576
12621
  if (this.debugLogs) {
@@ -12603,7 +12648,8 @@ var Raindrop = class {
12603
12648
  // but the direct shipper needs the full path to post to /v1/traces.
12604
12649
  directEndpoint: this.apiUrl,
12605
12650
  localDebuggerUrl: this.localDebuggerUrlOpt,
12606
- cloudEnabled: !this.localOnly
12651
+ cloudEnabled: !this.localOnly,
12652
+ projectId: this.projectId
12607
12653
  },
12608
12654
  this.debugLogs
12609
12655
  );
@@ -13052,7 +13098,8 @@ var Raindrop = class {
13052
13098
  method: "post",
13053
13099
  headers: {
13054
13100
  "Content-Type": "application/json",
13055
- Authorization: `Bearer ${this.writeKey}`
13101
+ Authorization: `Bearer ${this.writeKey}`,
13102
+ ...projectIdHeaders(this.projectId)
13056
13103
  },
13057
13104
  body: JSON.stringify(body),
13058
13105
  // Bounded: a dead or black-holed endpoint must never pin this
@@ -13321,7 +13368,8 @@ var Raindrop = class {
13321
13368
  method: "POST",
13322
13369
  headers: {
13323
13370
  "Content-Type": "application/json",
13324
- Authorization: `Bearer ${this.writeKey}`
13371
+ Authorization: `Bearer ${this.writeKey}`,
13372
+ ...projectIdHeaders(this.projectId)
13325
13373
  },
13326
13374
  body: JSON.stringify(event),
13327
13375
  // Send the single event object
package/dist/index.mjs CHANGED
@@ -5,7 +5,9 @@ import {
5
5
  SHUTDOWN_DEADLINE_MS,
6
6
  capText,
7
7
  mirrorPartialEventToLocalDebugger,
8
+ normalizeProjectId,
8
9
  package_default,
10
+ projectIdHeaders,
9
11
  raceWithTimeout,
10
12
  rateLimitedLog,
11
13
  redactUrlForLog,
@@ -14,7 +16,7 @@ import {
14
16
  setDefaultMaxTextFieldChars,
15
17
  stringifyBounded,
16
18
  tracing
17
- } from "./chunk-UICWZEYM.mjs";
19
+ } from "./chunk-QPGEMS2A.mjs";
18
20
  import {
19
21
  __commonJS,
20
22
  __toESM
@@ -10155,6 +10157,10 @@ var Raindrop = class {
10155
10157
  this.disabled = (_e = config.disabled) != null ? _e : false;
10156
10158
  this.wizardSession = (_f = config.wizardSession) != null ? _f : null;
10157
10159
  this.debugLogs = (_g = config.debugLogs) != null ? _g : false;
10160
+ this.projectId = normalizeProjectId(config.projectId, {
10161
+ debug: this.debugLogs,
10162
+ prefix: "[raindrop]"
10163
+ });
10158
10164
  this.redactPii = (_h = config.redactPii) != null ? _h : false;
10159
10165
  this.context = this.getContext();
10160
10166
  if (this.debugLogs) {
@@ -10187,7 +10193,8 @@ var Raindrop = class {
10187
10193
  // but the direct shipper needs the full path to post to /v1/traces.
10188
10194
  directEndpoint: this.apiUrl,
10189
10195
  localDebuggerUrl: this.localDebuggerUrlOpt,
10190
- cloudEnabled: !this.localOnly
10196
+ cloudEnabled: !this.localOnly,
10197
+ projectId: this.projectId
10191
10198
  },
10192
10199
  this.debugLogs
10193
10200
  );
@@ -10636,7 +10643,8 @@ var Raindrop = class {
10636
10643
  method: "post",
10637
10644
  headers: {
10638
10645
  "Content-Type": "application/json",
10639
- Authorization: `Bearer ${this.writeKey}`
10646
+ Authorization: `Bearer ${this.writeKey}`,
10647
+ ...projectIdHeaders(this.projectId)
10640
10648
  },
10641
10649
  body: JSON.stringify(body),
10642
10650
  // Bounded: a dead or black-holed endpoint must never pin this
@@ -10905,7 +10913,8 @@ var Raindrop = class {
10905
10913
  method: "POST",
10906
10914
  headers: {
10907
10915
  "Content-Type": "application/json",
10908
- Authorization: `Bearer ${this.writeKey}`
10916
+ Authorization: `Bearer ${this.writeKey}`,
10917
+ ...projectIdHeaders(this.projectId)
10909
10918
  },
10910
10919
  body: JSON.stringify(event),
10911
10920
  // Send the single event object
@@ -44,6 +44,12 @@ interface TracingOptions extends traceloop.InitializeOptions {
44
44
  * The local-debugger mirror still fires when a Workshop URL is resolved.
45
45
  */
46
46
  cloudEnabled?: boolean;
47
+ /**
48
+ * Optional project slug (already normalized by the parent SDK). When set,
49
+ * the DirectTraceShipper attaches `X-Raindrop-Project-Id` to its cloud span
50
+ * POSTs. Local-debugger mirror spans never carry it.
51
+ */
52
+ projectId?: string;
47
53
  }
48
54
  declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, options: TracingOptions, isDebug?: boolean) => {
49
55
  /**
@@ -44,6 +44,12 @@ interface TracingOptions extends traceloop.InitializeOptions {
44
44
  * The local-debugger mirror still fires when a Workshop URL is resolved.
45
45
  */
46
46
  cloudEnabled?: boolean;
47
+ /**
48
+ * Optional project slug (already normalized by the parent SDK). When set,
49
+ * the DirectTraceShipper attaches `X-Raindrop-Project-Id` to its cloud span
50
+ * POSTs. Local-debugger mirror spans never carry it.
51
+ */
52
+ projectId?: string;
47
53
  }
48
54
  declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, options: TracingOptions, isDebug?: boolean) => {
49
55
  /**
@@ -50,7 +50,7 @@ var import_instrumentation_vertexai = require("@traceloop/instrumentation-vertex
50
50
  var traceloop3 = __toESM(require("@traceloop/node-server-sdk"));
51
51
  var import_weakref = require("weakref");
52
52
 
53
- // ../core/dist/chunk-U5HUTMR5.js
53
+ // ../core/dist/chunk-SK6EJEO7.js
54
54
  var DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
55
55
  var MAX_RETRY_DELAY_MS = 3e4;
56
56
  function wait(ms) {
@@ -372,6 +372,10 @@ function sendLocalDebuggerLiveEvent(event, options = {}) {
372
372
  ).catch(() => {
373
373
  });
374
374
  }
375
+ var PROJECT_ID_HEADER = "X-Raindrop-Project-Id";
376
+ function projectIdHeaders(projectId) {
377
+ return projectId ? { [PROJECT_ID_HEADER]: projectId } : {};
378
+ }
375
379
  var SHUTDOWN_DEADLINE_MS = 1e4;
376
380
  var POST_SHUTDOWN_TIMEOUT_MS = 5e3;
377
381
  var DEFAULT_REDACT_ATTRIBUTE_KEYS = [
@@ -538,7 +542,7 @@ function base64ToHex(base64) {
538
542
  // package.json
539
543
  var package_default = {
540
544
  name: "raindrop-ai",
541
- version: "0.1.2",
545
+ version: "0.1.3",
542
546
  main: "dist/index.js",
543
547
  module: "dist/index.mjs",
544
548
  types: "dist/index.d.ts",
@@ -743,6 +747,7 @@ var DirectTraceShipper = class {
743
747
  this.enabled = (_b = opts.enabled) != null ? _b : true;
744
748
  this.cloudEnabled = (_c = opts.cloudEnabled) != null ? _c : true;
745
749
  this.debug = opts.debug;
750
+ this.projectId = opts.projectId;
746
751
  this.flushIntervalMs = (_d = opts.flushIntervalMs) != null ? _d : 1e3;
747
752
  this.maxBatchSize = (_e = opts.maxBatchSize) != null ? _e : 50;
748
753
  this.maxQueueSize = (_f = opts.maxQueueSize) != null ? _f : 5e3;
@@ -873,7 +878,12 @@ var DirectTraceShipper = class {
873
878
  }
874
879
  const body = buildExportTraceServiceRequest2(batch);
875
880
  const url = `${this.baseUrl}traces`;
876
- const p = postJson2(url, body, { Authorization: `Bearer ${this.writeKey}` }, opts);
881
+ const p = postJson2(
882
+ url,
883
+ body,
884
+ { Authorization: `Bearer ${this.writeKey}`, ...projectIdHeaders(this.projectId) },
885
+ opts
886
+ );
877
887
  this.inFlight.add(p);
878
888
  try {
879
889
  try {
@@ -2140,9 +2150,20 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2140
2150
  directEndpoint,
2141
2151
  localDebuggerUrl,
2142
2152
  cloudEnabled,
2153
+ projectId,
2143
2154
  ...otherOptions
2144
2155
  } = options;
2145
2156
  const cloudEnabledResolved = cloudEnabled != null ? cloudEnabled : true;
2157
+ const withProjectIdHeaders = (existing) => {
2158
+ if (!projectId) {
2159
+ return existing;
2160
+ }
2161
+ return {
2162
+ Authorization: `Bearer ${writeKey}`,
2163
+ ...existing != null ? existing : {},
2164
+ ...projectIdHeaders(projectId)
2165
+ };
2166
+ };
2146
2167
  if (isDebug) {
2147
2168
  const mode = useExternalOtel ? "(external OTEL mode)" : tracingEnabled === false ? "(tracing disabled)" : "";
2148
2169
  console.log("[raindrop] Initializing tracing", mode);
@@ -2156,7 +2177,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2156
2177
  debug: isDebug,
2157
2178
  enabled: tracingEnabled !== false,
2158
2179
  localDebuggerUrl,
2159
- cloudEnabled: cloudEnabledResolved
2180
+ cloudEnabled: cloudEnabledResolved,
2181
+ projectId
2160
2182
  }) : void 0;
2161
2183
  let traceloopInitialized = false;
2162
2184
  try {
@@ -2214,6 +2236,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2214
2236
  otherOptions.processor,
2215
2237
  localDebuggerProcessor
2216
2238
  );
2239
+ const headers = withProjectIdHeaders(otherOptions.headers);
2217
2240
  traceloop3.initialize({
2218
2241
  baseUrl: apiUrl,
2219
2242
  apiKey: writeKey,
@@ -2221,7 +2244,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2221
2244
  logLevel,
2222
2245
  tracingEnabled: tracingEnabled !== false,
2223
2246
  disableBatch: disableBatching,
2224
- ...processor ? { processor } : {}
2247
+ ...processor ? { processor } : {},
2248
+ ...headers ? { headers } : {}
2225
2249
  });
2226
2250
  traceloopInitialized = true;
2227
2251
  }
@@ -2316,11 +2340,13 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
2316
2340
  }
2317
2341
  };
2318
2342
  }
2343
+ const headers = withProjectIdHeaders(processorOptions == null ? void 0 : processorOptions.headers);
2319
2344
  const productionProcessor = traceloop3.createSpanProcessor({
2320
2345
  baseUrl: apiUrl,
2321
2346
  apiKey: writeKey,
2322
2347
  disableBatch: disableBatching,
2323
- ...processorOptions != null ? processorOptions : {}
2348
+ ...processorOptions != null ? processorOptions : {},
2349
+ ...headers ? { headers } : {}
2324
2350
  });
2325
2351
  const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
2326
2352
  writeKey,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tracing
3
- } from "../chunk-UICWZEYM.mjs";
3
+ } from "../chunk-QPGEMS2A.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.2",
3
+ "version": "0.1.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
@@ -46,7 +46,7 @@
46
46
  "typescript": "^5.3.3",
47
47
  "vite": "^7.3.2",
48
48
  "vitest": "^4.0.10",
49
- "@raindrop-ai/core": "0.0.3",
49
+ "@raindrop-ai/core": "0.0.4",
50
50
  "@raindrop-ai/redact-pii": "0.1.2",
51
51
  "@raindrop-ai/schemas": "0.0.1"
52
52
  },