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.d.ts CHANGED
@@ -531,7 +531,7 @@ declare class Client {
531
531
  private performShutdown;
532
532
  }
533
533
 
534
- type NeatlogsConfigurationErrorCode = 'UNKNOWN_INIT_OPTION' | 'UNSUPPORTED_INSTRUMENTATIONS' | 'UNSUPPORTED_SPAN_KIND' | 'CONFLICTING_INIT';
534
+ type NeatlogsConfigurationErrorCode = 'UNKNOWN_INIT_OPTION' | 'UNSUPPORTED_INSTRUMENTATIONS' | 'UNSUPPORTED_SPAN_KIND' | 'CONFLICTING_INIT' | 'INVALID_ENDPOINT';
535
535
  /** A caller-actionable SDK configuration failure. */
536
536
  declare class NeatlogsConfigurationError extends TypeError {
537
537
  readonly code: NeatlogsConfigurationErrorCode;
@@ -2282,6 +2282,6 @@ declare function doctorCapturedLocalV2(options?: Readonly<{
2282
2282
  * SDK version. Kept in sync with package.json by the `version:sync` script
2283
2283
  * (runs automatically on `prebuild`). Do not edit by hand — bump package.json.
2284
2284
  */
2285
- declare const __version__ = "1.1.20";
2285
+ declare const __version__ = "1.1.21";
2286
2286
 
2287
2287
  export { type CachedPrompt, Client, type ClientOptions, type CreatePromptInput, DOCTOR_V2_FORMAT_VERSION, type DeliveryDiagnosticsSnapshot, type DiagnosticEnvelope, type DiagnosticSpan, DisabledUploadAuthority, type DoctorV2Check, type DoctorV2Result, type FlushAllResult, type FlushOutcome, type GetPromptOptions, HttpUploadAuthority, type HttpUploadAuthorityOptions, type IdentifyOptions, type InitOptions, type LegacySavePromptVersionOptions, type MaskContext, type MaskFunction, NeatlogsConfigurationError, type NeatlogsConfigurationErrorCode, PromptApiError, PromptClient, PromptClientClosedError, PromptClientError, type PromptClientOptions, PromptHandle, type PromptMessage, type PromptMutationSelector, PromptNotFoundError, PromptRequestTimeoutError, PromptTemplate, type PromptWriteInput, type SavePromptVersionOptions, Span, type SpanKind, type SpanOptions, TELEMETRY_CONFLICT_PRECEDENCE, TELEMETRY_CONTRACT_VERSION, TELEMETRY_SCHEMA_SHA256, TELEMETRY_SCHEMA_V2, TELEMETRY_SCHEMA_VERSION, TelemetryUploadError, type TraceContextCarrier, type TraceOptions, type TraceSpanKind, type UploadAuthority, type UploadAuthorityOption, type UploadContentEncoding, type UploadPayload, type UploadPayloadSchema, type UploadPurpose, type UploadReceipt, type UploadReference, type UploadRequestOptions, UserPromptTemplate, __version__, addTag, bindTemplates, createPrompt, deletePrompt, doctorCapturedLocalV2, doctorLocalV2, doctorSemanticDigest, extractTraceContext, fetchPrompt, flush, flushAll, flushAllDetailed, getDeliveryDiagnostics, getMastraObservability, getPrompt, getSessionConfig, identify, init, injectTraceContext, isDebugEnabled, listPrompts, log, registerCrewaiTask, removeTag, saveAsVersion, setLabel, setTraceOutput, shutdown, span, trace, updatePrompt };
package/dist/index.mjs CHANGED
@@ -9283,7 +9283,7 @@ function _resetMastraCache() {
9283
9283
  }
9284
9284
 
9285
9285
  // src/version.ts
9286
- var __version__ = "1.1.20";
9286
+ var __version__ = "1.1.21";
9287
9287
 
9288
9288
  // src/core/deadline.ts
9289
9289
  async function runByDeadline(operation, deadlineMs) {
@@ -9385,6 +9385,24 @@ var INIT_OPTION_KEYS = /* @__PURE__ */ new Set([
9385
9385
  "piiSpanTypes",
9386
9386
  "uploadAuthority"
9387
9387
  ]);
9388
+ function resolveInitEndpoint(endpoint) {
9389
+ const explicit = (endpoint ?? "").trim();
9390
+ if (explicit) return explicit;
9391
+ const fromEnv = (process.env.NEATLOGS_ENDPOINT ?? "").trim();
9392
+ return fromEnv || DEFAULT_INGEST_ENDPOINT;
9393
+ }
9394
+ function resolveIngestBaseUrl(endpoint) {
9395
+ const parsed = new URL(endpoint.trim());
9396
+ const path3 = parsed.pathname.replace(/\/+$/, "");
9397
+ if (path3 !== "" && path3 !== "/v1/traces") {
9398
+ throw new NeatlogsConfigurationError(
9399
+ "INVALID_ENDPOINT",
9400
+ "endpoint",
9401
+ "endpoint must be a base URL or an OTLP traces URL ending in /v1/traces."
9402
+ );
9403
+ }
9404
+ return parsed.origin;
9405
+ }
9388
9406
  function validateInitOptions(options) {
9389
9407
  const raw = options;
9390
9408
  if (Object.prototype.hasOwnProperty.call(raw, "instrumentations")) {
@@ -9468,8 +9486,13 @@ function stableValue(value, ancestors = /* @__PURE__ */ new WeakSet(), location
9468
9486
  ancestors.delete(value);
9469
9487
  }
9470
9488
  }
9489
+ function resolveApiKey(apiKey) {
9490
+ const explicit = (apiKey ?? "").trim();
9491
+ if (explicit) return explicit;
9492
+ return (process.env.NEATLOGS_API_KEY ?? "").trim();
9493
+ }
9471
9494
  function initIdentity(options) {
9472
- const apiKey = (options.apiKey ?? process.env.NEATLOGS_API_KEY ?? "").trim();
9495
+ const apiKey = resolveApiKey(options.apiKey);
9473
9496
  const apiKeyDigest = createHash4("sha256").update(apiKey).digest("hex");
9474
9497
  const serialized = stableValue({
9475
9498
  apiKeyDigest,
@@ -9489,7 +9512,7 @@ function initIdentity(options) {
9489
9512
  captureLogs: options.captureLogs ?? false,
9490
9513
  pii: options.pii ?? null,
9491
9514
  version: options.version ?? null,
9492
- endpoint: options.endpoint ?? DEFAULT_INGEST_ENDPOINT,
9515
+ endpoint: resolveInitEndpoint(options.endpoint),
9493
9516
  batchSize: options.batchSize ?? 100,
9494
9517
  flushInterval: options.flushInterval ?? 5,
9495
9518
  piiEnabled: options.piiEnabled ?? null,
@@ -9569,12 +9592,7 @@ async function _performInit(options) {
9569
9592
  );
9570
9593
  }
9571
9594
  _deliveryDiagnostics = new DeliveryDiagnostics();
9572
- let resolvedKey;
9573
- if (options.apiKey && options.apiKey.trim()) {
9574
- resolvedKey = options.apiKey.trim();
9575
- } else {
9576
- resolvedKey = (process.env.NEATLOGS_API_KEY ?? "").trim();
9577
- }
9595
+ let resolvedKey = resolveApiKey(options.apiKey);
9578
9596
  let disableExportResolved = !!options.disableExport || ["true", "1", "yes"].includes(
9579
9597
  (process.env.NEATLOGS_DISABLE_EXPORT ?? "").toLowerCase()
9580
9598
  );
@@ -9595,8 +9613,8 @@ async function _performInit(options) {
9595
9613
  }
9596
9614
  _debugMode2 = options.debug ?? false;
9597
9615
  const resolvedWorkflowName = _resolveWorkflowName(options.workflowName);
9598
- const endpoint = options.endpoint ?? DEFAULT_INGEST_ENDPOINT;
9599
- const baseUrl = new URL(endpoint).origin;
9616
+ const endpoint = resolveInitEndpoint(options.endpoint);
9617
+ const baseUrl = resolveIngestBaseUrl(endpoint);
9600
9618
  const uploadAuthority = disableExportResolved ? new DisabledUploadAuthority("export_disabled") : resolveUploadAuthority(
9601
9619
  options.uploadAuthority,
9602
9620
  process.env.NEATLOGS_UPLOADS_ENABLED,