{"version":3,"file":"server.cjs","sources":["../src/server/scrub.ts","../src/server/transport.ts","../src/server/client.ts","../src/server/global.ts","../src/server/integrations/express.ts","../src/server/integrations/http.ts"],"sourcesContent":["/**\n * Credential redaction.\n *\n * Ported deliberately from the Python SDK (nohmo_sdk/client.py) so both backend SDKs\n * redact the same things — a header that is safe in one language must not be a leak in\n * the other.\n */\n\n/**\n * Written in whatever form reads naturally, then normalised once below.\n *\n * Comparing a normalised key against a NON-normalised set is a silent credential leak:\n * 'X-API-Key' normalises to 'x_api_key' and would never match an entry stored as\n * 'x-api-key'. That exact bug shipped in the Python SDK before review caught it.\n */\nconst SENSITIVE_KEY_SOURCE = [\n  'authorization', 'proxy-authorization', 'cookie', 'set-cookie',\n  'x-api-key', 'api-key', 'apikey', 'x-auth-token', 'auth',\n  'password', 'passwd', 'pwd', 'secret', 'token', 'access_token', 'refresh_token',\n  'id_token', 'session', 'sessionid', 'session_key', 'csrfmiddlewaretoken',\n  'csrf_token', 'x-csrftoken', 'private_key', 'client_secret', 'signature',\n  'credit_card', 'card_number', 'cvv', 'cvc', 'ssn', 'pin', 'otp',\n]\n\n/** Fold a header/field name to one comparable form: lowercase, hyphens as underscores. */\nexport function normaliseKey(key: string): string {\n  return key.trim().toLowerCase().replace(/-/g, '_')\n}\n\nconst SENSITIVE_KEYS = new Set(SENSITIVE_KEY_SOURCE.map(normaliseKey))\n\n/** Substrings that mark a key sensitive whatever it is wrapped in — catches\n *  'stripe_secret_key', 'user_password_hash', 'DB_PASSWORD' and friends. */\nconst SENSITIVE_SUBSTRINGS = [\n  'secret', 'password', 'passwd', 'token', 'apikey', 'api_key', 'private_key', 'credential',\n]\n\nconst REDACTED = '[redacted]'\nconst MAX_DEPTH = 6\nconst MAX_ARRAY = 50\n\nexport function isSensitive(key: string): boolean {\n  const norm = normaliseKey(key)\n  return SENSITIVE_KEYS.has(norm) || SENSITIVE_SUBSTRINGS.some((s) => norm.includes(s))\n}\n\n/**\n * Redact anything that looks like a credential. Key-based, case-insensitive, and\n * deliberately over-eager: over-redacting costs a little debuggability, under-redacting\n * puts someone's session token in a third-party database.\n *\n * Depth-limited so a deeply nested or self-referential object cannot hang the caller.\n * A `seen` set breaks true cycles, which are far easier to produce in JS than in Python —\n * `req.socket.parser.incoming === req` is a real cycle on a live node:http request.\n */\nexport function scrub(\n  data: Record<string, unknown> | null | undefined,\n  depth = 0,\n  seen: WeakSet<object> = new WeakSet(),\n): Record<string, unknown> {\n  if (!data || typeof data !== 'object' || Array.isArray(data)) return {}\n  if (depth >= MAX_DEPTH) return { '...': '[truncated]' }\n  if (seen.has(data)) return { '...': '[circular]' }\n  seen.add(data)\n\n  const out: Record<string, unknown> = {}\n  for (const k of Object.keys(data)) {\n    const v = (data as Record<string, unknown>)[k]\n    if (isSensitive(k)) {\n      out[k] = REDACTED\n    } else if (Array.isArray(v)) {\n      out[k] = v.slice(0, MAX_ARRAY).map((i) =>\n        i && typeof i === 'object' && !Array.isArray(i)\n          ? scrub(i as Record<string, unknown>, depth + 1, seen)\n          : safeScalar(i),\n      )\n    } else if (v && typeof v === 'object') {\n      out[k] = scrub(v as Record<string, unknown>, depth + 1, seen)\n    } else {\n      out[k] = safeScalar(v)\n    }\n  }\n  return out\n}\n\n/**\n * Anything that is not JSON-safe becomes a string.\n *\n * JSON.stringify would throw on a BigInt and silently drop a function or undefined, so a\n * single odd value in someone's `extra` could otherwise cost the whole batch.\n */\nfunction safeScalar(v: unknown): unknown {\n  const t = typeof v\n  if (v === null || t === 'string' || t === 'number' || t === 'boolean') {\n    return t === 'number' && !Number.isFinite(v as number) ? String(v) : v\n  }\n  if (t === 'bigint') return String(v)\n  if (t === 'undefined') return null\n  if (t === 'function' || t === 'symbol') return `[${t}]`\n  return String(v)\n}\n","/**\n * HTTP transport for the Node server SDK.\n *\n * Uses node:http/node:https directly rather than global fetch. fetch (undici) keeps a\n * pooled keep-alive socket that can hold the event loop open past the end of a short-lived\n * script, which is exactly the case — a cron job, a Lambda — where losing the final batch\n * matters most. A plain request we control can be unref'd and ended deterministically.\n *\n * Sent uncompressed, deliberately. The ingest endpoint reads the body and JSON.parses it\n * directly; Django does not decompress request bodies, so a Content-Encoding: gzip request\n * comes back 400 \"Invalid JSON\" — and 400 is not retryable, so those events vanish. The\n * Python SDK shipped that bug once; not repeating it here.\n */\nimport { request as httpRequest } from 'node:http'\nimport { request as httpsRequest } from 'node:https'\nimport { URL } from 'node:url'\n\n/** Worth trying again. Any other 4xx means the request is wrong and will stay wrong. */\nconst RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504])\n\nexport interface TransportResult {\n  ok: boolean\n  status?: number\n}\n\nexport class Transport {\n  private endpoint: string\n  private apiKey: string\n  private timeoutMs: number\n  private maxRetries: number\n  private userAgent: string\n  private debug: boolean\n\n  /** Set when the server tells us to back off. Until it passes we drop rather than send —\n   *  a struggling ingest endpoint must not be hammered by every app server at once. */\n  private blockedUntil = 0\n  /**\n   * Network failures are logged at debug only, which means an SDK that cannot reach the\n   * server at all — blocked egress, TLS failure, bad DNS — would say nothing under a\n   * normal logging setup. For a tool whose job is telling you when things break, failing\n   * invisibly is the worst mode. Warn once on becoming unreachable, once on recovery.\n   */\n  private unreachable = false\n  private lastError: Error | null = null\n\n  constructor(opts: {\n    endpoint: string\n    apiKey: string\n    timeoutMs?: number\n    maxRetries?: number\n    userAgent: string\n    debug?: boolean\n  }) {\n    this.endpoint = opts.endpoint\n    this.apiKey = opts.apiKey\n    this.timeoutMs = opts.timeoutMs ?? 5000\n    this.maxRetries = opts.maxRetries ?? 3\n    this.userAgent = opts.userAgent\n    this.debug = opts.debug ?? false\n  }\n\n  /** Send a batch. Resolves true if accepted. Never rejects. */\n  async send(events: unknown[]): Promise<boolean> {\n    if (!events.length) return true\n    if (Date.now() < this.blockedUntil) {\n      this.log(`rate limited by server, dropping ${events.length} event(s)`)\n      return false\n    }\n\n    let body: string\n    try {\n      body = JSON.stringify({ events, apiKey: this.apiKey })\n    } catch (err) {\n      // A value that cannot be serialised must not take the process down. scrub()\n      // normally prevents this; this is the backstop.\n      this.warn(`could not serialise ${events.length} event(s) — dropped (${String(err)})`)\n      return false\n    }\n\n    for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n      const { ok, retryable, retryAfter } = await this.attempt(body)\n      if (ok) {\n        if (this.unreachable) {\n          this.warn(`connection to ${this.endpoint} restored`)\n          this.unreachable = false\n        }\n        return true\n      }\n      if (!retryable || attempt === this.maxRetries) {\n        if (retryable && this.lastError && !this.unreachable) {\n          this.unreachable = true\n          this.warn(\n            `cannot reach ${this.endpoint} (${this.lastError.message}) — events are being ` +\n            'dropped. Check outbound network access and TLS from this host.',\n          )\n        }\n        return false\n      }\n      if (retryAfter != null) {\n        this.blockedUntil = Date.now() + retryAfter * 1000\n        return false\n      }\n      // Full jitter, so N app servers retrying after a blip do not resynchronise into a\n      // thundering herd.\n      await sleep(Math.random() * Math.min(2 ** attempt, 8) * 1000)\n    }\n    return false\n  }\n\n  private attempt(body: string): Promise<{\n    ok: boolean; retryable: boolean; retryAfter: number | null\n  }> {\n    // Cleared per attempt so a stale network error cannot make a later HTTP 5xx look like\n    // an unreachable host.\n    this.lastError = null\n\n    return new Promise((resolve) => {\n      let url: URL\n      try {\n        url = new URL(this.endpoint)\n      } catch (err) {\n        // A typo'd endpoint can never start working. Fail fast and say so once.\n        this.warn(`invalid endpoint ${this.endpoint} — events dropped`)\n        resolve({ ok: false, retryable: false, retryAfter: null })\n        return\n      }\n\n      const doRequest = url.protocol === 'https:' ? httpsRequest : httpRequest\n      let settled = false\n      const finish = (r: { ok: boolean; retryable: boolean; retryAfter: number | null }) => {\n        if (settled) return\n        settled = true\n        resolve(r)\n      }\n\n      const req = doRequest(\n        {\n          protocol: url.protocol,\n          hostname: url.hostname,\n          port: url.port || undefined,\n          path: `${url.pathname}${url.search}`,\n          method: 'POST',\n          headers: {\n            'Content-Type': 'application/json',\n            'Content-Length': Buffer.byteLength(body),\n            'X-API-Key': this.apiKey,\n            'User-Agent': this.userAgent,\n          },\n        },\n        (res) => {\n          const status = res.statusCode ?? 0\n          // Drain, or the socket is never released back to the pool.\n          res.resume()\n          res.on('end', () => {\n            if (status >= 200 && status < 300) {\n              finish({ ok: true, retryable: false, retryAfter: null })\n              return\n            }\n            if (status === 401 || status === 403) {\n              // A bad API key will never start working. Say so once, loudly.\n              this.warn(`rejected (HTTP ${status}) — check your API key`)\n              finish({ ok: false, retryable: false, retryAfter: null })\n              return\n            }\n            let retryAfter: number | null = null\n            if (status === 429 || status === 503) {\n              const raw = res.headers['retry-after']\n              const n = Number(Array.isArray(raw) ? raw[0] : raw)\n              retryAfter = Number.isFinite(n) ? Math.max(0, n) : null\n            }\n            finish({ ok: false, retryable: RETRYABLE_STATUS.has(status), retryAfter })\n          })\n        },\n      )\n\n      req.setTimeout(this.timeoutMs, () => {\n        this.lastError = new Error(`timeout after ${this.timeoutMs}ms`)\n        req.destroy()\n        finish({ ok: false, retryable: true, retryAfter: null })\n      })\n\n      req.on('error', (err: Error) => {\n        this.lastError = err\n        this.log(`send failed (${err.message})`)\n        finish({ ok: false, retryable: true, retryAfter: null })\n      })\n\n      req.end(body)\n    })\n  }\n\n  private log(msg: string): void {\n    if (this.debug) console.log(`nohmo: ${msg}`)\n  }\n\n  private warn(msg: string): void {\n    console.warn(`nohmo: ${msg}`)\n  }\n}\n\nfunction sleep(ms: number): Promise<void> {\n  return new Promise((resolve) => {\n    // unref so a pending backoff can never hold a short-lived process open.\n    const t = setTimeout(resolve, ms)\n    if (typeof t.unref === 'function') t.unref()\n  })\n}\n","/**\n * The Node server client.\n *\n * Mirrors nohmo-sdk (Python) so both backends behave identically: same event type, same\n * platform, same dedup and sampling semantics, same PII posture. Where the two differ it\n * is because the runtime forces it, and those places are commented.\n */\nimport { hostname } from 'node:os'\nimport { scrub } from './scrub'\nimport { Transport } from './transport'\nimport type {\n  CaptureOptions, NohmoServerOptions, RequestContext, ServerEvent, UserContext,\n} from './types'\n\nexport const DEFAULT_ENDPOINT = 'https://www.nohmo.in/api/tracker/track/'\n\nconst DEFAULT_QUEUE_SIZE = 1000\nconst DEFAULT_BATCH_SIZE = 50\nconst DEFAULT_FLUSH_INTERVAL = 5      // seconds\nconst DEFAULT_DEDUP_WINDOW = 5        // seconds\n\nconst MAX_MESSAGE_CHARS = 1000\nconst MAX_STACK_CHARS = 8000\n\n/** Read at module load so the bundled build has no import-time cost per event. */\nconst SDK_VERSION = '__NOHMO_VERSION__'\n\nexport class ServerClient {\n  private projectId: string\n  private apiKey: string\n  private environment: string\n  private release: string\n  private serverName: string\n  private sampleRate: number\n  private dedupWindow: number\n  private queueSize: number\n  private batchSize: number\n  private sendDefaultPii: boolean\n  private debug: boolean\n\n  private transport: Transport\n  private queue: ServerEvent[] = []\n  private timer: ReturnType<typeof setInterval> | null = null\n  /** Signature -> last-sent epoch ms, for the dedup window. */\n  private recent = new Map<string, number>()\n  private closed = false\n  /** Number of in-flight sends, so flush() can wait for real completion. */\n  private inFlight = 0\n\n  readonly instanceId: string\n\n  constructor(opts: NohmoServerOptions) {\n    this.projectId = opts.projectId\n    this.apiKey = opts.apiKey\n    this.environment = opts.environment ?? 'production'\n    this.release = opts.release ?? ''\n    this.serverName = opts.serverName ?? safeHostname()\n    this.sampleRate = clamp(opts.sampleRate ?? 1, 0, 1)\n    this.dedupWindow = opts.dedupWindow ?? DEFAULT_DEDUP_WINDOW\n    this.queueSize = opts.queueSize ?? DEFAULT_QUEUE_SIZE\n    this.batchSize = opts.batchSize ?? DEFAULT_BATCH_SIZE\n    this.sendDefaultPii = opts.sendDefaultPii ?? false\n    this.debug = opts.debug ?? false\n\n    // One \"device\" per process, so the dashboard can tell instances apart without\n    // treating every request as a new visitor.\n    this.instanceId = `server:${this.serverName}:${process.pid}`\n\n    this.transport = new Transport({\n      endpoint: opts.endpoint ?? DEFAULT_ENDPOINT,\n      apiKey: this.apiKey,\n      userAgent: `nohmo-node/${SDK_VERSION}`,\n      debug: this.debug,\n    })\n\n    const intervalMs = (opts.flushInterval ?? DEFAULT_FLUSH_INTERVAL) * 1000\n    this.timer = setInterval(() => { void this.drain() }, intervalMs)\n    // unref is the whole difference from the Python design: a Node timer keeps the event\n    // loop alive, so without this an app that imports the SDK would simply never exit.\n    if (typeof this.timer.unref === 'function') this.timer.unref()\n  }\n\n  captureException(err: unknown, opts: CaptureOptions = {}): void {\n    const { message, type, stack } = describeError(err)\n    this.enqueue(message, type, stack, opts)\n  }\n\n  captureMessage(message: string, opts: CaptureOptions = {}): void {\n    this.enqueue(String(message), 'Message', '', { handled: true, ...opts })\n  }\n\n  /**\n   * Send everything queued and wait for it. Resolves false if anything was dropped.\n   *\n   * Node has no background thread, so unlike the Python SDK there is nothing to join —\n   * what we wait on is the in-flight request promises.\n   */\n  async flush(timeoutMs = 5000): Promise<boolean> {\n    const deadline = Date.now() + timeoutMs\n    let ok = await this.drain()\n    while (this.inFlight > 0 && Date.now() < deadline) {\n      await sleep(20)\n    }\n    if (this.queue.length) ok = false\n    return ok\n  }\n\n  /** Flush and stop the timer. After this the client accepts nothing further. */\n  async close(timeoutMs = 3000): Promise<boolean> {\n    const ok = await this.flush(timeoutMs)\n    if (this.timer) {\n      clearInterval(this.timer)\n      this.timer = null\n    }\n    this.closed = true\n    return ok\n  }\n\n  // ── internals ────────────────────────────────────────────────────────────\n  private enqueue(\n    message: string, type: string, stack: string, opts: CaptureOptions,\n  ): void {\n    if (this.closed) return\n    try {\n      if (this.sampleRate < 1 && Math.random() >= this.sampleRate) return\n\n      // Dedup on the shape of the error, not its text alone, so a hot loop reports once\n      // per window instead of thousands of times.\n      const sig = `${type}|${firstFrame(stack)}|${message.slice(0, 200)}`\n      const now = Date.now()\n      const last = this.recent.get(sig)\n      if (last != null && now - last < this.dedupWindow * 1000) return\n      this.recent.set(sig, now)\n      if (this.recent.size > 500) this.pruneRecent(now)\n\n      const event = this.buildEvent(message, type, stack, opts)\n\n      if (this.queue.length >= this.queueSize) {\n        // Bounded on purpose. A crash loop generates errors faster than any network can\n        // ship them; an unbounded queue there is a memory leak that ends in an OOM kill —\n        // the SDK becoming the outage. Drop the oldest, keep the newest.\n        this.queue.shift()\n      }\n      this.queue.push(event)\n      if (this.queue.length >= this.batchSize) void this.drain()\n    } catch (err) {\n      // Capturing an error must never itself throw into the customer's request path.\n      this.log(`capture failed (${String(err)})`)\n    }\n  }\n\n  private buildEvent(\n    message: string, type: string, stack: string, opts: CaptureOptions,\n  ): ServerEvent {\n    const req: RequestContext = opts.request ?? {}\n    const user: UserContext = opts.user ?? {}\n\n    const data: Record<string, unknown> = {\n      message: truncate(message, MAX_MESSAGE_CHARS),\n      type,\n      stack: truncate(stack, MAX_STACK_CHARS),\n      handled: opts.handled ?? true,\n      environment: this.environment,\n      serverName: this.serverName,\n      runtime: `node/${process.version.replace(/^v/, '')}`,\n    }\n    if (this.release) data.release = this.release\n    if (opts.extra) data.extra = scrub(opts.extra)\n    if (req.method) data.method = String(req.method).slice(0, 10)\n\n    if (this.sendDefaultPii) {\n      if (req.headers) data.headers = scrub(req.headers)\n      if (req.query) data.query = scrub(req.query)\n      if (req.ip) data.ip = req.ip\n      if (user.email) data.userEmail = user.email\n    }\n\n    return {\n      deviceId: this.instanceId,\n      userId: user.id != null ? String(user.id).slice(0, 255) : null,\n      // Empty unless the app supplies a correlation id.\n      //\n      // A fresh id per error made the ingest pipeline mint one Session row per exception,\n      // each with a single event and zero duration — which lands in the customer's own\n      // Overview and drags their average session time to nothing. The Python SDK shipped\n      // that and it had to be fixed; do not reintroduce it here.\n      sessionId: req.requestId ? String(req.requestId).slice(0, 255) : '',\n      event: 'SERVER_ERROR',\n      data,\n      page: req.path ? String(req.path).slice(0, 500) : '',\n      referrer: '',\n      ts: Date.now(),\n      platform: 'server',\n    }\n  }\n\n  /** Ship whatever is queued, in batches. Returns false if any batch was rejected. */\n  private async drain(): Promise<boolean> {\n    if (!this.queue.length) return true\n    let allOk = true\n    while (this.queue.length) {\n      const batch = this.queue.splice(0, this.batchSize)\n      this.inFlight++\n      try {\n        const ok = await this.transport.send(batch)\n        if (!ok) allOk = false\n      } catch (err) {\n        allOk = false\n        this.log(`drain failed (${String(err)})`)\n      } finally {\n        this.inFlight--\n      }\n    }\n    return allOk\n  }\n\n  private pruneRecent(now: number): void {\n    const cutoff = now - this.dedupWindow * 1000\n    for (const [k, t] of this.recent) {\n      if (t < cutoff) this.recent.delete(k)\n    }\n    // Still oversized after pruning (every entry is fresh): drop the oldest half rather\n    // than let the map grow without bound under a storm of distinct errors.\n    if (this.recent.size > 500) {\n      const keys = [...this.recent.keys()].slice(0, this.recent.size - 250)\n      for (const k of keys) this.recent.delete(k)\n    }\n  }\n\n  private log(msg: string): void {\n    if (this.debug) console.log(`nohmo: ${msg}`)\n  }\n}\n\n// ── helpers ────────────────────────────────────────────────────────────────\n\n/** Pull message/type/stack out of anything someone might throw. */\nexport function describeError(err: unknown): {\n  message: string; type: string; stack: string\n} {\n  if (err instanceof Error) {\n    return {\n      message: `${err.name}: ${err.message}`,\n      type: err.name || 'Error',\n      stack: err.stack ?? '',\n    }\n  }\n  // JS lets you throw literals, and plenty of libraries do.\n  if (typeof err === 'string') return { message: err, type: 'Error', stack: '' }\n  if (err && typeof err === 'object') {\n    const o = err as Record<string, unknown>\n    const msg = typeof o.message === 'string' ? o.message : safeStringify(err)\n    const type = typeof o.name === 'string' ? o.name : 'Error'\n    return { message: msg, type, stack: typeof o.stack === 'string' ? o.stack : '' }\n  }\n  return { message: String(err), type: 'Error', stack: '' }\n}\n\n/** First stack frame, used to keep same-message errors from different sites apart. */\nfunction firstFrame(stack: string): string {\n  for (const line of stack.split('\\n')) {\n    const t = line.trim()\n    if (t.startsWith('at ')) return t.slice(0, 200)\n  }\n  return ''\n}\n\nfunction truncate(s: string, max: number): string {\n  return s.length > max ? `${s.slice(0, max)}…[truncated]` : s\n}\n\nfunction safeStringify(v: unknown): string {\n  try {\n    return JSON.stringify(v) ?? String(v)\n  } catch {\n    return String(v)\n  }\n}\n\nfunction safeHostname(): string {\n  try {\n    return hostname() || 'unknown'\n  } catch {\n    return 'unknown'\n  }\n}\n\nfunction clamp(n: number, lo: number, hi: number): number {\n  return Number.isFinite(n) ? Math.min(hi, Math.max(lo, n)) : hi\n}\n\nfunction sleep(ms: number): Promise<void> {\n  return new Promise((resolve) => {\n    const t = setTimeout(resolve, ms)\n    if (typeof t.unref === 'function') t.unref()\n  })\n}\n","/**\n * The process-wide client singleton and the functions that use it.\n *\n * Split out from index.ts so the integrations can reach captureException without\n * importing the barrel that re-exports them. Going through index.ts created a genuine\n * import cycle (index -> express -> index), which in a CJS bundle can leave the binding\n * undefined at module-init time — the integration would silently report nothing.\n */\nimport { ServerClient } from './client'\nimport type { CaptureOptions, NohmoServerOptions } from './types'\n\nlet client: ServerClient | null = null\n\n/**\n * Kept so it can be detached again. Without this, every init() added another 'beforeExit'\n * listener and none were ever removed — Node starts printing MaxListenersExceededWarning\n * at eleven, and an app that re-inits on config reload would leak one per reload.\n */\nlet beforeExitHandler: (() => void) | null = null\n\nfunction detachBeforeExit(): void {\n  if (beforeExitHandler) {\n    process.removeListener('beforeExit', beforeExitHandler)\n    beforeExitHandler = null\n  }\n}\n\n/**\n * Initialise the global client. Returns it, or null if configuration was missing.\n *\n * Never throws: a missing env var must not stop a deploy. It logs once and disables\n * itself, the same posture the Django integration takes.\n */\nexport function init(options: NohmoServerOptions): ServerClient | null {\n  if (!options?.projectId || !options?.apiKey) {\n    console.warn('nohmo: init() called without projectId/apiKey — disabled')\n    client = null\n    return null\n  }\n  try {\n    detachBeforeExit()\n    client = new ServerClient(options)\n    // Best-effort final flush. 'beforeExit' does NOT fire on an explicit process.exit()\n    // or a fatal signal, which is exactly why flush() is public and documented for\n    // short-lived processes.\n    beforeExitHandler = () => { void client?.flush(2000) }\n    process.once('beforeExit', beforeExitHandler)\n    return client\n  } catch (err) {\n    console.warn(`nohmo: init failed — disabled (${String(err)})`)\n    client = null\n    return null\n  }\n}\n\nexport function isInitialised(): boolean {\n  return client !== null\n}\n\n/** Report an exception. Safe to call before init() — it is then a no-op. */\nexport function captureException(err: unknown, options: CaptureOptions = {}): void {\n  client?.captureException(err, options)\n}\n\n/** Report a message with no exception attached. */\nexport function captureMessage(message: string, options: CaptureOptions = {}): void {\n  client?.captureMessage(message, options)\n}\n\n/**\n * Send everything queued and wait for it.\n *\n * Call this before a short-lived process exits — a cron job, a Lambda, a one-off script.\n * Events are otherwise shipped on a timer that is deliberately unref'd, so it will not\n * hold the process open and will not get a chance to fire on the way out.\n */\nexport function flush(timeoutMs = 5000): Promise<boolean> {\n  return client ? client.flush(timeoutMs) : Promise.resolve(true)\n}\n\n/** Flush and stop. The client accepts nothing afterwards. */\nexport async function close(timeoutMs = 3000): Promise<boolean> {\n  detachBeforeExit()\n  if (!client) return true\n  const ok = await client.close(timeoutMs)\n  client = null\n  return ok\n}\n\n/** Escape hatch for tests and for apps that want more than one client. */\nexport function getClient(): ServerClient | null {\n  return client\n}\n","/**\n * Express integration.\n *\n *     import { init, expressErrorHandler } from 'nohmo/server'\n *\n *     init({ projectId: '...', apiKey: process.env.NOHMO_API_KEY })\n *\n *     app.get('/', handler)\n *     // ... all routes ...\n *     app.use(expressErrorHandler())   // LAST, after every route and router\n *\n * Placement is the opposite of the Django middleware's. Express error handlers only see\n * errors from middleware registered BEFORE them, so this goes last; Django's\n * process_exception hook sees what is below it, so that one goes first.\n */\nimport { captureException } from '../global'\nimport type { RequestContext, UserContext } from '../types'\n\n/** Structurally typed so the SDK never needs @types/express as a dependency. */\ninterface ReqLike {\n  path?: string\n  originalUrl?: string\n  url?: string\n  method?: string\n  headers?: Record<string, unknown>\n  query?: Record<string, unknown>\n  ip?: string\n  user?: unknown\n  id?: unknown\n}\ntype NextLike = (err?: unknown) => void\n\nexport interface ExpressHandlerOptions {\n  /**\n   * Decide whether an error is worth reporting. Return false to skip.\n   * Handy for 404s or validation errors that are expected traffic, not defects.\n   */\n  shouldReport?: (err: unknown, req: unknown) => boolean\n}\n\nexport function requestContext(req: ReqLike): RequestContext {\n  return {\n    // originalUrl keeps the mount prefix a router strips off req.url, which is what\n    // makes the reported path match the route the user actually hit.\n    path: stripQuery(req.originalUrl || req.path || req.url || ''),\n    method: req.method,\n    headers: req.headers,\n    query: req.query,\n    ip: req.ip,\n    // Set by common request-id middleware; becomes the event's sessionId so an error can\n    // be tied back to a request trace.\n    requestId: pickRequestId(req),\n  }\n}\n\nexport function userContext(req: ReqLike): UserContext | undefined {\n  const u = req.user as Record<string, unknown> | undefined\n  if (!u || typeof u !== 'object') return undefined\n  const id = u.id ?? u._id ?? u.userId ?? u.sub\n  const email = typeof u.email === 'string' ? u.email : undefined\n  if (id == null && !email) return undefined\n  return { id: id as string | number | undefined, email }\n}\n\n/**\n * Express error-handling middleware. Reports, then hands the error straight on — it never\n * swallows, so the app's own error page or JSON response is unchanged.\n */\nexport function expressErrorHandler(options: ExpressHandlerOptions = {}) {\n  // Express identifies error handlers by arity: it MUST declare four parameters, so\n  // `_next` cannot be removed even though renaming it would satisfy a linter.\n  return function nohmoErrorHandler(\n    err: unknown, req: ReqLike, _res: unknown, next: NextLike,\n  ): void {\n    try {\n      if (!options.shouldReport || options.shouldReport(err, req)) {\n        captureException(err, {\n          request: requestContext(req),\n          user: userContext(req),\n          handled: false,\n        })\n      }\n    } catch {\n      // Reporting must never replace the customer's error with one of ours.\n    }\n    next(err)\n  }\n}\n\nfunction stripQuery(url: string): string {\n  const i = url.indexOf('?')\n  return i === -1 ? url : url.slice(0, i)\n}\n\nfunction pickRequestId(req: ReqLike): string | undefined {\n  if (typeof req.id === 'string' && req.id) return req.id\n  const h = req.headers ?? {}\n  for (const key of ['x-request-id', 'x-correlation-id', 'x-amzn-trace-id']) {\n    const v = h[key]\n    const s = Array.isArray(v) ? v[0] : v\n    if (typeof s === 'string' && s) return s\n  }\n  return undefined\n}\n","/**\n * Raw node:http integration — the catch-all for anything without a dedicated adapter.\n *\n *     import { init, wrapHandler } from 'nohmo/server'\n *\n *     init({ projectId: '...', apiKey: process.env.NOHMO_API_KEY })\n *     http.createServer(wrapHandler(async (req, res) => { ... })).listen(3000)\n *\n * This is the Node counterpart of the Python SDK's WSGI wrapper: it works with Connect,\n * Koa's raw layer, Next's custom server, or a hand-rolled http server.\n */\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport { captureException } from '../global'\nimport type { RequestContext } from '../types'\n\ntype Handler = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>\n\nexport function httpRequestContext(req: IncomingMessage): RequestContext {\n  const url = req.url ?? ''\n  const qi = url.indexOf('?')\n  return {\n    path: qi === -1 ? url : url.slice(0, qi),\n    method: req.method,\n    headers: req.headers as Record<string, unknown>,\n    query: qi === -1 ? undefined : parseQuery(url.slice(qi + 1)),\n    ip: req.socket?.remoteAddress,\n    requestId: headerValue(req, 'x-request-id') ?? headerValue(req, 'x-correlation-id'),\n  }\n}\n\n/**\n * Wrap a handler so anything it throws — synchronously or from a rejected promise — is\n * reported and then rethrown.\n *\n * Rethrowing matters: swallowing here would leave the socket hanging open forever with no\n * response, turning an error the app could have handled into a stalled request.\n */\nexport function wrapHandler(handler: Handler): Handler {\n  return function nohmoWrapped(req: IncomingMessage, res: ServerResponse) {\n    const report = (err: unknown) => {\n      try {\n        captureException(err, { request: httpRequestContext(req), handled: false })\n      } catch {\n        /* never replace the app's error with ours */\n      }\n    }\n    try {\n      const out = handler(req, res)\n      // Only attach a catch when the handler is actually thenable — a sync handler\n      // returning undefined must not be coerced into a promise.\n      if (out && typeof (out as Promise<void>).then === 'function') {\n        return (out as Promise<void>).catch((err: unknown) => {\n          report(err)\n          throw err\n        })\n      }\n      return out\n    } catch (err) {\n      report(err)\n      throw err\n    }\n  }\n}\n\nfunction headerValue(req: IncomingMessage, name: string): string | undefined {\n  const v = req.headers[name]\n  const s = Array.isArray(v) ? v[0] : v\n  return typeof s === 'string' && s ? s : undefined\n}\n\nfunction parseQuery(qs: string): Record<string, unknown> {\n  const out: Record<string, unknown> = {}\n  for (const pair of qs.split('&')) {\n    if (!pair) continue\n    const i = pair.indexOf('=')\n    const k = i === -1 ? pair : pair.slice(0, i)\n    const v = i === -1 ? '' : pair.slice(i + 1)\n    try {\n      out[decodeURIComponent(k)] = decodeURIComponent(v)\n    } catch {\n      out[k] = v      // malformed percent-encoding: keep it raw rather than throw\n    }\n  }\n  return out\n}\n"],"names":["sleep","URL","httpsRequest","httpRequest","hostname"],"mappings":";;;;;;;AAAA;;;;;;AAMG;AAEH;;;;;;AAMG;AACH,MAAM,oBAAoB,GAAG;AAC3B,IAAA,eAAe,EAAE,qBAAqB,EAAE,QAAQ,EAAE,YAAY;AAC9D,IAAA,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM;IACxD,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe;AAC/E,IAAA,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,qBAAqB;AACxE,IAAA,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW;IACxE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;CAChE,CAAA;AAED;AACM,SAAU,YAAY,CAAC,GAAW,EAAA;AACtC,IAAA,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AACpD,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;AAEtE;AAC4E;AAC5E,MAAM,oBAAoB,GAAG;AAC3B,IAAA,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY;CAC1F,CAAA;AAED,MAAM,QAAQ,GAAG,YAAY,CAAA;AAC7B,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,MAAM,SAAS,GA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