neatlogs 1.1.20 → 1.1.21

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/dist/index.cjs CHANGED
@@ -9376,7 +9376,7 @@ function _resetMastraCache() {
9376
9376
  }
9377
9377
 
9378
9378
  // src/version.ts
9379
- var __version__ = "1.1.20";
9379
+ var __version__ = "1.1.21";
9380
9380
 
9381
9381
  // src/core/deadline.ts
9382
9382
  async function runByDeadline(operation, deadlineMs) {
@@ -9478,6 +9478,24 @@ var INIT_OPTION_KEYS = /* @__PURE__ */ new Set([
9478
9478
  "piiSpanTypes",
9479
9479
  "uploadAuthority"
9480
9480
  ]);
9481
+ function resolveInitEndpoint(endpoint) {
9482
+ const explicit = (endpoint ?? "").trim();
9483
+ if (explicit) return explicit;
9484
+ const fromEnv = (process.env.NEATLOGS_ENDPOINT ?? "").trim();
9485
+ return fromEnv || DEFAULT_INGEST_ENDPOINT;
9486
+ }
9487
+ function resolveIngestBaseUrl(endpoint) {
9488
+ const parsed = new URL(endpoint.trim());
9489
+ const path3 = parsed.pathname.replace(/\/+$/, "");
9490
+ if (path3 !== "" && path3 !== "/v1/traces") {
9491
+ throw new NeatlogsConfigurationError(
9492
+ "INVALID_ENDPOINT",
9493
+ "endpoint",
9494
+ "endpoint must be a base URL or an OTLP traces URL ending in /v1/traces."
9495
+ );
9496
+ }
9497
+ return parsed.origin;
9498
+ }
9481
9499
  function validateInitOptions(options) {
9482
9500
  const raw = options;
9483
9501
  if (Object.prototype.hasOwnProperty.call(raw, "instrumentations")) {
@@ -9561,8 +9579,13 @@ function stableValue(value, ancestors = /* @__PURE__ */ new WeakSet(), location
9561
9579
  ancestors.delete(value);
9562
9580
  }
9563
9581
  }
9582
+ function resolveApiKey(apiKey) {
9583
+ const explicit = (apiKey ?? "").trim();
9584
+ if (explicit) return explicit;
9585
+ return (process.env.NEATLOGS_API_KEY ?? "").trim();
9586
+ }
9564
9587
  function initIdentity(options) {
9565
- const apiKey = (options.apiKey ?? process.env.NEATLOGS_API_KEY ?? "").trim();
9588
+ const apiKey = resolveApiKey(options.apiKey);
9566
9589
  const apiKeyDigest = (0, import_node_crypto4.createHash)("sha256").update(apiKey).digest("hex");
9567
9590
  const serialized = stableValue({
9568
9591
  apiKeyDigest,
@@ -9582,7 +9605,7 @@ function initIdentity(options) {
9582
9605
  captureLogs: options.captureLogs ?? false,
9583
9606
  pii: options.pii ?? null,
9584
9607
  version: options.version ?? null,
9585
- endpoint: options.endpoint ?? DEFAULT_INGEST_ENDPOINT,
9608
+ endpoint: resolveInitEndpoint(options.endpoint),
9586
9609
  batchSize: options.batchSize ?? 100,
9587
9610
  flushInterval: options.flushInterval ?? 5,
9588
9611
  piiEnabled: options.piiEnabled ?? null,
@@ -9662,12 +9685,7 @@ async function _performInit(options) {
9662
9685
  );
9663
9686
  }
9664
9687
  _deliveryDiagnostics = new DeliveryDiagnostics();
9665
- let resolvedKey;
9666
- if (options.apiKey && options.apiKey.trim()) {
9667
- resolvedKey = options.apiKey.trim();
9668
- } else {
9669
- resolvedKey = (process.env.NEATLOGS_API_KEY ?? "").trim();
9670
- }
9688
+ let resolvedKey = resolveApiKey(options.apiKey);
9671
9689
  let disableExportResolved = !!options.disableExport || ["true", "1", "yes"].includes(
9672
9690
  (process.env.NEATLOGS_DISABLE_EXPORT ?? "").toLowerCase()
9673
9691
  );
@@ -9688,8 +9706,8 @@ async function _performInit(options) {
9688
9706
  }
9689
9707
  _debugMode2 = options.debug ?? false;
9690
9708
  const resolvedWorkflowName = _resolveWorkflowName(options.workflowName);
9691
- const endpoint = options.endpoint ?? DEFAULT_INGEST_ENDPOINT;
9692
- const baseUrl = new URL(endpoint).origin;
9709
+ const endpoint = resolveInitEndpoint(options.endpoint);
9710
+ const baseUrl = resolveIngestBaseUrl(endpoint);
9693
9711
  const uploadAuthority = disableExportResolved ? new DisabledUploadAuthority("export_disabled") : resolveUploadAuthority(
9694
9712
  options.uploadAuthority,
9695
9713
  process.env.NEATLOGS_UPLOADS_ENABLED,