@deeptracer/core 0.6.4 → 0.7.0

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.6.4";
2
+ var SDK_VERSION = "0.7.0";
3
3
  var SDK_NAME = "core";
4
4
 
5
5
  // src/transport.ts
@@ -99,6 +99,7 @@ var Transport = class {
99
99
  track(promise) {
100
100
  this.inFlightRequests.add(promise);
101
101
  promise.finally(() => this.inFlightRequests.delete(promise));
102
+ this.config.waitUntil?.(promise);
102
103
  }
103
104
  async sendLogs(logs) {
104
105
  const p = this.sendWithRetry(
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.6.4";
67
+ var SDK_VERSION = "0.7.0";
68
68
  var SDK_NAME = "core";
69
69
 
70
70
  // src/transport.ts
@@ -164,6 +164,7 @@ var Transport = class {
164
164
  track(promise) {
165
165
  this.inFlightRequests.add(promise);
166
166
  promise.finally(() => this.inFlightRequests.delete(promise));
167
+ this.config.waitUntil?.(promise);
167
168
  }
168
169
  async sendLogs(logs) {
169
170
  const p = this.sendWithRetry(
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { L as Logger } from './logger-DyJENLNA.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-DyJENLNA.cjs';
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';
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.6.4";
21
+ declare const SDK_VERSION = "0.7.0";
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-DyJENLNA.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-DyJENLNA.js';
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';
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.6.4";
21
+ declare const SDK_VERSION = "0.7.0";
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-QAJHHVX4.js";
6
+ } from "./chunk-POYXPAC5.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.6.4";
67
+ var SDK_VERSION = "0.7.0";
68
68
  var SDK_NAME = "core";
69
69
 
70
70
  // src/transport.ts
@@ -164,6 +164,7 @@ var Transport = class {
164
164
  track(promise) {
165
165
  this.inFlightRequests.add(promise);
166
166
  promise.finally(() => this.inFlightRequests.delete(promise));
167
+ this.config.waitUntil?.(promise);
167
168
  }
168
169
  async sendLogs(logs) {
169
170
  const p = this.sendWithRetry(
@@ -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-DyJENLNA.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-DnaUqfFI.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-DyJENLNA.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-DnaUqfFI.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-QAJHHVX4.js";
6
+ } from "./chunk-POYXPAC5.js";
7
7
 
8
8
  // src/internal.ts
9
9
  function safeStringify(value) {
@@ -63,6 +63,28 @@ interface LoggerConfig {
63
63
  * ```
64
64
  */
65
65
  beforeSend?: (event: BeforeSendEvent) => BeforeSendEvent | null;
66
+ /**
67
+ * Called with each outgoing HTTP request promise when the transport sends data.
68
+ * Use this to keep a serverless function alive until all in-flight requests
69
+ * complete — even for logs written after the HTTP response has been returned
70
+ * (e.g., from Better Auth background task callbacks or other post-response work).
71
+ *
72
+ * On Vercel this is wired up automatically by `@deeptracer/nextjs`.
73
+ * On Cloudflare Workers, pass `ctx.waitUntil.bind(ctx)` when creating the logger.
74
+ * On persistent servers (Railway, Fly, Docker) you don't need this — the process
75
+ * stays alive and the timer-based flush handles it.
76
+ *
77
+ * @example Cloudflare Workers
78
+ * ```ts
79
+ * export default {
80
+ * async fetch(request, env, ctx) {
81
+ * const logger = createLogger({ waitUntil: ctx.waitUntil.bind(ctx), ... })
82
+ * // logs are now kept alive past the response
83
+ * }
84
+ * }
85
+ * ```
86
+ */
87
+ waitUntil?: (promise: Promise<unknown>) => void;
66
88
  }
67
89
  /** Log severity level */
68
90
  type LogLevel = "debug" | "info" | "warn" | "error";
@@ -254,7 +276,7 @@ declare class Transport {
254
276
  * (e.g., when the ingestion endpoint is unreachable during development).
255
277
  */
256
278
  private warnedLabels;
257
- constructor(config: Pick<LoggerConfig, "endpoint" | "apiKey" | "service" | "environment">);
279
+ constructor(config: Pick<LoggerConfig, "endpoint" | "apiKey" | "service" | "environment" | "waitUntil">);
258
280
  private get authKey();
259
281
  /**
260
282
  * Send a request with automatic retry and exponential backoff.
@@ -63,6 +63,28 @@ interface LoggerConfig {
63
63
  * ```
64
64
  */
65
65
  beforeSend?: (event: BeforeSendEvent) => BeforeSendEvent | null;
66
+ /**
67
+ * Called with each outgoing HTTP request promise when the transport sends data.
68
+ * Use this to keep a serverless function alive until all in-flight requests
69
+ * complete — even for logs written after the HTTP response has been returned
70
+ * (e.g., from Better Auth background task callbacks or other post-response work).
71
+ *
72
+ * On Vercel this is wired up automatically by `@deeptracer/nextjs`.
73
+ * On Cloudflare Workers, pass `ctx.waitUntil.bind(ctx)` when creating the logger.
74
+ * On persistent servers (Railway, Fly, Docker) you don't need this — the process
75
+ * stays alive and the timer-based flush handles it.
76
+ *
77
+ * @example Cloudflare Workers
78
+ * ```ts
79
+ * export default {
80
+ * async fetch(request, env, ctx) {
81
+ * const logger = createLogger({ waitUntil: ctx.waitUntil.bind(ctx), ... })
82
+ * // logs are now kept alive past the response
83
+ * }
84
+ * }
85
+ * ```
86
+ */
87
+ waitUntil?: (promise: Promise<unknown>) => void;
66
88
  }
67
89
  /** Log severity level */
68
90
  type LogLevel = "debug" | "info" | "warn" | "error";
@@ -254,7 +276,7 @@ declare class Transport {
254
276
  * (e.g., when the ingestion endpoint is unreachable during development).
255
277
  */
256
278
  private warnedLabels;
257
- constructor(config: Pick<LoggerConfig, "endpoint" | "apiKey" | "service" | "environment">);
279
+ constructor(config: Pick<LoggerConfig, "endpoint" | "apiKey" | "service" | "environment" | "waitUntil">);
258
280
  private get authKey();
259
281
  /**
260
282
  * Send a request with automatic retry and exponential backoff.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeptracer/core",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "Core SDK for DeepTracer — Logger class, types, transport, batcher, tracing",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",