@deeptracer/core 0.4.3 → 0.5.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.
package/README.md CHANGED
@@ -50,7 +50,7 @@ const logger = createLogger({
50
50
  service: "api",
51
51
  environment: "production",
52
52
  endpoint: "https://your-deeptracer.example.com",
53
- secretKey: "dt_secret_xxx",
53
+ apiKey: "dt_xxx",
54
54
  })
55
55
 
56
56
  // Structured logging (batched -- sent in groups of 50 or every 5 seconds)
@@ -87,7 +87,7 @@ const logger = createLogger({
87
87
  service: "api", // Service name within the product
88
88
  environment: "production", // "production" or "staging"
89
89
  endpoint: "https://dt.co", // DeepTracer ingestion endpoint URL
90
- secretKey: "dt_secret_xxx", // Server-side API key for authentication
90
+ apiKey: "dt_xxx", // API key for authentication
91
91
 
92
92
  // Optional
93
93
  batchSize: 50, // Logs to buffer before sending (default: 50)
@@ -101,8 +101,7 @@ const logger = createLogger({
101
101
  | `service` | `string` | Yes | -- | Service name (e.g., `"api"`, `"worker"`, `"web"`) |
102
102
  | `environment` | `"production" \| "staging"` | Yes | -- | Deployment environment |
103
103
  | `endpoint` | `string` | Yes | -- | DeepTracer ingestion endpoint URL |
104
- | `secretKey` | `string` | Yes | -- | Server-side API key (prefix: `dt_secret_`) |
105
- | `publicKey` | `string` | No | -- | Client-side API key (prefix: `dt_public_`) |
104
+ | `apiKey` | `string` | Yes | -- | API key (prefix: `dt_`) |
106
105
  | `batchSize` | `number` | No | `50` | Number of log entries to buffer before flushing |
107
106
  | `flushIntervalMs` | `number` | No | `5000` | Milliseconds between automatic flushes |
108
107
  | `debug` | `boolean` | No | `false` | When `true`, all log calls also print to the console |
@@ -120,7 +119,7 @@ const logger = createLogger({
120
119
  service: "api",
121
120
  environment: "production",
122
121
  endpoint: "https://your-deeptracer.example.com",
123
- secretKey: "dt_secret_xxx",
122
+ apiKey: "dt_xxx",
124
123
  })
125
124
  ```
126
125
 
@@ -439,8 +438,7 @@ interface LoggerConfig {
439
438
  service: string
440
439
  environment: "production" | "staging"
441
440
  endpoint: string
442
- secretKey: string
443
- publicKey?: string
441
+ apiKey: string
444
442
  batchSize?: number // default: 50
445
443
  flushIntervalMs?: number // default: 5000
446
444
  debug?: boolean // default: false
@@ -584,7 +582,7 @@ The transport layer sends data to four DeepTracer ingestion endpoints:
584
582
  | `POST /ingest/llm` | Immediate | LLM usage reports |
585
583
 
586
584
  All requests include:
587
- - `Authorization: Bearer <secretKey>` header
585
+ - `Authorization: Bearer <apiKey>` header
588
586
  - `Content-Type: application/json` header
589
587
  - `service` and `environment` fields in the JSON body
590
588
 
@@ -1,19 +1,14 @@
1
1
  // src/version.ts
2
- var SDK_VERSION = "0.4.3";
2
+ var SDK_VERSION = "0.5.1";
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
@@ -62,21 +62,16 @@ var Batcher = class {
62
62
  };
63
63
 
64
64
  // src/version.ts
65
- var SDK_VERSION = "0.4.3";
65
+ var SDK_VERSION = "0.5.1";
66
66
  var SDK_NAME = "core";
67
67
 
68
68
  // src/transport.ts
69
69
  var Transport = class {
70
70
  constructor(config) {
71
71
  this.config = config;
72
- const hasKey = !!(config.secretKey || config.publicKey);
72
+ const hasKey = !!config.apiKey;
73
73
  const hasEndpoint = !!config.endpoint;
74
74
  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
75
  }
81
76
  inFlightRequests = /* @__PURE__ */ new Set();
82
77
  /**
@@ -93,9 +88,8 @@ var Transport = class {
93
88
  * (e.g., when the ingestion endpoint is unreachable during development).
94
89
  */
95
90
  warnedLabels = /* @__PURE__ */ new Set();
96
- /** Resolve the auth key: prefer secretKey (server), fall back to publicKey (client). */
97
91
  get authKey() {
98
- return this.config.secretKey ?? this.config.publicKey ?? "";
92
+ return this.config.apiKey ?? "";
99
93
  }
100
94
  /**
101
95
  * Send a request with automatic retry and exponential backoff.
@@ -310,16 +304,14 @@ var Logger = class _Logger {
310
304
  this.contextName = contextName;
311
305
  this.requestMeta = requestMeta;
312
306
  this.state = state ?? createLoggerState(config.maxBreadcrumbs ?? 20);
313
- const hasKey = !!(config.secretKey || config.publicKey);
307
+ const hasKey = !!config.apiKey;
314
308
  const hasEndpoint = !!config.endpoint;
315
309
  if (!hasKey && !hasEndpoint) {
316
310
  _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."
311
+ "[@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
312
  );
319
313
  } else if (!hasKey) {
320
- _originalConsole.warn(
321
- "[@deeptracer/core] No `secretKey` or `publicKey` provided. Events will not be sent."
322
- );
314
+ _originalConsole.warn("[@deeptracer/core] No `apiKey` provided. Events will not be sent.");
323
315
  } else if (!hasEndpoint) {
324
316
  _originalConsole.warn("[@deeptracer/core] No `endpoint` provided. Events will not be sent.");
325
317
  }
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
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
+ 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-BzzHo1HP.cjs';
2
2
 
3
3
  /** SDK version. Update on each release. */
4
- declare const SDK_VERSION = "0.4.3";
4
+ declare const SDK_VERSION = "0.5.1";
5
5
  declare const SDK_NAME = "core";
6
6
 
7
7
  export { SDK_NAME, SDK_VERSION };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
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
+ 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-BzzHo1HP.js';
2
2
 
3
3
  /** SDK version. Update on each release. */
4
- declare const SDK_VERSION = "0.4.3";
4
+ declare const SDK_VERSION = "0.5.1";
5
5
  declare const SDK_NAME = "core";
6
6
 
7
7
  export { SDK_NAME, SDK_VERSION };
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  SDK_NAME,
4
4
  SDK_VERSION,
5
5
  createLogger
6
- } from "./chunk-2W6VVHL7.js";
6
+ } from "./chunk-HOUMS3SU.js";
7
7
  export {
8
8
  Logger,
9
9
  SDK_NAME,
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.4.3";
66
+ var SDK_VERSION = "0.5.1";
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, b as LogEntry, E as ErrorReport, f as SpanData } from './logger-BzzHo1HP.cjs';
2
+ export { d as Logger, h as LoggerState, M as MiddlewareOptions, _ as _originalConsole, p as parseTraceparent } from './logger-BzzHo1HP.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, b as LogEntry, E as ErrorReport, f as SpanData } from './logger-BzzHo1HP.js';
2
+ export { d as Logger, h as LoggerState, M as MiddlewareOptions, _ as _originalConsole, p as parseTraceparent } from './logger-BzzHo1HP.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-2W6VVHL7.js";
6
+ } from "./chunk-HOUMS3SU.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",
@@ -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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deeptracer/core",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "description": "Core SDK for DeepTracer — Logger class, types, transport, batcher, tracing",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",