@deeptracer/core 0.7.0 → 0.8.1

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,5 +1,5 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = "0.7.0";
2
+ var SDK_VERSION = "0.8.1";
3
3
  var SDK_NAME = "core";
4
4
 
5
5
  // src/transport.ts
@@ -48,7 +48,10 @@ var Transport = class {
48
48
  Authorization: `Bearer ${this.authKey}`,
49
49
  "x-deeptracer-sdk": `${SDK_NAME}/${SDK_VERSION}`
50
50
  },
51
- body: JSON.stringify(body)
51
+ body: JSON.stringify(body),
52
+ // Keep the request alive if the browser tab closes or navigates away
53
+ // mid-flight. Node.js (undici) silently ignores this flag.
54
+ keepalive: typeof window !== "undefined"
52
55
  });
53
56
  if (res.ok) {
54
57
  this.warnedLabels.delete(label);
@@ -257,6 +260,13 @@ function parseTraceparent(header) {
257
260
  if (/^0+$/.test(traceId) || /^0+$/.test(parentId)) return null;
258
261
  return { traceId, parentId, flags };
259
262
  }
263
+ function resolveRelease(config) {
264
+ if (config.release) return config.release;
265
+ if (typeof process !== "undefined" && process.env) {
266
+ return process.env.DEEPTRACER_RELEASE || process.env.VERCEL_GIT_COMMIT_SHA || process.env.RAILWAY_GIT_COMMIT_SHA || process.env.RENDER_GIT_COMMIT || process.env.FLY_IMAGE_REF || process.env.GIT_COMMIT_SHA || process.env.COMMIT_SHA || void 0;
267
+ }
268
+ return void 0;
269
+ }
260
270
  var _originalConsole = {
261
271
  log: console.log,
262
272
  info: console.info,
@@ -269,6 +279,7 @@ var Logger = class _Logger {
269
279
  transport;
270
280
  isRoot;
271
281
  effectiveLevel;
282
+ release;
272
283
  contextName;
273
284
  config;
274
285
  state;
@@ -292,6 +303,7 @@ var Logger = class _Logger {
292
303
  _originalConsole.warn("[@deeptracer/core] No `endpoint` provided. Events will not be sent.");
293
304
  }
294
305
  }
306
+ this.release = resolveRelease(config);
295
307
  this.effectiveLevel = LOG_LEVEL_VALUES[config.level ?? (config.environment === "production" ? "info" : "debug")];
296
308
  this.transport = sharedTransport ?? new Transport(config);
297
309
  this.batcher = sharedBatcher ?? new Batcher(
@@ -455,7 +467,8 @@ var Logger = class _Logger {
455
467
  trace_id: this.requestMeta?.trace_id,
456
468
  span_id: this.requestMeta?.span_id,
457
469
  request_id: this.requestMeta?.request_id,
458
- vercel_id: this.requestMeta?.vercel_id
470
+ vercel_id: this.requestMeta?.vercel_id,
471
+ release: this.release
459
472
  };
460
473
  const hookResult = this.applyBeforeSend({ type: "log", data: entry });
461
474
  if (hookResult === null) return;
@@ -547,7 +560,8 @@ var Logger = class _Logger {
547
560
  context: Object.keys(enrichedContext).length > 0 ? enrichedContext : void 0,
548
561
  trace_id: this.requestMeta?.trace_id,
549
562
  user_id: context?.userId || this.state.user?.id,
550
- breadcrumbs: context?.breadcrumbs || [...this.state.breadcrumbs]
563
+ breadcrumbs: context?.breadcrumbs || [...this.state.breadcrumbs],
564
+ release: this.release
551
565
  };
552
566
  const hookResult = this.applyBeforeSend({ type: "error", data: report });
553
567
  if (hookResult === null) return;
@@ -567,7 +581,8 @@ var Logger = class _Logger {
567
581
  output_tokens: report.outputTokens,
568
582
  cost_usd: report.costUsd || 0,
569
583
  latency_ms: report.latencyMs,
570
- metadata
584
+ metadata,
585
+ release: this.release
571
586
  };
572
587
  const hookResult = this.applyBeforeSend({ type: "llm", data: report });
573
588
  if (hookResult === null) return;
@@ -646,7 +661,8 @@ var Logger = class _Logger {
646
661
  start_time: startTime,
647
662
  duration_ms: durationMs,
648
663
  status: options?.status || "ok",
649
- metadata: this.mergeStateMetadata(options?.metadata)
664
+ metadata: this.mergeStateMetadata(options?.metadata),
665
+ release: this.release
650
666
  };
651
667
  const hookResult = this.applyBeforeSend({ type: "trace", data: spanData });
652
668
  if (hookResult === null) return;
package/dist/index.cjs CHANGED
@@ -64,7 +64,7 @@ var Batcher = class {
64
64
  };
65
65
 
66
66
  // src/version.ts
67
- var SDK_VERSION = "0.7.0";
67
+ var SDK_VERSION = "0.8.1";
68
68
  var SDK_NAME = "core";
69
69
 
70
70
  // src/transport.ts
@@ -113,7 +113,10 @@ var Transport = class {
113
113
  Authorization: `Bearer ${this.authKey}`,
114
114
  "x-deeptracer-sdk": `${SDK_NAME}/${SDK_VERSION}`
115
115
  },
116
- body: JSON.stringify(body)
116
+ body: JSON.stringify(body),
117
+ // Keep the request alive if the browser tab closes or navigates away
118
+ // mid-flight. Node.js (undici) silently ignores this flag.
119
+ keepalive: typeof window !== "undefined"
117
120
  });
118
121
  if (res.ok) {
119
122
  this.warnedLabels.delete(label);
@@ -287,6 +290,13 @@ function parseTraceparent(header) {
287
290
  if (/^0+$/.test(traceId) || /^0+$/.test(parentId)) return null;
288
291
  return { traceId, parentId, flags };
289
292
  }
293
+ function resolveRelease(config) {
294
+ if (config.release) return config.release;
295
+ if (typeof process !== "undefined" && process.env) {
296
+ return process.env.DEEPTRACER_RELEASE || process.env.VERCEL_GIT_COMMIT_SHA || process.env.RAILWAY_GIT_COMMIT_SHA || process.env.RENDER_GIT_COMMIT || process.env.FLY_IMAGE_REF || process.env.GIT_COMMIT_SHA || process.env.COMMIT_SHA || void 0;
297
+ }
298
+ return void 0;
299
+ }
290
300
  var _originalConsole = {
291
301
  log: console.log,
292
302
  info: console.info,
@@ -299,6 +309,7 @@ var Logger = class _Logger {
299
309
  transport;
300
310
  isRoot;
301
311
  effectiveLevel;
312
+ release;
302
313
  contextName;
303
314
  config;
304
315
  state;
@@ -322,6 +333,7 @@ var Logger = class _Logger {
322
333
  _originalConsole.warn("[@deeptracer/core] No `endpoint` provided. Events will not be sent.");
323
334
  }
324
335
  }
336
+ this.release = resolveRelease(config);
325
337
  this.effectiveLevel = LOG_LEVEL_VALUES[config.level ?? (config.environment === "production" ? "info" : "debug")];
326
338
  this.transport = sharedTransport ?? new Transport(config);
327
339
  this.batcher = sharedBatcher ?? new Batcher(
@@ -485,7 +497,8 @@ var Logger = class _Logger {
485
497
  trace_id: this.requestMeta?.trace_id,
486
498
  span_id: this.requestMeta?.span_id,
487
499
  request_id: this.requestMeta?.request_id,
488
- vercel_id: this.requestMeta?.vercel_id
500
+ vercel_id: this.requestMeta?.vercel_id,
501
+ release: this.release
489
502
  };
490
503
  const hookResult = this.applyBeforeSend({ type: "log", data: entry });
491
504
  if (hookResult === null) return;
@@ -577,7 +590,8 @@ var Logger = class _Logger {
577
590
  context: Object.keys(enrichedContext).length > 0 ? enrichedContext : void 0,
578
591
  trace_id: this.requestMeta?.trace_id,
579
592
  user_id: context?.userId || this.state.user?.id,
580
- breadcrumbs: context?.breadcrumbs || [...this.state.breadcrumbs]
593
+ breadcrumbs: context?.breadcrumbs || [...this.state.breadcrumbs],
594
+ release: this.release
581
595
  };
582
596
  const hookResult = this.applyBeforeSend({ type: "error", data: report });
583
597
  if (hookResult === null) return;
@@ -597,7 +611,8 @@ var Logger = class _Logger {
597
611
  output_tokens: report.outputTokens,
598
612
  cost_usd: report.costUsd || 0,
599
613
  latency_ms: report.latencyMs,
600
- metadata
614
+ metadata,
615
+ release: this.release
601
616
  };
602
617
  const hookResult = this.applyBeforeSend({ type: "llm", data: report });
603
618
  if (hookResult === null) return;
@@ -676,7 +691,8 @@ var Logger = class _Logger {
676
691
  start_time: startTime,
677
692
  duration_ms: durationMs,
678
693
  status: options?.status || "ok",
679
- metadata: this.mergeStateMetadata(options?.metadata)
694
+ metadata: this.mergeStateMetadata(options?.metadata),
695
+ release: this.release
680
696
  };
681
697
  const hookResult = this.applyBeforeSend({ type: "trace", data: spanData });
682
698
  if (hookResult === null) return;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as Logger } from './logger-DnaUqfFI.cjs';
2
- export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveSpan, b as LLMUsageReport, c as LogEntry, d as LogLevel, e as LoggerConfig, M as MiddlewareOptions, S as Span, f as SpanData, U as User, g as createLogger } from './logger-DnaUqfFI.cjs';
1
+ import { L as Logger } from './logger-B-igTEwz.cjs';
2
+ export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveSpan, b as LLMUsageReport, c as LogEntry, d as LogLevel, e as LoggerConfig, M as MiddlewareOptions, S as Span, f as SpanData, U as User, g as createLogger } from './logger-B-igTEwz.cjs';
3
3
 
4
4
  /**
5
5
  * A Logger-compatible object where every method is a silent no-op.
@@ -18,7 +18,7 @@ export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveS
18
18
  declare const noopLogger: Logger;
19
19
 
20
20
  /** SDK version. Update on each release. */
21
- declare const SDK_VERSION = "0.7.0";
21
+ declare const SDK_VERSION = "0.8.1";
22
22
  declare const SDK_NAME = "core";
23
23
 
24
24
  export { Logger, SDK_NAME, SDK_VERSION, noopLogger };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as Logger } from './logger-DnaUqfFI.js';
2
- export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveSpan, b as LLMUsageReport, c as LogEntry, d as LogLevel, e as LoggerConfig, M as MiddlewareOptions, S as Span, f as SpanData, U as User, g as createLogger } from './logger-DnaUqfFI.js';
1
+ import { L as Logger } from './logger-B-igTEwz.js';
2
+ export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveSpan, b as LLMUsageReport, c as LogEntry, d as LogLevel, e as LoggerConfig, M as MiddlewareOptions, S as Span, f as SpanData, U as User, g as createLogger } from './logger-B-igTEwz.js';
3
3
 
4
4
  /**
5
5
  * A Logger-compatible object where every method is a silent no-op.
@@ -18,7 +18,7 @@ export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveS
18
18
  declare const noopLogger: Logger;
19
19
 
20
20
  /** SDK version. Update on each release. */
21
- declare const SDK_VERSION = "0.7.0";
21
+ declare const SDK_VERSION = "0.8.1";
22
22
  declare const SDK_NAME = "core";
23
23
 
24
24
  export { Logger, SDK_NAME, SDK_VERSION, noopLogger };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  SDK_NAME,
4
4
  SDK_VERSION,
5
5
  createLogger
6
- } from "./chunk-POYXPAC5.js";
6
+ } from "./chunk-6QL6H4AH.js";
7
7
 
8
8
  // src/noop-logger.ts
9
9
  var NOOP_INACTIVE_SPAN = {
package/dist/internal.cjs CHANGED
@@ -64,7 +64,7 @@ var Batcher = class {
64
64
  };
65
65
 
66
66
  // src/version.ts
67
- var SDK_VERSION = "0.7.0";
67
+ var SDK_VERSION = "0.8.1";
68
68
  var SDK_NAME = "core";
69
69
 
70
70
  // src/transport.ts
@@ -113,7 +113,10 @@ var Transport = class {
113
113
  Authorization: `Bearer ${this.authKey}`,
114
114
  "x-deeptracer-sdk": `${SDK_NAME}/${SDK_VERSION}`
115
115
  },
116
- body: JSON.stringify(body)
116
+ body: JSON.stringify(body),
117
+ // Keep the request alive if the browser tab closes or navigates away
118
+ // mid-flight. Node.js (undici) silently ignores this flag.
119
+ keepalive: typeof window !== "undefined"
117
120
  });
118
121
  if (res.ok) {
119
122
  this.warnedLabels.delete(label);
@@ -287,6 +290,13 @@ function parseTraceparent(header) {
287
290
  if (/^0+$/.test(traceId) || /^0+$/.test(parentId)) return null;
288
291
  return { traceId, parentId, flags };
289
292
  }
293
+ function resolveRelease(config) {
294
+ if (config.release) return config.release;
295
+ if (typeof process !== "undefined" && process.env) {
296
+ return process.env.DEEPTRACER_RELEASE || process.env.VERCEL_GIT_COMMIT_SHA || process.env.RAILWAY_GIT_COMMIT_SHA || process.env.RENDER_GIT_COMMIT || process.env.FLY_IMAGE_REF || process.env.GIT_COMMIT_SHA || process.env.COMMIT_SHA || void 0;
297
+ }
298
+ return void 0;
299
+ }
290
300
  var _originalConsole = {
291
301
  log: console.log,
292
302
  info: console.info,
@@ -299,6 +309,7 @@ var Logger = class _Logger {
299
309
  transport;
300
310
  isRoot;
301
311
  effectiveLevel;
312
+ release;
302
313
  contextName;
303
314
  config;
304
315
  state;
@@ -322,6 +333,7 @@ var Logger = class _Logger {
322
333
  _originalConsole.warn("[@deeptracer/core] No `endpoint` provided. Events will not be sent.");
323
334
  }
324
335
  }
336
+ this.release = resolveRelease(config);
325
337
  this.effectiveLevel = LOG_LEVEL_VALUES[config.level ?? (config.environment === "production" ? "info" : "debug")];
326
338
  this.transport = sharedTransport ?? new Transport(config);
327
339
  this.batcher = sharedBatcher ?? new Batcher(
@@ -485,7 +497,8 @@ var Logger = class _Logger {
485
497
  trace_id: this.requestMeta?.trace_id,
486
498
  span_id: this.requestMeta?.span_id,
487
499
  request_id: this.requestMeta?.request_id,
488
- vercel_id: this.requestMeta?.vercel_id
500
+ vercel_id: this.requestMeta?.vercel_id,
501
+ release: this.release
489
502
  };
490
503
  const hookResult = this.applyBeforeSend({ type: "log", data: entry });
491
504
  if (hookResult === null) return;
@@ -577,7 +590,8 @@ var Logger = class _Logger {
577
590
  context: Object.keys(enrichedContext).length > 0 ? enrichedContext : void 0,
578
591
  trace_id: this.requestMeta?.trace_id,
579
592
  user_id: context?.userId || this.state.user?.id,
580
- breadcrumbs: context?.breadcrumbs || [...this.state.breadcrumbs]
593
+ breadcrumbs: context?.breadcrumbs || [...this.state.breadcrumbs],
594
+ release: this.release
581
595
  };
582
596
  const hookResult = this.applyBeforeSend({ type: "error", data: report });
583
597
  if (hookResult === null) return;
@@ -597,7 +611,8 @@ var Logger = class _Logger {
597
611
  output_tokens: report.outputTokens,
598
612
  cost_usd: report.costUsd || 0,
599
613
  latency_ms: report.latencyMs,
600
- metadata
614
+ metadata,
615
+ release: this.release
601
616
  };
602
617
  const hookResult = this.applyBeforeSend({ type: "llm", data: report });
603
618
  if (hookResult === null) return;
@@ -676,7 +691,8 @@ var Logger = class _Logger {
676
691
  start_time: startTime,
677
692
  duration_ms: durationMs,
678
693
  status: options?.status || "ok",
679
- metadata: this.mergeStateMetadata(options?.metadata)
694
+ metadata: this.mergeStateMetadata(options?.metadata),
695
+ release: this.release
680
696
  };
681
697
  const hookResult = this.applyBeforeSend({ type: "trace", data: spanData });
682
698
  if (hookResult === null) return;
@@ -1,4 +1,4 @@
1
- export { L as Logger, e as LoggerConfig, h as LoggerState, M as MiddlewareOptions, T as Transport, _ as _originalConsole, p as parseTraceparent } from './logger-DnaUqfFI.cjs';
1
+ export { L as Logger, e as LoggerConfig, h as LoggerState, M as MiddlewareOptions, T as Transport, _ as _originalConsole, p as parseTraceparent } from './logger-B-igTEwz.cjs';
2
2
 
3
3
  /**
4
4
  * Parse console.log/info/warn/error arguments into a structured `{ message, metadata }` pair.
@@ -1,4 +1,4 @@
1
- export { L as Logger, e as LoggerConfig, h as LoggerState, M as MiddlewareOptions, T as Transport, _ as _originalConsole, p as parseTraceparent } from './logger-DnaUqfFI.js';
1
+ export { L as Logger, e as LoggerConfig, h as LoggerState, M as MiddlewareOptions, T as Transport, _ as _originalConsole, p as parseTraceparent } from './logger-B-igTEwz.js';
2
2
 
3
3
  /**
4
4
  * Parse console.log/info/warn/error arguments into a structured `{ message, metadata }` pair.
package/dist/internal.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Transport,
4
4
  _originalConsole,
5
5
  parseTraceparent
6
- } from "./chunk-POYXPAC5.js";
6
+ } from "./chunk-6QL6H4AH.js";
7
7
 
8
8
  // src/internal.ts
9
9
  function safeStringify(value) {
@@ -39,6 +39,17 @@ interface LoggerConfig {
39
39
  * Override via `DEEPTRACER_LOG_LEVEL` (server) or `NEXT_PUBLIC_DEEPTRACER_LOG_LEVEL` (client).
40
40
  */
41
41
  level?: LogLevel;
42
+ /**
43
+ * Release identifier sent with all events (logs, errors, traces, LLM usage).
44
+ *
45
+ * Used for source map resolution on errors and deployment correlation
46
+ * across all event types.
47
+ *
48
+ * Auto-detected (in order) from environment variables when not set explicitly:
49
+ * `DEEPTRACER_RELEASE`, `VERCEL_GIT_COMMIT_SHA`, `RAILWAY_GIT_COMMIT_SHA`,
50
+ * `RENDER_GIT_COMMIT`, `FLY_IMAGE_REF`, `GIT_COMMIT_SHA`, `COMMIT_SHA`.
51
+ */
52
+ release?: string;
42
53
  /** Enable console output for all log calls (useful for local development) */
43
54
  debug?: boolean;
44
55
  /** Maximum breadcrumbs to retain for error reports. Default: 20 */
@@ -102,6 +113,8 @@ interface LogEntry {
102
113
  request_id?: string;
103
114
  vercel_id?: string;
104
115
  context?: string;
116
+ /** Release identifier for deployment correlation */
117
+ release?: string;
105
118
  }
106
119
  /**
107
120
  * A breadcrumb entry — a trail of events leading up to an error.
@@ -128,6 +141,8 @@ interface ErrorReport {
128
141
  trace_id?: string;
129
142
  user_id?: string;
130
143
  breadcrumbs?: Breadcrumb[];
144
+ /** Release identifier for source map lookup */
145
+ release?: string;
131
146
  }
132
147
  /**
133
148
  * LLM usage report for tracking AI costs and performance.
@@ -154,6 +169,8 @@ interface SpanData {
154
169
  duration_ms: number;
155
170
  status: "ok" | "error";
156
171
  metadata?: Record<string, unknown>;
172
+ /** Release identifier for deployment correlation */
173
+ release?: string;
157
174
  }
158
175
  /**
159
176
  * A span representing a unit of work within a trace.
@@ -383,6 +400,7 @@ declare class Logger {
383
400
  private transport;
384
401
  private readonly isRoot;
385
402
  private effectiveLevel;
403
+ private release;
386
404
  protected contextName?: string;
387
405
  protected config: LoggerConfig;
388
406
  protected state: LoggerState;
@@ -39,6 +39,17 @@ interface LoggerConfig {
39
39
  * Override via `DEEPTRACER_LOG_LEVEL` (server) or `NEXT_PUBLIC_DEEPTRACER_LOG_LEVEL` (client).
40
40
  */
41
41
  level?: LogLevel;
42
+ /**
43
+ * Release identifier sent with all events (logs, errors, traces, LLM usage).
44
+ *
45
+ * Used for source map resolution on errors and deployment correlation
46
+ * across all event types.
47
+ *
48
+ * Auto-detected (in order) from environment variables when not set explicitly:
49
+ * `DEEPTRACER_RELEASE`, `VERCEL_GIT_COMMIT_SHA`, `RAILWAY_GIT_COMMIT_SHA`,
50
+ * `RENDER_GIT_COMMIT`, `FLY_IMAGE_REF`, `GIT_COMMIT_SHA`, `COMMIT_SHA`.
51
+ */
52
+ release?: string;
42
53
  /** Enable console output for all log calls (useful for local development) */
43
54
  debug?: boolean;
44
55
  /** Maximum breadcrumbs to retain for error reports. Default: 20 */
@@ -102,6 +113,8 @@ interface LogEntry {
102
113
  request_id?: string;
103
114
  vercel_id?: string;
104
115
  context?: string;
116
+ /** Release identifier for deployment correlation */
117
+ release?: string;
105
118
  }
106
119
  /**
107
120
  * A breadcrumb entry — a trail of events leading up to an error.
@@ -128,6 +141,8 @@ interface ErrorReport {
128
141
  trace_id?: string;
129
142
  user_id?: string;
130
143
  breadcrumbs?: Breadcrumb[];
144
+ /** Release identifier for source map lookup */
145
+ release?: string;
131
146
  }
132
147
  /**
133
148
  * LLM usage report for tracking AI costs and performance.
@@ -154,6 +169,8 @@ interface SpanData {
154
169
  duration_ms: number;
155
170
  status: "ok" | "error";
156
171
  metadata?: Record<string, unknown>;
172
+ /** Release identifier for deployment correlation */
173
+ release?: string;
157
174
  }
158
175
  /**
159
176
  * A span representing a unit of work within a trace.
@@ -383,6 +400,7 @@ declare class Logger {
383
400
  private transport;
384
401
  private readonly isRoot;
385
402
  private effectiveLevel;
403
+ private release;
386
404
  protected contextName?: string;
387
405
  protected config: LoggerConfig;
388
406
  protected state: LoggerState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeptracer/core",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "Core SDK for DeepTracer — Logger class, types, transport, batcher, tracing",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",