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/cli.mjs CHANGED
@@ -7096,7 +7096,7 @@ var TELEMETRY_CONFLICT_PRECEDENCE = Object.freeze(
7096
7096
  );
7097
7097
 
7098
7098
  // src/version.ts
7099
- var __version__ = "1.1.20";
7099
+ var __version__ = "1.1.21";
7100
7100
 
7101
7101
  // src/init.ts
7102
7102
  import * as path2 from "path";
@@ -11422,6 +11422,24 @@ var INIT_OPTION_KEYS = /* @__PURE__ */ new Set([
11422
11422
  "piiSpanTypes",
11423
11423
  "uploadAuthority"
11424
11424
  ]);
11425
+ function resolveInitEndpoint(endpoint) {
11426
+ const explicit = (endpoint ?? "").trim();
11427
+ if (explicit) return explicit;
11428
+ const fromEnv = (process.env.NEATLOGS_ENDPOINT ?? "").trim();
11429
+ return fromEnv || DEFAULT_INGEST_ENDPOINT;
11430
+ }
11431
+ function resolveIngestBaseUrl(endpoint) {
11432
+ const parsed = new URL(endpoint.trim());
11433
+ const path3 = parsed.pathname.replace(/\/+$/, "");
11434
+ if (path3 !== "" && path3 !== "/v1/traces") {
11435
+ throw new NeatlogsConfigurationError(
11436
+ "INVALID_ENDPOINT",
11437
+ "endpoint",
11438
+ "endpoint must be a base URL or an OTLP traces URL ending in /v1/traces."
11439
+ );
11440
+ }
11441
+ return parsed.origin;
11442
+ }
11425
11443
  function validateInitOptions(options) {
11426
11444
  const raw = options;
11427
11445
  if (Object.prototype.hasOwnProperty.call(raw, "instrumentations")) {
@@ -11505,8 +11523,13 @@ function stableValue(value, ancestors = /* @__PURE__ */ new WeakSet(), location
11505
11523
  ancestors.delete(value);
11506
11524
  }
11507
11525
  }
11526
+ function resolveApiKey(apiKey) {
11527
+ const explicit = (apiKey ?? "").trim();
11528
+ if (explicit) return explicit;
11529
+ return (process.env.NEATLOGS_API_KEY ?? "").trim();
11530
+ }
11508
11531
  function initIdentity(options) {
11509
- const apiKey = (options.apiKey ?? process.env.NEATLOGS_API_KEY ?? "").trim();
11532
+ const apiKey = resolveApiKey(options.apiKey);
11510
11533
  const apiKeyDigest = createHash4("sha256").update(apiKey).digest("hex");
11511
11534
  const serialized = stableValue({
11512
11535
  apiKeyDigest,
@@ -11526,7 +11549,7 @@ function initIdentity(options) {
11526
11549
  captureLogs: options.captureLogs ?? false,
11527
11550
  pii: options.pii ?? null,
11528
11551
  version: options.version ?? null,
11529
- endpoint: options.endpoint ?? DEFAULT_INGEST_ENDPOINT,
11552
+ endpoint: resolveInitEndpoint(options.endpoint),
11530
11553
  batchSize: options.batchSize ?? 100,
11531
11554
  flushInterval: options.flushInterval ?? 5,
11532
11555
  piiEnabled: options.piiEnabled ?? null,
@@ -11606,12 +11629,7 @@ async function _performInit(options) {
11606
11629
  );
11607
11630
  }
11608
11631
  _deliveryDiagnostics = new DeliveryDiagnostics();
11609
- let resolvedKey;
11610
- if (options.apiKey && options.apiKey.trim()) {
11611
- resolvedKey = options.apiKey.trim();
11612
- } else {
11613
- resolvedKey = (process.env.NEATLOGS_API_KEY ?? "").trim();
11614
- }
11632
+ let resolvedKey = resolveApiKey(options.apiKey);
11615
11633
  let disableExportResolved = !!options.disableExport || ["true", "1", "yes"].includes(
11616
11634
  (process.env.NEATLOGS_DISABLE_EXPORT ?? "").toLowerCase()
11617
11635
  );
@@ -11632,8 +11650,8 @@ async function _performInit(options) {
11632
11650
  }
11633
11651
  _debugMode2 = options.debug ?? false;
11634
11652
  const resolvedWorkflowName = _resolveWorkflowName(options.workflowName);
11635
- const endpoint = options.endpoint ?? DEFAULT_INGEST_ENDPOINT;
11636
- const baseUrl = new URL(endpoint).origin;
11653
+ const endpoint = resolveInitEndpoint(options.endpoint);
11654
+ const baseUrl = resolveIngestBaseUrl(endpoint);
11637
11655
  const uploadAuthority = disableExportResolved ? new DisabledUploadAuthority("export_disabled") : resolveUploadAuthority(
11638
11656
  options.uploadAuthority,
11639
11657
  process.env.NEATLOGS_UPLOADS_ENABLED,