@deeptracer/core 0.5.0 → 0.6.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.
package/README.md CHANGED
@@ -83,11 +83,10 @@ Pass a `LoggerConfig` object to `createLogger()`:
83
83
 
84
84
  ```ts
85
85
  const logger = createLogger({
86
- // Required
87
- service: "api", // Service name within the product
88
- environment: "production", // "production" or "staging"
89
- endpoint: "https://dt.co", // DeepTracer ingestion endpoint URL
90
- apiKey: "dt_xxx", // API key for authentication
86
+ apiKey: "dt_xxx", // API key (reads DEEPTRACER_KEY env var if omitted)
87
+ endpoint: "https://dt.co", // Ingestion endpoint (reads DEEPTRACER_ENDPOINT if omitted)
88
+ service: "api", // Service name (default: "server")
89
+ environment: "production", // Deployment environment (default: NODE_ENV or "production")
91
90
 
92
91
  // Optional
93
92
  batchSize: 50, // Logs to buffer before sending (default: 50)
@@ -96,15 +95,17 @@ const logger = createLogger({
96
95
  })
97
96
  ```
98
97
 
99
- | Field | Type | Required | Default | Description |
100
- |-------|------|----------|---------|-------------|
101
- | `service` | `string` | Yes | -- | Service name (e.g., `"api"`, `"worker"`, `"web"`) |
102
- | `environment` | `"production" \| "staging"` | Yes | -- | Deployment environment |
103
- | `endpoint` | `string` | Yes | -- | DeepTracer ingestion endpoint URL |
104
- | `apiKey` | `string` | Yes | -- | API key (prefix: `dt_`) |
105
- | `batchSize` | `number` | No | `50` | Number of log entries to buffer before flushing |
106
- | `flushIntervalMs` | `number` | No | `5000` | Milliseconds between automatic flushes |
107
- | `debug` | `boolean` | No | `false` | When `true`, all log calls also print to the console |
98
+ > **Graceful degradation:** If `apiKey` or `endpoint` is missing, `createLogger()` prints a warning and runs in local-only mode — all methods work but no data is sent. The SDK never throws on missing config.
99
+
100
+ | Field | Type | Default | Description |
101
+ |-------|------|---------|-------------|
102
+ | `apiKey` | `string` | `DEEPTRACER_KEY` env var | API key (prefix: `dt_`). If missing, runs in local-only mode (no data sent). |
103
+ | `endpoint` | `string` | `DEEPTRACER_ENDPOINT` env var | DeepTracer ingestion endpoint URL. If missing, runs in local-only mode. |
104
+ | `service` | `string` | `"server"` | Service name (e.g., `"api"`, `"worker"`, `"web"`) |
105
+ | `environment` | `string` | `NODE_ENV` / `"production"` | Deployment environment |
106
+ | `batchSize` | `number` | `50` | Number of log entries to buffer before flushing |
107
+ | `flushIntervalMs` | `number` | `5000` | Milliseconds between automatic flushes |
108
+ | `debug` | `boolean` | `false` | When `true`, all log calls also print to the console |
108
109
 
109
110
  ## API Reference
110
111
 
@@ -1,19 +1,14 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = "0.5.0";
2
+ var SDK_VERSION = "0.6.0";
3
3
  var SDK_NAME = "core";
4
4
 
5
5
  // src/transport.ts
6
6
  var Transport = class {
7
7
  constructor(config) {
8
8
  this.config = config;
9
- const hasKey = !!(config.secretKey || config.publicKey);
9
+ const hasKey = !!config.apiKey;
10
10
  const hasEndpoint = !!config.endpoint;
11
11
  this.disabled = !hasKey || !hasEndpoint;
12
- if (config.secretKey?.startsWith("dt_secret_") && typeof globalThis.window !== "undefined") {
13
- console.error(
14
- "[@deeptracer/core] WARNING: `secretKey` (dt_secret_...) detected in a browser bundle. This exposes your server key to end users. Use `publicKey` (dt_public_...) for client-side code."
15
- );
16
- }
17
12
  }
18
13
  inFlightRequests = /* @__PURE__ */ new Set();
19
14
  /**
@@ -30,9 +25,8 @@ var Transport = class {
30
25
  * (e.g., when the ingestion endpoint is unreachable during development).
31
26
  */
32
27
  warnedLabels = /* @__PURE__ */ new Set();
33
- /** Resolve the auth key: prefer secretKey (server), fall back to publicKey (client). */
34
28
  get authKey() {
35
- return this.config.secretKey ?? this.config.publicKey ?? "";
29
+ return this.config.apiKey ?? "";
36
30
  }
37
31
  /**
38
32
  * Send a request with automatic retry and exponential backoff.
@@ -281,16 +275,14 @@ var Logger = class _Logger {
281
275
  this.contextName = contextName;
282
276
  this.requestMeta = requestMeta;
283
277
  this.state = state ?? createLoggerState(config.maxBreadcrumbs ?? 20);
284
- const hasKey = !!(config.secretKey || config.publicKey);
278
+ const hasKey = !!config.apiKey;
285
279
  const hasEndpoint = !!config.endpoint;
286
280
  if (!hasKey && !hasEndpoint) {
287
281
  _originalConsole.warn(
288
- "[@deeptracer/core] No API key or endpoint configured. Running in local-only mode (logging methods work, but events are not sent). Set DEEPTRACER_SECRET_KEY and DEEPTRACER_ENDPOINT to enable."
282
+ "[@deeptracer/core] No API key or endpoint configured. Running in local-only mode (logging methods work, but events are not sent). Set DEEPTRACER_KEY and DEEPTRACER_ENDPOINT to enable."
289
283
  );
290
284
  } else if (!hasKey) {
291
- _originalConsole.warn(
292
- "[@deeptracer/core] No `secretKey` or `publicKey` provided. Events will not be sent."
293
- );
285
+ _originalConsole.warn("[@deeptracer/core] No `apiKey` provided. Events will not be sent.");
294
286
  } else if (!hasEndpoint) {
295
287
  _originalConsole.warn("[@deeptracer/core] No `endpoint` provided. Events will not be sent.");
296
288
  }
package/dist/index.cjs CHANGED
@@ -23,7 +23,8 @@ __export(index_exports, {
23
23
  Logger: () => Logger,
24
24
  SDK_NAME: () => SDK_NAME,
25
25
  SDK_VERSION: () => SDK_VERSION,
26
- createLogger: () => createLogger
26
+ createLogger: () => createLogger,
27
+ noopLogger: () => noopLogger
27
28
  });
28
29
  module.exports = __toCommonJS(index_exports);
29
30
 
@@ -62,21 +63,16 @@ var Batcher = class {
62
63
  };
63
64
 
64
65
  // src/version.ts
65
- var SDK_VERSION = "0.5.0";
66
+ var SDK_VERSION = "0.6.0";
66
67
  var SDK_NAME = "core";
67
68
 
68
69
  // src/transport.ts
69
70
  var Transport = class {
70
71
  constructor(config) {
71
72
  this.config = config;
72
- const hasKey = !!(config.secretKey || config.publicKey);
73
+ const hasKey = !!config.apiKey;
73
74
  const hasEndpoint = !!config.endpoint;
74
75
  this.disabled = !hasKey || !hasEndpoint;
75
- if (config.secretKey?.startsWith("dt_secret_") && typeof globalThis.window !== "undefined") {
76
- console.error(
77
- "[@deeptracer/core] WARNING: `secretKey` (dt_secret_...) detected in a browser bundle. This exposes your server key to end users. Use `publicKey` (dt_public_...) for client-side code."
78
- );
79
- }
80
76
  }
81
77
  inFlightRequests = /* @__PURE__ */ new Set();
82
78
  /**
@@ -93,9 +89,8 @@ var Transport = class {
93
89
  * (e.g., when the ingestion endpoint is unreachable during development).
94
90
  */
95
91
  warnedLabels = /* @__PURE__ */ new Set();
96
- /** Resolve the auth key: prefer secretKey (server), fall back to publicKey (client). */
97
92
  get authKey() {
98
- return this.config.secretKey ?? this.config.publicKey ?? "";
93
+ return this.config.apiKey ?? "";
99
94
  }
100
95
  /**
101
96
  * Send a request with automatic retry and exponential backoff.
@@ -310,16 +305,14 @@ var Logger = class _Logger {
310
305
  this.contextName = contextName;
311
306
  this.requestMeta = requestMeta;
312
307
  this.state = state ?? createLoggerState(config.maxBreadcrumbs ?? 20);
313
- const hasKey = !!(config.secretKey || config.publicKey);
308
+ const hasKey = !!config.apiKey;
314
309
  const hasEndpoint = !!config.endpoint;
315
310
  if (!hasKey && !hasEndpoint) {
316
311
  _originalConsole.warn(
317
- "[@deeptracer/core] No API key or endpoint configured. Running in local-only mode (logging methods work, but events are not sent). Set DEEPTRACER_SECRET_KEY and DEEPTRACER_ENDPOINT to enable."
312
+ "[@deeptracer/core] No API key or endpoint configured. Running in local-only mode (logging methods work, but events are not sent). Set DEEPTRACER_KEY and DEEPTRACER_ENDPOINT to enable."
318
313
  );
319
314
  } else if (!hasKey) {
320
- _originalConsole.warn(
321
- "[@deeptracer/core] No `secretKey` or `publicKey` provided. Events will not be sent."
322
- );
315
+ _originalConsole.warn("[@deeptracer/core] No `apiKey` provided. Events will not be sent.");
323
316
  } else if (!hasEndpoint) {
324
317
  _originalConsole.warn("[@deeptracer/core] No `endpoint` provided. Events will not be sent.");
325
318
  }
@@ -728,10 +721,64 @@ var Logger = class _Logger {
728
721
  function createLogger(config) {
729
722
  return new Logger(config);
730
723
  }
724
+
725
+ // src/noop-logger.ts
726
+ var NOOP_INACTIVE_SPAN = {
727
+ traceId: "0".repeat(32),
728
+ spanId: "0".repeat(16),
729
+ parentSpanId: "",
730
+ operation: "noop",
731
+ end: () => {
732
+ },
733
+ getHeaders: () => ({}),
734
+ startSpan: (_operation, fn) => fn(NOOP_SPAN),
735
+ startInactiveSpan: () => NOOP_INACTIVE_SPAN
736
+ };
737
+ var NOOP_SPAN = {
738
+ traceId: NOOP_INACTIVE_SPAN.traceId,
739
+ spanId: NOOP_INACTIVE_SPAN.spanId,
740
+ parentSpanId: NOOP_INACTIVE_SPAN.parentSpanId,
741
+ operation: NOOP_INACTIVE_SPAN.operation,
742
+ getHeaders: () => ({})
743
+ };
744
+ var noop = () => {
745
+ };
746
+ var noopLogger = {
747
+ // Logging — silent
748
+ debug: noop,
749
+ info: noop,
750
+ warn: noop,
751
+ error: noop,
752
+ // User context — silent
753
+ setUser: noop,
754
+ clearUser: noop,
755
+ // Tags & context — silent
756
+ setTags: noop,
757
+ clearTags: noop,
758
+ setContext: noop,
759
+ clearContext: noop,
760
+ // Breadcrumbs — silent
761
+ addBreadcrumb: noop,
762
+ // Child loggers — return self
763
+ withContext: () => noopLogger,
764
+ forRequest: () => noopLogger,
765
+ // Error capture — silent
766
+ captureError: noop,
767
+ // LLM usage — silent
768
+ llmUsage: noop,
769
+ // Tracing — call the callback, return its result
770
+ startSpan: (_operation, fn) => fn(NOOP_SPAN),
771
+ startInactiveSpan: () => NOOP_INACTIVE_SPAN,
772
+ wrap: (_operation, fn) => fn,
773
+ // Lifecycle — resolve immediately
774
+ flush: noop,
775
+ destroy: () => Promise.resolve()
776
+ };
731
777
  // Annotate the CommonJS export names for ESM import in node:
732
778
  0 && (module.exports = {
733
779
  Logger,
734
780
  SDK_NAME,
735
781
  SDK_VERSION,
736
- createLogger
782
+ createLogger,
783
+ noopLogger
737
784
  });
package/dist/index.d.cts CHANGED
@@ -1,7 +1,24 @@
1
- export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveSpan, L as LLMUsageReport, b as LogEntry, c as LogLevel, d as Logger, e as LoggerConfig, M as MiddlewareOptions, S as Span, f as SpanData, U as User, g as createLogger } from './logger-BDTEt7Gi.cjs';
1
+ import { L as Logger } from './logger-CzZg2_vM.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-CzZg2_vM.cjs';
3
+
4
+ /**
5
+ * A Logger-compatible object where every method is a silent no-op.
6
+ *
7
+ * Returned by `init()` when API key or endpoint is missing, and by
8
+ * `useLogger()` when the DeepTracer provider hasn't initialized yet (SSR/SSG).
9
+ *
10
+ * This ensures the SDK never crashes your app — if config is missing,
11
+ * all logging calls silently do nothing.
12
+ *
13
+ * - No timers, no Transport, no network requests, no console output
14
+ * - `withContext()` and `forRequest()` return the same noopLogger
15
+ * - `startSpan(op, fn)` still calls `fn` and returns its result
16
+ * - `flush()` and `destroy()` resolve immediately
17
+ */
18
+ declare const noopLogger: Logger;
2
19
 
3
20
  /** SDK version. Update on each release. */
4
- declare const SDK_VERSION = "0.5.0";
21
+ declare const SDK_VERSION = "0.6.0";
5
22
  declare const SDK_NAME = "core";
6
23
 
7
- export { SDK_NAME, SDK_VERSION };
24
+ export { Logger, SDK_NAME, SDK_VERSION, noopLogger };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,24 @@
1
- export { B as BeforeSendEvent, a as Breadcrumb, E as ErrorReport, I as InactiveSpan, L as LLMUsageReport, b as LogEntry, c as LogLevel, d as Logger, e as LoggerConfig, M as MiddlewareOptions, S as Span, f as SpanData, U as User, g as createLogger } from './logger-BDTEt7Gi.js';
1
+ import { L as Logger } from './logger-CzZg2_vM.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-CzZg2_vM.js';
3
+
4
+ /**
5
+ * A Logger-compatible object where every method is a silent no-op.
6
+ *
7
+ * Returned by `init()` when API key or endpoint is missing, and by
8
+ * `useLogger()` when the DeepTracer provider hasn't initialized yet (SSR/SSG).
9
+ *
10
+ * This ensures the SDK never crashes your app — if config is missing,
11
+ * all logging calls silently do nothing.
12
+ *
13
+ * - No timers, no Transport, no network requests, no console output
14
+ * - `withContext()` and `forRequest()` return the same noopLogger
15
+ * - `startSpan(op, fn)` still calls `fn` and returns its result
16
+ * - `flush()` and `destroy()` resolve immediately
17
+ */
18
+ declare const noopLogger: Logger;
2
19
 
3
20
  /** SDK version. Update on each release. */
4
- declare const SDK_VERSION = "0.5.0";
21
+ declare const SDK_VERSION = "0.6.0";
5
22
  declare const SDK_NAME = "core";
6
23
 
7
- export { SDK_NAME, SDK_VERSION };
24
+ export { Logger, SDK_NAME, SDK_VERSION, noopLogger };
package/dist/index.js CHANGED
@@ -3,10 +3,64 @@ import {
3
3
  SDK_NAME,
4
4
  SDK_VERSION,
5
5
  createLogger
6
- } from "./chunk-GH7R74RT.js";
6
+ } from "./chunk-7GB6YZQS.js";
7
+
8
+ // src/noop-logger.ts
9
+ var NOOP_INACTIVE_SPAN = {
10
+ traceId: "0".repeat(32),
11
+ spanId: "0".repeat(16),
12
+ parentSpanId: "",
13
+ operation: "noop",
14
+ end: () => {
15
+ },
16
+ getHeaders: () => ({}),
17
+ startSpan: (_operation, fn) => fn(NOOP_SPAN),
18
+ startInactiveSpan: () => NOOP_INACTIVE_SPAN
19
+ };
20
+ var NOOP_SPAN = {
21
+ traceId: NOOP_INACTIVE_SPAN.traceId,
22
+ spanId: NOOP_INACTIVE_SPAN.spanId,
23
+ parentSpanId: NOOP_INACTIVE_SPAN.parentSpanId,
24
+ operation: NOOP_INACTIVE_SPAN.operation,
25
+ getHeaders: () => ({})
26
+ };
27
+ var noop = () => {
28
+ };
29
+ var noopLogger = {
30
+ // Logging — silent
31
+ debug: noop,
32
+ info: noop,
33
+ warn: noop,
34
+ error: noop,
35
+ // User context — silent
36
+ setUser: noop,
37
+ clearUser: noop,
38
+ // Tags & context — silent
39
+ setTags: noop,
40
+ clearTags: noop,
41
+ setContext: noop,
42
+ clearContext: noop,
43
+ // Breadcrumbs — silent
44
+ addBreadcrumb: noop,
45
+ // Child loggers — return self
46
+ withContext: () => noopLogger,
47
+ forRequest: () => noopLogger,
48
+ // Error capture — silent
49
+ captureError: noop,
50
+ // LLM usage — silent
51
+ llmUsage: noop,
52
+ // Tracing — call the callback, return its result
53
+ startSpan: (_operation, fn) => fn(NOOP_SPAN),
54
+ startInactiveSpan: () => NOOP_INACTIVE_SPAN,
55
+ wrap: (_operation, fn) => fn,
56
+ // Lifecycle — resolve immediately
57
+ flush: noop,
58
+ destroy: () => Promise.resolve()
59
+ };
7
60
  export {
8
61
  Logger,
9
62
  SDK_NAME,
10
63
  SDK_VERSION,
11
- createLogger
64
+ createLogger,
65
+ noopLogger
12
66
  };
package/dist/internal.cjs CHANGED
@@ -63,21 +63,16 @@ var Batcher = class {
63
63
  };
64
64
 
65
65
  // src/version.ts
66
- var SDK_VERSION = "0.5.0";
66
+ var SDK_VERSION = "0.6.0";
67
67
  var SDK_NAME = "core";
68
68
 
69
69
  // src/transport.ts
70
70
  var Transport = class {
71
71
  constructor(config) {
72
72
  this.config = config;
73
- const hasKey = !!(config.secretKey || config.publicKey);
73
+ const hasKey = !!config.apiKey;
74
74
  const hasEndpoint = !!config.endpoint;
75
75
  this.disabled = !hasKey || !hasEndpoint;
76
- if (config.secretKey?.startsWith("dt_secret_") && typeof globalThis.window !== "undefined") {
77
- console.error(
78
- "[@deeptracer/core] WARNING: `secretKey` (dt_secret_...) detected in a browser bundle. This exposes your server key to end users. Use `publicKey` (dt_public_...) for client-side code."
79
- );
80
- }
81
76
  }
82
77
  inFlightRequests = /* @__PURE__ */ new Set();
83
78
  /**
@@ -94,9 +89,8 @@ var Transport = class {
94
89
  * (e.g., when the ingestion endpoint is unreachable during development).
95
90
  */
96
91
  warnedLabels = /* @__PURE__ */ new Set();
97
- /** Resolve the auth key: prefer secretKey (server), fall back to publicKey (client). */
98
92
  get authKey() {
99
- return this.config.secretKey ?? this.config.publicKey ?? "";
93
+ return this.config.apiKey ?? "";
100
94
  }
101
95
  /**
102
96
  * Send a request with automatic retry and exponential backoff.
@@ -311,16 +305,14 @@ var Logger = class _Logger {
311
305
  this.contextName = contextName;
312
306
  this.requestMeta = requestMeta;
313
307
  this.state = state ?? createLoggerState(config.maxBreadcrumbs ?? 20);
314
- const hasKey = !!(config.secretKey || config.publicKey);
308
+ const hasKey = !!config.apiKey;
315
309
  const hasEndpoint = !!config.endpoint;
316
310
  if (!hasKey && !hasEndpoint) {
317
311
  _originalConsole.warn(
318
- "[@deeptracer/core] No API key or endpoint configured. Running in local-only mode (logging methods work, but events are not sent). Set DEEPTRACER_SECRET_KEY and DEEPTRACER_ENDPOINT to enable."
312
+ "[@deeptracer/core] No API key or endpoint configured. Running in local-only mode (logging methods work, but events are not sent). Set DEEPTRACER_KEY and DEEPTRACER_ENDPOINT to enable."
319
313
  );
320
314
  } else if (!hasKey) {
321
- _originalConsole.warn(
322
- "[@deeptracer/core] No `secretKey` or `publicKey` provided. Events will not be sent."
323
- );
315
+ _originalConsole.warn("[@deeptracer/core] No `apiKey` provided. Events will not be sent.");
324
316
  } else if (!hasEndpoint) {
325
317
  _originalConsole.warn("[@deeptracer/core] No `endpoint` provided. Events will not be sent.");
326
318
  }
@@ -1,5 +1,5 @@
1
- import { e as LoggerConfig, b as LogEntry, E as ErrorReport, f as SpanData } from './logger-BDTEt7Gi.cjs';
2
- export { d as Logger, h as LoggerState, M as MiddlewareOptions, _ as _originalConsole, p as parseTraceparent } from './logger-BDTEt7Gi.cjs';
1
+ import { e as LoggerConfig, c as LogEntry, E as ErrorReport, f as SpanData } from './logger-CzZg2_vM.cjs';
2
+ export { L as Logger, h as LoggerState, M as MiddlewareOptions, _ as _originalConsole, p as parseTraceparent } from './logger-CzZg2_vM.cjs';
3
3
 
4
4
  /**
5
5
  * HTTP transport for sending data to the DeepTracer ingestion API.
@@ -30,8 +30,7 @@ declare class Transport {
30
30
  * (e.g., when the ingestion endpoint is unreachable during development).
31
31
  */
32
32
  private warnedLabels;
33
- constructor(config: Pick<LoggerConfig, "endpoint" | "secretKey" | "publicKey" | "service" | "environment">);
34
- /** Resolve the auth key: prefer secretKey (server), fall back to publicKey (client). */
33
+ constructor(config: Pick<LoggerConfig, "endpoint" | "apiKey" | "service" | "environment">);
35
34
  private get authKey();
36
35
  /**
37
36
  * Send a request with automatic retry and exponential backoff.
@@ -1,5 +1,5 @@
1
- import { e as LoggerConfig, b as LogEntry, E as ErrorReport, f as SpanData } from './logger-BDTEt7Gi.js';
2
- export { d as Logger, h as LoggerState, M as MiddlewareOptions, _ as _originalConsole, p as parseTraceparent } from './logger-BDTEt7Gi.js';
1
+ import { e as LoggerConfig, c as LogEntry, E as ErrorReport, f as SpanData } from './logger-CzZg2_vM.js';
2
+ export { L as Logger, h as LoggerState, M as MiddlewareOptions, _ as _originalConsole, p as parseTraceparent } from './logger-CzZg2_vM.js';
3
3
 
4
4
  /**
5
5
  * HTTP transport for sending data to the DeepTracer ingestion API.
@@ -30,8 +30,7 @@ declare class Transport {
30
30
  * (e.g., when the ingestion endpoint is unreachable during development).
31
31
  */
32
32
  private warnedLabels;
33
- constructor(config: Pick<LoggerConfig, "endpoint" | "secretKey" | "publicKey" | "service" | "environment">);
34
- /** Resolve the auth key: prefer secretKey (server), fall back to publicKey (client). */
33
+ constructor(config: Pick<LoggerConfig, "endpoint" | "apiKey" | "service" | "environment">);
35
34
  private get authKey();
36
35
  /**
37
36
  * Send a request with automatic retry and exponential backoff.
package/dist/internal.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  Transport,
4
4
  _originalConsole,
5
5
  parseTraceparent
6
- } from "./chunk-GH7R74RT.js";
6
+ } from "./chunk-7GB6YZQS.js";
7
7
 
8
8
  // src/internal.ts
9
9
  function safeStringify(value) {
@@ -2,34 +2,22 @@
2
2
  * Configuration for creating a DeepTracer logger instance.
3
3
  *
4
4
  * All fields are optional when environment variables are set.
5
- * Server packages read `DEEPTRACER_SECRET_KEY`, `DEEPTRACER_ENDPOINT`, etc.
5
+ * Server packages read `DEEPTRACER_KEY`, `DEEPTRACER_ENDPOINT`, etc.
6
6
  * Client packages read `NEXT_PUBLIC_DEEPTRACER_KEY`, `NEXT_PUBLIC_DEEPTRACER_ENDPOINT`, etc.
7
7
  *
8
8
  * @example
9
- * Server (Node.js / Next.js instrumentation):
10
9
  * ```ts
11
10
  * const config: LoggerConfig = {
12
- * secretKey: "dt_secret_xxx",
11
+ * apiKey: "dt_xxx",
13
12
  * endpoint: "https://deeptracer.example.com",
14
13
  * service: "api",
15
14
  * environment: "production",
16
15
  * }
17
16
  * ```
18
- *
19
- * @example
20
- * Client (browser / React):
21
- * ```ts
22
- * const config: LoggerConfig = {
23
- * publicKey: "dt_public_xxx",
24
- * endpoint: "https://deeptracer.example.com",
25
- * }
26
- * ```
27
17
  */
28
18
  interface LoggerConfig {
29
- /** Server-side API key (prefix: `dt_secret_`). Never expose in client bundles. */
30
- secretKey?: string;
31
- /** Client-side API key (prefix: `dt_public_`). Safe for browser bundles. */
32
- publicKey?: string;
19
+ /** DeepTracer API key (prefix: `dt_`). Set via `DEEPTRACER_KEY` or `NEXT_PUBLIC_DEEPTRACER_KEY` env var. */
20
+ apiKey?: string;
33
21
  /** Service name (e.g., "api", "worker", "web"). Default varies by package. */
34
22
  service?: string;
35
23
  /** Deployment environment (any string). Default: `NODE_ENV` or `"production"` */
@@ -274,7 +262,7 @@ declare const _originalConsole: {
274
262
  * import { createLogger } from "@deeptracer/core"
275
263
  *
276
264
  * const logger = createLogger({
277
- * secretKey: "dt_secret_xxx",
265
+ * apiKey: "dt_xxx",
278
266
  * endpoint: "https://deeptracer.example.com",
279
267
  * service: "api",
280
268
  * environment: "production",
@@ -409,4 +397,4 @@ declare class Logger {
409
397
  /** Create a new DeepTracer logger instance. */
410
398
  declare function createLogger(config: LoggerConfig): Logger;
411
399
 
412
- export { type BeforeSendEvent as B, type ErrorReport as E, type InactiveSpan as I, type LLMUsageReport as L, type MiddlewareOptions as M, type Span as S, type User as U, _originalConsole as _, type Breadcrumb as a, type LogEntry as b, type LogLevel as c, Logger as d, type LoggerConfig as e, type SpanData as f, createLogger as g, type LoggerState as h, parseTraceparent as p };
400
+ export { type BeforeSendEvent as B, type ErrorReport as E, type InactiveSpan as I, Logger as L, type MiddlewareOptions as M, type Span as S, type User as U, _originalConsole as _, type Breadcrumb as a, type LLMUsageReport as b, type LogEntry as c, type LogLevel as d, type LoggerConfig as e, type SpanData as f, createLogger as g, type LoggerState as h, parseTraceparent as p };
@@ -2,34 +2,22 @@
2
2
  * Configuration for creating a DeepTracer logger instance.
3
3
  *
4
4
  * All fields are optional when environment variables are set.
5
- * Server packages read `DEEPTRACER_SECRET_KEY`, `DEEPTRACER_ENDPOINT`, etc.
5
+ * Server packages read `DEEPTRACER_KEY`, `DEEPTRACER_ENDPOINT`, etc.
6
6
  * Client packages read `NEXT_PUBLIC_DEEPTRACER_KEY`, `NEXT_PUBLIC_DEEPTRACER_ENDPOINT`, etc.
7
7
  *
8
8
  * @example
9
- * Server (Node.js / Next.js instrumentation):
10
9
  * ```ts
11
10
  * const config: LoggerConfig = {
12
- * secretKey: "dt_secret_xxx",
11
+ * apiKey: "dt_xxx",
13
12
  * endpoint: "https://deeptracer.example.com",
14
13
  * service: "api",
15
14
  * environment: "production",
16
15
  * }
17
16
  * ```
18
- *
19
- * @example
20
- * Client (browser / React):
21
- * ```ts
22
- * const config: LoggerConfig = {
23
- * publicKey: "dt_public_xxx",
24
- * endpoint: "https://deeptracer.example.com",
25
- * }
26
- * ```
27
17
  */
28
18
  interface LoggerConfig {
29
- /** Server-side API key (prefix: `dt_secret_`). Never expose in client bundles. */
30
- secretKey?: string;
31
- /** Client-side API key (prefix: `dt_public_`). Safe for browser bundles. */
32
- publicKey?: string;
19
+ /** DeepTracer API key (prefix: `dt_`). Set via `DEEPTRACER_KEY` or `NEXT_PUBLIC_DEEPTRACER_KEY` env var. */
20
+ apiKey?: string;
33
21
  /** Service name (e.g., "api", "worker", "web"). Default varies by package. */
34
22
  service?: string;
35
23
  /** Deployment environment (any string). Default: `NODE_ENV` or `"production"` */
@@ -274,7 +262,7 @@ declare const _originalConsole: {
274
262
  * import { createLogger } from "@deeptracer/core"
275
263
  *
276
264
  * const logger = createLogger({
277
- * secretKey: "dt_secret_xxx",
265
+ * apiKey: "dt_xxx",
278
266
  * endpoint: "https://deeptracer.example.com",
279
267
  * service: "api",
280
268
  * environment: "production",
@@ -409,4 +397,4 @@ declare class Logger {
409
397
  /** Create a new DeepTracer logger instance. */
410
398
  declare function createLogger(config: LoggerConfig): Logger;
411
399
 
412
- export { type BeforeSendEvent as B, type ErrorReport as E, type InactiveSpan as I, type LLMUsageReport as L, type MiddlewareOptions as M, type Span as S, type User as U, _originalConsole as _, type Breadcrumb as a, type LogEntry as b, type LogLevel as c, Logger as d, type LoggerConfig as e, type SpanData as f, createLogger as g, type LoggerState as h, parseTraceparent as p };
400
+ export { type BeforeSendEvent as B, type ErrorReport as E, type InactiveSpan as I, Logger as L, type MiddlewareOptions as M, type Span as S, type User as U, _originalConsole as _, type Breadcrumb as a, type LLMUsageReport as b, type LogEntry as c, type LogLevel as d, type LoggerConfig as e, type SpanData as f, createLogger as g, type LoggerState as h, parseTraceparent as p };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeptracer/core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Core SDK for DeepTracer — Logger class, types, transport, batcher, tracing",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",