ezlogs-nextjs 0.3.1 → 0.4.2

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.
Files changed (76) hide show
  1. package/README.md +149 -30
  2. package/bin/install-triggers.cjs +7 -2
  3. package/dist/actors/index.cjs +4 -4
  4. package/dist/actors/index.d.cts +1 -1
  5. package/dist/actors/index.d.ts +1 -1
  6. package/dist/actors/index.js +1 -1
  7. package/dist/{chunk-C5OSM557.js → chunk-FCFVIRQF.js} +7 -0
  8. package/dist/chunk-GI6BM4MR.js +443 -0
  9. package/dist/{chunk-YX2XPLOA.cjs → chunk-GMHOUAKD.cjs} +63 -34
  10. package/dist/{chunk-CU45I2WR.js → chunk-MHBS5FEP.js} +48 -20
  11. package/dist/chunk-MMLQXSSD.cjs +461 -0
  12. package/dist/{chunk-CE3R7DVB.js → chunk-NINIAL7M.js} +60 -384
  13. package/dist/{chunk-Y5NSHKWQ.cjs → chunk-NX4EL7BY.cjs} +57 -7
  14. package/dist/chunk-PS4U2GFJ.cjs +52 -0
  15. package/dist/chunk-R6IWVTX3.cjs +212 -0
  16. package/dist/{chunk-V5YNKKTG.cjs → chunk-TWTG5ILJ.cjs} +7 -0
  17. package/dist/chunk-U22T7QYY.js +200 -0
  18. package/dist/chunk-YMIGZYFH.js +48 -0
  19. package/dist/{chunk-WASXTDLW.cjs → chunk-YXZZNZG6.cjs} +71 -403
  20. package/dist/{chunk-DKRNNI4I.js → chunk-Z2TM3LGG.js} +53 -3
  21. package/dist/{configuration-OHLNivON.d.ts → configuration-CJ5yKVlP.d.cts} +14 -8
  22. package/dist/{configuration-OHLNivON.d.cts → configuration-CJ5yKVlP.d.ts} +14 -8
  23. package/dist/db/drizzle.cjs +5 -4
  24. package/dist/db/drizzle.js +3 -2
  25. package/dist/db/postgres-js.cjs +98 -0
  26. package/dist/db/postgres-js.d.cts +11 -0
  27. package/dist/db/postgres-js.d.ts +11 -0
  28. package/dist/db/postgres-js.js +95 -0
  29. package/dist/db/prisma.cjs +21 -20
  30. package/dist/db/prisma.d.cts +19 -2
  31. package/dist/db/prisma.d.ts +19 -2
  32. package/dist/db/prisma.js +6 -5
  33. package/dist/db/supabase.cjs +19 -12
  34. package/dist/db/supabase.d.cts +3 -2
  35. package/dist/db/supabase.d.ts +3 -2
  36. package/dist/db/supabase.js +11 -4
  37. package/dist/index.cjs +596 -165
  38. package/dist/index.d.cts +5 -3
  39. package/dist/index.d.ts +5 -3
  40. package/dist/index.js +492 -62
  41. package/dist/jobs/bullmq.cjs +63 -18
  42. package/dist/jobs/bullmq.d.cts +0 -4
  43. package/dist/jobs/bullmq.d.ts +0 -4
  44. package/dist/jobs/bullmq.js +59 -14
  45. package/dist/jobs/inngest.cjs +61 -24
  46. package/dist/jobs/inngest.d.cts +5 -1
  47. package/dist/jobs/inngest.d.ts +5 -1
  48. package/dist/jobs/inngest.js +55 -18
  49. package/dist/jobs/supabase-queues.cjs +17 -15
  50. package/dist/jobs/supabase-queues.d.cts +1 -1
  51. package/dist/jobs/supabase-queues.d.ts +1 -1
  52. package/dist/jobs/supabase-queues.js +15 -13
  53. package/dist/jobs/trigger.cjs +11 -12
  54. package/dist/jobs/trigger.d.cts +4 -3
  55. package/dist/jobs/trigger.d.ts +4 -3
  56. package/dist/jobs/trigger.js +7 -8
  57. package/dist/jobs/upstash-workflow.cjs +43 -35
  58. package/dist/jobs/upstash-workflow.d.cts +2 -8
  59. package/dist/jobs/upstash-workflow.d.ts +2 -8
  60. package/dist/jobs/upstash-workflow.js +38 -30
  61. package/dist/nextjs-plugin/index.cjs +39 -3
  62. package/dist/nextjs-plugin/index.d.cts +8 -1
  63. package/dist/nextjs-plugin/index.d.ts +8 -1
  64. package/dist/nextjs-plugin/index.js +39 -3
  65. package/dist/nextjs-plugin/loader.cjs +41 -3
  66. package/dist/nextjs-plugin/loader.d.cts +1 -0
  67. package/dist/nextjs-plugin/loader.d.ts +1 -0
  68. package/dist/nextjs-plugin/loader.js +42 -4
  69. package/dist/triggers/index.cjs +145 -92
  70. package/dist/triggers/index.d.cts +20 -5
  71. package/dist/triggers/index.d.ts +20 -5
  72. package/dist/triggers/index.js +125 -82
  73. package/package.json +11 -1
  74. package/sql/postgres/00_install.sql +1 -1
  75. package/dist/chunk-UQHEW6ER.js +0 -119
  76. package/dist/chunk-UWHYJH4M.cjs +0 -126
package/dist/index.cjs CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkY5NSHKWQ_cjs = require('./chunk-Y5NSHKWQ.cjs');
4
- var chunkYX2XPLOA_cjs = require('./chunk-YX2XPLOA.cjs');
5
- var chunkWASXTDLW_cjs = require('./chunk-WASXTDLW.cjs');
6
- var chunkV5YNKKTG_cjs = require('./chunk-V5YNKKTG.cjs');
3
+ var chunkNX4EL7BY_cjs = require('./chunk-NX4EL7BY.cjs');
4
+ var chunkGMHOUAKD_cjs = require('./chunk-GMHOUAKD.cjs');
5
+ var chunkYXZZNZG6_cjs = require('./chunk-YXZZNZG6.cjs');
6
+ var chunkMMLQXSSD_cjs = require('./chunk-MMLQXSSD.cjs');
7
+ var chunkTWTG5ILJ_cjs = require('./chunk-TWTG5ILJ.cjs');
7
8
  require('./chunk-ZDSQYCYV.cjs');
8
9
 
9
10
  // src/pipeline/transport.ts
@@ -11,10 +12,10 @@ var REQUEST_TIMEOUT_MS = 1e4;
11
12
  var transport = {
12
13
  async send(events) {
13
14
  if (!events || events.length === 0) return "success";
14
- const config = chunkWASXTDLW_cjs.configuration();
15
+ const config = chunkMMLQXSSD_cjs.configuration();
15
16
  const serverUrl = config.serverUrl;
16
17
  if (!serverUrl) {
17
- chunkV5YNKKTG_cjs.logger.error("Transport: serverUrl not configured");
18
+ chunkTWTG5ILJ_cjs.logger.error("Transport: serverUrl not configured");
18
19
  return "failure";
19
20
  }
20
21
  const url = `${stripTrailingSlash(serverUrl)}/api/events`;
@@ -34,14 +35,14 @@ var transport = {
34
35
  signal: controller.signal
35
36
  });
36
37
  if (response.status >= 200 && response.status < 300) {
37
- chunkV5YNKKTG_cjs.logger.debug(`Transport send succeeded (${response.status})`);
38
+ chunkTWTG5ILJ_cjs.logger.debug(`Transport send succeeded (${response.status})`);
38
39
  return "success";
39
40
  }
40
- chunkV5YNKKTG_cjs.logger.error(`Transport send failed (${response.status})`);
41
+ chunkTWTG5ILJ_cjs.logger.error(`Transport send failed (${response.status})`);
41
42
  return "failure";
42
43
  } catch (error) {
43
44
  const desc = describeError(error);
44
- chunkV5YNKKTG_cjs.logger.error(`Transport send failed: ${desc}`);
45
+ chunkTWTG5ILJ_cjs.logger.error(`Transport send failed: ${desc}`);
45
46
  return "failure";
46
47
  } finally {
47
48
  clearTimeout(timer);
@@ -76,7 +77,7 @@ var retrySender = {
76
77
  await sleepBeforeRetry(attempt);
77
78
  attempt += 1;
78
79
  }
79
- chunkV5YNKKTG_cjs.logger.error(
80
+ chunkTWTG5ILJ_cjs.logger.error(
80
81
  `RetrySender: failed after ${maxAttempts} attempts, dropping ${events.length} events`
81
82
  );
82
83
  return "failure";
@@ -86,7 +87,7 @@ async function attemptSend(events, attempt, maxAttempts) {
86
87
  try {
87
88
  return await transport.send(events);
88
89
  } catch (error) {
89
- chunkV5YNKKTG_cjs.logger.error(
90
+ chunkTWTG5ILJ_cjs.logger.error(
90
91
  `RetrySender: transport raised (attempt ${attempt}/${maxAttempts}): ${describeError2(error)}`
91
92
  );
92
93
  return "failure";
@@ -103,7 +104,7 @@ function applyJitter(base) {
103
104
  }
104
105
  function retryAttempts() {
105
106
  try {
106
- const value = chunkWASXTDLW_cjs.configuration().retryAttempts;
107
+ const value = chunkMMLQXSSD_cjs.configuration().retryAttempts;
107
108
  if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
108
109
  return 3;
109
110
  }
@@ -137,7 +138,7 @@ var flushScheduler = {
137
138
  if (typeof s.timer === "object" && s.timer !== null && "unref" in s.timer) {
138
139
  s.timer.unref();
139
140
  }
140
- chunkV5YNKKTG_cjs.logger.debug(`FlushScheduler started (interval ${interval}ms)`);
141
+ chunkTWTG5ILJ_cjs.logger.debug(`FlushScheduler started (interval ${interval}ms)`);
141
142
  },
142
143
  async stop() {
143
144
  const s = state();
@@ -145,7 +146,7 @@ var flushScheduler = {
145
146
  clearInterval(s.timer);
146
147
  s.timer = null;
147
148
  await tick();
148
- chunkV5YNKKTG_cjs.logger.debug("FlushScheduler stopped");
149
+ chunkTWTG5ILJ_cjs.logger.debug("FlushScheduler stopped");
149
150
  },
150
151
  isRunning() {
151
152
  return state().timer !== null;
@@ -160,18 +161,22 @@ async function tick() {
160
161
  if (s.inFlight) return;
161
162
  s.inFlight = true;
162
163
  try {
163
- const events = chunkWASXTDLW_cjs.drainEvents();
164
- if (events.length === 0) return;
165
- await retrySender.send(events);
164
+ const events = chunkYXZZNZG6_cjs.drainEvents();
165
+ if (events.length > 0) await retrySender.send(events);
166
+ const reader = chunkMMLQXSSD_cjs.configuration().databaseReader;
167
+ if (!reader) return;
168
+ await chunkGMHOUAKD_cjs.maintainAuditLogAfterRequests(reader);
169
+ const swept = chunkYXZZNZG6_cjs.drainEvents();
170
+ if (swept.length > 0) await retrySender.send(swept);
166
171
  } catch (error) {
167
- chunkV5YNKKTG_cjs.logger.error(`FlushScheduler tick failed: ${describeError3(error)}`);
172
+ chunkTWTG5ILJ_cjs.logger.error(`FlushScheduler tick failed: ${describeError3(error)}`);
168
173
  } finally {
169
174
  s.inFlight = false;
170
175
  }
171
176
  }
172
177
  function sendInterval() {
173
178
  try {
174
- const value = chunkWASXTDLW_cjs.configuration().sendInterval;
179
+ const value = chunkMMLQXSSD_cjs.configuration().sendInterval;
175
180
  if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
176
181
  return 5e3;
177
182
  }
@@ -194,13 +199,13 @@ function patchGlobalFetch() {
194
199
  if (typeof globalThis.fetch !== "function") return;
195
200
  originalFetch = globalThis.fetch;
196
201
  const wrapped = (input, init) => {
197
- const id = chunkWASXTDLW_cjs.current();
202
+ const id = chunkMMLQXSSD_cjs.current();
198
203
  if (!id) return originalFetch.call(globalThis, input, init);
199
204
  try {
200
205
  const enriched = injectHeader(input, init, id);
201
206
  return originalFetch.call(globalThis, enriched.input, enriched.init);
202
207
  } catch (error) {
203
- chunkV5YNKKTG_cjs.logger.debug(`outgoing-fetch injection failed: ${describeError4(error)}`);
208
+ chunkTWTG5ILJ_cjs.logger.debug(`outgoing-fetch injection failed: ${describeError4(error)}`);
204
209
  return originalFetch.call(globalThis, input, init);
205
210
  }
206
211
  };
@@ -330,7 +335,7 @@ function buildHttpSourceData(input) {
330
335
  source.graphql_variables = input.graphql.graphql_variables;
331
336
  }
332
337
  } else {
333
- const params = chunkWASXTDLW_cjs.sanitizeRequestParams(input.rawParams, input.excludedVariableKeys);
338
+ const params = chunkYXZZNZG6_cjs.sanitizeRequestParams(input.rawParams, input.excludedVariableKeys);
334
339
  if (params !== null) source.request_params = params;
335
340
  }
336
341
  return compact(source);
@@ -438,7 +443,7 @@ function parseServerActionName(name) {
438
443
  function stripTrailingS(entity) {
439
444
  if (entity.length <= 1) return entity;
440
445
  if (entity.endsWith("ies")) return `${entity.slice(0, -3)}y`;
441
- if (entity.endsWith("s") && !entity.endsWith("ss")) return entity.slice(0, -1);
446
+ if (entity.endsWith("s") && !/(ss|us|sis)$/i.test(entity)) return entity.slice(0, -1);
442
447
  return entity;
443
448
  }
444
449
  function deriveFormat(contentType) {
@@ -460,9 +465,11 @@ function compact(obj) {
460
465
  }
461
466
  function determineOutcome(statusCode, exception, graphqlResponseErrors, responseError = null) {
462
467
  if (exception) {
468
+ const issues = exception.issues;
469
+ const message = Array.isArray(issues) ? capErrorText(specificErrorMessage({ issues }) ?? "Validation failed") : exception.message;
463
470
  return {
464
471
  outcome: "failure",
465
- error_message: `${exception.name}: ${exception.message}`
472
+ error_message: `${exception.name}: ${message}`
466
473
  };
467
474
  }
468
475
  if (statusCode !== null && statusCode >= 400) {
@@ -471,8 +478,215 @@ function determineOutcome(statusCode, exception, graphqlResponseErrors, response
471
478
  if (graphqlResponseErrors) {
472
479
  return { outcome: "failure", error_message: graphqlResponseErrors };
473
480
  }
481
+ if (responseError) {
482
+ return { outcome: "failure", error_message: responseError };
483
+ }
474
484
  return { outcome: "success", error_message: null };
475
485
  }
486
+ var MAX_SPECIFIC_ERROR_LENGTH = 200;
487
+ function capErrorText(text) {
488
+ const out = chunkYXZZNZG6_cjs.scrubSecretsInText(text, { emails: true });
489
+ return out.length <= MAX_SPECIFIC_ERROR_LENGTH ? out : `${out.slice(0, MAX_SPECIFIC_ERROR_LENGTH - 1)}\u2026`;
490
+ }
491
+ var GENERIC_ERROR_TEXT = /^(?:validation(?: error| failed)?|invalid (?:input|request|data|body|payload|params|parameters|arguments)|bad request|unprocessable(?: entity| content)?|error|failed|request failed)[.!]?$/i;
492
+ function isGenericErrorText(text) {
493
+ return GENERIC_ERROR_TEXT.test(text.trim());
494
+ }
495
+ function specificErrorMessage(body, userPatterns = []) {
496
+ if (!isRecord(body)) return null;
497
+ const error = isRecord(body.error) ? body.error : {};
498
+ const details = isRecord(body.details) ? body.details : {};
499
+ for (const list of [body.details, body.issues, body.errors, error.issues, error.details]) {
500
+ if (!Array.isArray(list)) continue;
501
+ for (const issue of list) {
502
+ const found = issueMessage(issue, userPatterns);
503
+ if (found) return found;
504
+ }
505
+ }
506
+ for (const flat of [body, details, error]) {
507
+ const fields = isRecord(flat.fieldErrors) ? flat.fieldErrors : null;
508
+ for (const [field, value] of Object.entries(fields ?? {})) {
509
+ const found = fieldMessage([field], firstString(value), userPatterns);
510
+ if (found) return found;
511
+ }
512
+ const form = fieldMessage([], firstString(flat.formErrors), userPatterns);
513
+ if (form) return form;
514
+ }
515
+ return null;
516
+ }
517
+ function issueMessage(issue, userPatterns = []) {
518
+ if (!isRecord(issue) || typeof issue.message !== "string") return null;
519
+ const path = Array.isArray(issue.path) ? issue.path.map(pathKey) : [];
520
+ return fieldMessage(path, issue.message, userPatterns);
521
+ }
522
+ function fieldMessage(path, message, userPatterns) {
523
+ const text = message?.replace(/\s+/g, " ").trim().replace(/received\s+("[^"]*"|'[^']*'|`[^`]*`)/gi, "received [FILTERED]");
524
+ if (!text) return null;
525
+ const keys = path.filter((k) => k !== null && k !== "");
526
+ if (keys.some((k) => chunkYXZZNZG6_cjs.isSensitiveKey(k, userPatterns))) return null;
527
+ if (keys.length > 0) return `${keys.join(".")}: ${text}`;
528
+ return text.split(/[^A-Za-z0-9_]+/).some((w) => w !== "" && chunkYXZZNZG6_cjs.isSensitiveKey(w, userPatterns)) ? null : text;
529
+ }
530
+ function pathKey(segment) {
531
+ if (typeof segment === "string") return segment;
532
+ if (isRecord(segment) && typeof segment.key === "string") return segment.key;
533
+ return null;
534
+ }
535
+ function firstString(value) {
536
+ if (typeof value === "string") return value;
537
+ if (Array.isArray(value) && typeof value[0] === "string") return value[0];
538
+ return null;
539
+ }
540
+ function isRecord(value) {
541
+ return value !== null && typeof value === "object" && !Array.isArray(value);
542
+ }
543
+
544
+ // src/http/trpc.ts
545
+ function isRecord2(value) {
546
+ return value !== null && typeof value === "object" && !Array.isArray(value);
547
+ }
548
+ function isSuperjsonEnvelope(value) {
549
+ if (!isRecord2(value) || !("json" in value)) return false;
550
+ return Object.keys(value).every((k) => k === "json" || k === "meta");
551
+ }
552
+ function unwrap(value) {
553
+ return isSuperjsonEnvelope(value) ? value.json : value;
554
+ }
555
+ function isIndexed(value) {
556
+ const keys = Object.keys(value);
557
+ return keys.length > 0 && keys.every((k, i) => k === String(i));
558
+ }
559
+ function safeJsonParse(text) {
560
+ try {
561
+ return JSON.parse(text);
562
+ } catch {
563
+ return void 0;
564
+ }
565
+ }
566
+ function isTrpcRoute(raw, routeModulePath = null) {
567
+ return isRecord2(raw) && "trpc" in raw || routeModulePath?.includes("[trpc]") === true;
568
+ }
569
+ function unwrapTrpcParams(raw, url, routeModulePath = null) {
570
+ if (!isRecord2(raw) || !isTrpcRoute(raw, routeModulePath)) return raw;
571
+ const batch = url.searchParams.get("batch") === "1";
572
+ const rest = {};
573
+ let payload = void 0;
574
+ if (typeof raw.input === "string") {
575
+ const parsed = safeJsonParse(raw.input);
576
+ if (parsed !== void 0) {
577
+ for (const [k, v] of Object.entries(raw)) if (k !== "input" && k !== "batch") rest[k] = v;
578
+ if (isSuperjsonEnvelope(parsed) || batch && isRecord2(parsed) && isIndexed(parsed)) payload = parsed;
579
+ else return liftInput(parsed, rest);
580
+ }
581
+ }
582
+ if (payload === void 0) {
583
+ const indexed = {};
584
+ for (const [k, v] of Object.entries(raw)) {
585
+ if (/^\d+$/.test(k)) indexed[k] = v;
586
+ else rest[k] = v;
587
+ }
588
+ const envelopes = Object.values(indexed);
589
+ if (isIndexed(indexed) && (batch || envelopes.every(isSuperjsonEnvelope))) {
590
+ payload = indexed;
591
+ } else if (isSuperjsonEnvelope(raw)) {
592
+ return liftInput(raw.json, {});
593
+ } else {
594
+ return raw;
595
+ }
596
+ }
597
+ if (isSuperjsonEnvelope(payload)) return liftInput(payload.json, rest);
598
+ const calls = Object.values(payload).map(unwrap);
599
+ if (calls.length === 1) return liftInput(calls[0], rest);
600
+ const out = {};
601
+ calls.forEach((input, i) => {
602
+ if (input !== null && input !== void 0) out[String(i)] = input;
603
+ });
604
+ return { ...out, ...rest };
605
+ }
606
+ function liftInput(input, rest) {
607
+ let out;
608
+ if (input === null || input === void 0) out = { ...rest };
609
+ else if (isRecord2(input)) out = { ...input, ...rest };
610
+ else out = { input, ...rest };
611
+ return Object.keys(out).length > 0 ? out : null;
612
+ }
613
+ function trpcErrorMessage(body, userPatterns = []) {
614
+ const items = Array.isArray(body) ? body : [body];
615
+ for (const item of items) {
616
+ if (!isRecord2(item)) continue;
617
+ const error = unwrap(item.error);
618
+ if (!isRecord2(error) || typeof error.message !== "string") continue;
619
+ const data = error.data;
620
+ if (!isRecord2(data) || typeof data.code !== "string") continue;
621
+ const reason = callReason(error.message.trim(), data.zodError, userPatterns);
622
+ if (!reason) continue;
623
+ const path = typeof data.path === "string" && data.path.length > 0 ? `${data.path}: ` : "";
624
+ return capErrorText(`${path}${reason}`);
625
+ }
626
+ return null;
627
+ }
628
+ function callReason(message, zodError, userPatterns) {
629
+ const specific = isRecord2(zodError) ? specificErrorMessage(zodError, userPatterns) : null;
630
+ if (specific) return specific;
631
+ if (message.startsWith("[") || message.startsWith("{")) {
632
+ const parsed = safeJsonParse(message);
633
+ const issues = Array.isArray(parsed) ? parsed : isRecord2(parsed) ? parsed.issues : null;
634
+ const fromIssues = Array.isArray(issues) ? specificErrorMessage({ issues }, userPatterns) : null;
635
+ if (fromIssues) return fromIssues;
636
+ if (parsed !== void 0) return "Validation failed";
637
+ }
638
+ return message.length > 0 ? message : null;
639
+ }
640
+ var MAX_STREAM_LINE = 16384;
641
+ function trpcStreamErrorScanner(userPatterns = []) {
642
+ const decoder = new TextDecoder();
643
+ let line = "";
644
+ let skipping = false;
645
+ let error = null;
646
+ let callChunks = null;
647
+ return {
648
+ get error() {
649
+ return error;
650
+ },
651
+ push(chunk) {
652
+ if (error) return;
653
+ const parts = decoder.decode(chunk, { stream: true }).split("\n");
654
+ for (let i = 0; i < parts.length; i++) {
655
+ if (!skipping) line += parts[i];
656
+ if (line.length > MAX_STREAM_LINE) {
657
+ line = "";
658
+ skipping = true;
659
+ }
660
+ if (i === parts.length - 1) return;
661
+ if (!skipping) {
662
+ if (callChunks) error = streamLineError(line, callChunks, userPatterns);
663
+ else callChunks = headCallChunks(line);
664
+ }
665
+ if (error) return;
666
+ line = "";
667
+ skipping = false;
668
+ }
669
+ }
670
+ };
671
+ }
672
+ function headCallChunks(text) {
673
+ const ids = /* @__PURE__ */ new Set();
674
+ const head = unwrap(safeJsonParse(text));
675
+ if (!isRecord2(head)) return ids;
676
+ for (const call of Object.values(head)) {
677
+ const ref = Array.isArray(call) ? call[1] : null;
678
+ if (Array.isArray(ref) && typeof ref[2] === "number") ids.add(ref[2]);
679
+ }
680
+ return ids;
681
+ }
682
+ function streamLineError(text, callChunks, userPatterns) {
683
+ const chunk = unwrap(safeJsonParse(text));
684
+ if (!Array.isArray(chunk) || chunk.length !== 3 || typeof chunk[0] !== "number") return null;
685
+ const value = chunk[2];
686
+ if (!Array.isArray(value)) return trpcErrorMessage({ error: value }, userPatterns);
687
+ if (!callChunks.has(chunk[0]) || !Array.isArray(value[0])) return null;
688
+ return trpcErrorMessage(value[0][0], userPatterns);
689
+ }
476
690
 
477
691
  // src/http/graphql.ts
478
692
  var QUERY_PREFIXES = ["Get", "Fetch", "List", "Find", "Load", "Search", "Query"];
@@ -492,7 +706,7 @@ function parseGraphqlBody(body, excludedOperations, excludedVariableKeys) {
492
706
  return { metadata: "skip" };
493
707
  }
494
708
  const operationType = inferOperationTypeFromQuery(queryString) ?? inferOperationTypeFromName(operationName);
495
- const sanitizedVariables = chunkWASXTDLW_cjs.sanitizeRequestParams(obj.variables, excludedVariableKeys);
709
+ const sanitizedVariables = chunkYXZZNZG6_cjs.sanitizeRequestParams(obj.variables, excludedVariableKeys);
496
710
  return {
497
711
  metadata: {
498
712
  graphql_operation: operationName ?? "anonymous",
@@ -550,7 +764,7 @@ function captureRoute(handler, context = {}) {
550
764
  return handler(...invokeArgs);
551
765
  };
552
766
  try {
553
- if (!chunkWASXTDLW_cjs.configuration().captureHttp) {
767
+ if (!chunkMMLQXSSD_cjs.configuration().captureHttp) {
554
768
  return Promise.resolve(runHandler(...args));
555
769
  }
556
770
  const request = args[0];
@@ -560,8 +774,8 @@ function captureRoute(handler, context = {}) {
560
774
  const snapshot = await snapshotRequest(request);
561
775
  if (snapshot === null) return Promise.resolve(runHandler(...args));
562
776
  snapshot.rawParams = mergeRouteParams(snapshot.rawParams, await readRouteParams(args[1]));
563
- const correlationId = chunkWASXTDLW_cjs.resolveCorrelation(request.headers ?? null);
564
- return await chunkWASXTDLW_cjs.runWithCorrelation(
777
+ const correlationId = chunkMMLQXSSD_cjs.resolveCorrelation(request.headers ?? null);
778
+ return await chunkMMLQXSSD_cjs.runWithCorrelation(
565
779
  correlationId,
566
780
  () => runWithActorAndAuditScope(async () => {
567
781
  await maybeRunActorHook(request);
@@ -571,13 +785,50 @@ function captureRoute(handler, context = {}) {
571
785
  let exception = null;
572
786
  let graphqlErrorMessage = null;
573
787
  let responseErrorMessage = null;
788
+ let followed = false;
789
+ let handlerMs = null;
790
+ const finish = async () => {
791
+ await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
792
+ await emitEvent({
793
+ snapshot,
794
+ context,
795
+ statusCode,
796
+ exception,
797
+ graphqlErrorMessage,
798
+ responseErrorMessage,
799
+ durationMs: handlerMs ?? Date.now() - startMs,
800
+ startedAt: new Date(startMs)
801
+ });
802
+ if (isServerless()) {
803
+ await flushScheduler.flushNow().catch(() => {
804
+ });
805
+ }
806
+ chunkMMLQXSSD_cjs.endCorrelationScope();
807
+ };
574
808
  try {
575
809
  response = await Promise.resolve(runHandler(...args));
810
+ handlerMs = Date.now() - startMs;
576
811
  statusCode = response.status;
577
812
  if (snapshot.graphqlBody !== null && response.status === 200) {
578
813
  graphqlErrorMessage = await readGraphqlErrors(response);
579
814
  }
580
- responseErrorMessage = await readResponseErrorMessage(response);
815
+ const trpcRoute = isTrpcRoute(snapshot.rawParams, context.routeModulePath ?? null);
816
+ responseErrorMessage = await readResponseErrorMessage(response, trpcRoute);
817
+ const trpcStream = responseErrorMessage === null && trpcRoute ? trpcStreamErrorScanner(chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys) : null;
818
+ const followedResponse = followBody(
819
+ response,
820
+ snapshot.method,
821
+ (streamError) => {
822
+ if (streamError) exception = streamError;
823
+ responseErrorMessage ??= trpcStream?.error ?? null;
824
+ return finish();
825
+ },
826
+ trpcStream ? (chunk) => trpcStream.push(chunk) : void 0
827
+ );
828
+ if (followedResponse) {
829
+ followed = true;
830
+ return followedResponse;
831
+ }
581
832
  return response;
582
833
  } catch (e) {
583
834
  const controlStatus = nextControlFlowStatus(e);
@@ -589,27 +840,13 @@ function captureRoute(handler, context = {}) {
589
840
  statusCode = 500;
590
841
  throw e;
591
842
  } finally {
592
- await maybeExtractSupabaseActor();
593
- await emitEvent({
594
- snapshot,
595
- context,
596
- statusCode,
597
- exception,
598
- graphqlErrorMessage,
599
- responseErrorMessage,
600
- durationMs: Date.now() - startMs,
601
- startedAt: new Date(startMs)
602
- });
603
- if (isServerless()) {
604
- await flushScheduler.flushNow().catch(() => {
605
- });
606
- }
843
+ if (!followed) await finish();
607
844
  }
608
845
  })
609
846
  );
610
847
  } catch (preCaptureError) {
611
848
  if (handlerInvoked) throw preCaptureError;
612
- chunkV5YNKKTG_cjs.logger.warn(
849
+ chunkTWTG5ILJ_cjs.logger.warn(
613
850
  `captureRoute pre-handler setup failed (${describeError5(preCaptureError)}); bypassing capture for this request`
614
851
  );
615
852
  return Promise.resolve(handler(...args));
@@ -625,12 +862,12 @@ function withMiddlewareCapture(middleware) {
625
862
  return middleware(req, ...mRest);
626
863
  };
627
864
  try {
628
- const correlationId = chunkWASXTDLW_cjs.resolveCorrelation(request.headers);
865
+ const correlationId = chunkMMLQXSSD_cjs.resolveCorrelation(request.headers);
629
866
  try {
630
867
  request.headers.set(CORRELATION_HEADER, correlationId);
631
868
  } catch {
632
869
  }
633
- return await chunkWASXTDLW_cjs.runWithCorrelation(
870
+ return await chunkMMLQXSSD_cjs.runWithCorrelation(
634
871
  correlationId,
635
872
  () => runWithActorAndAuditScope(async () => {
636
873
  const startMs = Date.now();
@@ -645,7 +882,7 @@ function withMiddlewareCapture(middleware) {
645
882
  try {
646
883
  if (shouldEmitPageNavigation(request)) {
647
884
  await maybeRunActorHook(request);
648
- await maybeExtractSupabaseActor();
885
+ await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
649
886
  await emitPageNavigationEvent({
650
887
  request,
651
888
  statusCode: typeof response?.status === "number" ? response.status : null,
@@ -654,14 +891,14 @@ function withMiddlewareCapture(middleware) {
654
891
  });
655
892
  }
656
893
  } catch (error) {
657
- chunkV5YNKKTG_cjs.logger.debug(`page navigation capture failed: ${describeError5(error)}`);
894
+ chunkTWTG5ILJ_cjs.logger.debug(`page navigation capture failed: ${describeError5(error)}`);
658
895
  }
659
896
  return response;
660
- })
897
+ }).finally(chunkMMLQXSSD_cjs.endCorrelationScope)
661
898
  );
662
899
  } catch (preCaptureError) {
663
900
  if (middlewareInvoked) throw preCaptureError;
664
- chunkV5YNKKTG_cjs.logger.warn(
901
+ chunkTWTG5ILJ_cjs.logger.warn(
665
902
  `withMiddlewareCapture pre-handler setup failed (${describeError5(preCaptureError)}); bypassing capture for this request`
666
903
  );
667
904
  return await Promise.resolve(middleware(request, ...rest));
@@ -670,9 +907,16 @@ function withMiddlewareCapture(middleware) {
670
907
  }
671
908
  function shouldEmitPageNavigation(request) {
672
909
  if (request.method !== "GET") return false;
673
- if (request.headers.get("next-action")) return false;
674
- if (request.headers.get("rsc")) return false;
675
- if (request.headers.get("next-router-prefetch")) return false;
910
+ const headers = request.headers;
911
+ if (headers.get("next-action")) return false;
912
+ for (const marker of ROUTER_FETCH_HEADERS) {
913
+ if (headers.get(marker) !== null) return false;
914
+ }
915
+ if (/prefetch|prerender/i.test(headers.get("sec-purpose") ?? headers.get("purpose") ?? "")) {
916
+ return false;
917
+ }
918
+ const fetchMode = headers.get("sec-fetch-mode");
919
+ if (fetchMode !== null && fetchMode !== "navigate") return false;
676
920
  let url;
677
921
  try {
678
922
  url = new URL(request.url);
@@ -684,6 +928,15 @@ function shouldEmitPageNavigation(request) {
684
928
  if (url.pathname.startsWith("/api/")) return false;
685
929
  return true;
686
930
  }
931
+ var ROUTER_FETCH_HEADERS = [
932
+ "rsc",
933
+ "next-router-prefetch",
934
+ "next-router-segment-prefetch",
935
+ "next-router-state-tree",
936
+ "next-url",
937
+ "x-middleware-prefetch",
938
+ "x-nextjs-data"
939
+ ];
687
940
  async function emitPageNavigationEvent(input) {
688
941
  try {
689
942
  await flushTriggerAuditLog();
@@ -702,27 +955,27 @@ async function emitPageNavigationEvent(input) {
702
955
  userAgent,
703
956
  remoteIp,
704
957
  contentType: null,
705
- excludedVariableKeys: chunkWASXTDLW_cjs.configuration().excludedGraphqlVariableKeys
958
+ excludedVariableKeys: chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys
706
959
  });
707
960
  const { outcome, error_message } = determineOutcome(
708
961
  input.statusCode,
709
962
  null,
710
963
  null
711
964
  );
712
- const event = chunkWASXTDLW_cjs.build({
965
+ const event = chunkYXZZNZG6_cjs.build({
713
966
  source_type: "http_request",
714
967
  source_data: sourceData,
715
968
  outcome,
716
- correlation_id: chunkWASXTDLW_cjs.current(),
969
+ correlation_id: chunkMMLQXSSD_cjs.current(),
717
970
  resource_ids: [],
718
- context: chunkWASXTDLW_cjs.getCurrentActor() ? { actor: chunkWASXTDLW_cjs.getCurrentActor() } : null,
971
+ context: chunkMMLQXSSD_cjs.getCurrentActor() ? { actor: chunkMMLQXSSD_cjs.getCurrentActor() } : null,
719
972
  duration_ms: input.durationMs,
720
973
  error_message,
721
974
  timestamp: input.startedAt
722
975
  });
723
- chunkWASXTDLW_cjs.pushEvent(event);
976
+ chunkYXZZNZG6_cjs.pushEvent(event);
724
977
  } catch (error) {
725
- chunkV5YNKKTG_cjs.logger.error(`page navigation emit failed: ${describeError5(error)}`);
978
+ chunkTWTG5ILJ_cjs.logger.error(`page navigation emit failed: ${describeError5(error)}`);
726
979
  }
727
980
  }
728
981
  function pageControllerFromPath(pathname) {
@@ -745,7 +998,7 @@ function capturePagesApi(handler, context = {}) {
745
998
  return handler(...invokeArgs);
746
999
  };
747
1000
  try {
748
- if (!chunkWASXTDLW_cjs.configuration().captureHttp) {
1001
+ if (!chunkMMLQXSSD_cjs.configuration().captureHttp) {
749
1002
  return Promise.resolve(runHandler(...args));
750
1003
  }
751
1004
  const req = args[0];
@@ -753,10 +1006,10 @@ function capturePagesApi(handler, context = {}) {
753
1006
  if (!req || !res) return Promise.resolve(runHandler(...args));
754
1007
  const snapshot = snapshotPagesRequest(req);
755
1008
  if (snapshot === null) return Promise.resolve(runHandler(...args));
756
- const correlationId = chunkWASXTDLW_cjs.resolveCorrelation({
1009
+ const correlationId = chunkMMLQXSSD_cjs.resolveCorrelation({
757
1010
  get: (name) => readPagesHeader(req, name)
758
1011
  });
759
- return await chunkWASXTDLW_cjs.runWithCorrelation(
1012
+ return await chunkMMLQXSSD_cjs.runWithCorrelation(
760
1013
  correlationId,
761
1014
  () => runWithActorAndAuditScope(async () => {
762
1015
  await maybeRunActorHookFromPages(req);
@@ -769,7 +1022,7 @@ function capturePagesApi(handler, context = {}) {
769
1022
  exception = e instanceof Error ? e : new Error(String(e));
770
1023
  throw e;
771
1024
  } finally {
772
- await maybeExtractSupabaseActor();
1025
+ await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
773
1026
  await emitEvent({
774
1027
  snapshot,
775
1028
  context,
@@ -782,12 +1035,13 @@ function capturePagesApi(handler, context = {}) {
782
1035
  if (isServerless()) {
783
1036
  await flushScheduler.flushNow().catch(() => void 0);
784
1037
  }
1038
+ chunkMMLQXSSD_cjs.endCorrelationScope();
785
1039
  }
786
1040
  })
787
1041
  );
788
1042
  } catch (preCaptureError) {
789
1043
  if (handlerInvoked) throw preCaptureError;
790
- chunkV5YNKKTG_cjs.logger.warn(
1044
+ chunkTWTG5ILJ_cjs.logger.warn(
791
1045
  `capturePagesApi pre-handler setup failed (${describeError5(preCaptureError)}); bypassing capture for this request`
792
1046
  );
793
1047
  return Promise.resolve(handler(...args));
@@ -802,12 +1056,12 @@ function captureServerAction(action, actionName) {
802
1056
  return action(...invokeArgs);
803
1057
  };
804
1058
  try {
805
- if (!chunkWASXTDLW_cjs.configuration().captureHttp) {
1059
+ if (!chunkMMLQXSSD_cjs.configuration().captureHttp) {
806
1060
  return Promise.resolve(runAction(...args));
807
1061
  }
808
1062
  const headersAdapter = await readNextHeadersAsAdapter();
809
- const correlationId = chunkWASXTDLW_cjs.resolveCorrelation(headersAdapter);
810
- return await chunkWASXTDLW_cjs.runWithCorrelation(
1063
+ const correlationId = chunkMMLQXSSD_cjs.resolveCorrelation(headersAdapter);
1064
+ return await chunkMMLQXSSD_cjs.runWithCorrelation(
811
1065
  correlationId,
812
1066
  () => runWithActorAndAuditScope(async () => {
813
1067
  const startMs = Date.now();
@@ -816,7 +1070,7 @@ function captureServerAction(action, actionName) {
816
1070
  await maybeRunActorHookFromServerAction();
817
1071
  try {
818
1072
  const result = await Promise.resolve(runAction(...args));
819
- await maybeExtractSupabaseActor();
1073
+ await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
820
1074
  const failure = classifyServerActionResult(result);
821
1075
  await emitServerActionEvent({
822
1076
  actionName,
@@ -832,7 +1086,7 @@ function captureServerAction(action, actionName) {
832
1086
  return result;
833
1087
  } catch (e) {
834
1088
  if (isNextControlFlowError(e)) {
835
- await maybeExtractSupabaseActor();
1089
+ await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
836
1090
  const controlStatus = nextControlFlowStatus(e) ?? 200;
837
1091
  await emitServerActionEvent({
838
1092
  actionName,
@@ -842,12 +1096,13 @@ function captureServerAction(action, actionName) {
842
1096
  exception: null,
843
1097
  durationMs: Date.now() - startMs,
844
1098
  startedAt,
845
- args
1099
+ args,
1100
+ redirectTo: redirectTarget(e)
846
1101
  });
847
1102
  throw e;
848
1103
  }
849
1104
  exception = e instanceof Error ? e : new Error(String(e));
850
- await maybeExtractSupabaseActor();
1105
+ await chunkMMLQXSSD_cjs.maybeExtractSupabaseActor();
851
1106
  await emitServerActionEvent({
852
1107
  actionName,
853
1108
  statusCode: 500,
@@ -861,12 +1116,13 @@ function captureServerAction(action, actionName) {
861
1116
  if (isServerless()) {
862
1117
  await flushScheduler.flushNow().catch(() => void 0);
863
1118
  }
1119
+ chunkMMLQXSSD_cjs.endCorrelationScope();
864
1120
  }
865
1121
  })
866
1122
  );
867
1123
  } catch (preCaptureError) {
868
1124
  if (actionInvoked) throw preCaptureError;
869
- chunkV5YNKKTG_cjs.logger.warn(
1125
+ chunkTWTG5ILJ_cjs.logger.warn(
870
1126
  `captureServerAction pre-handler setup failed (${describeError5(preCaptureError)}); bypassing capture for this action`
871
1127
  );
872
1128
  return Promise.resolve(action(...args));
@@ -888,7 +1144,7 @@ async function __ezlogs_run_inline_server_action(actionName, body) {
888
1144
  return wrapped();
889
1145
  }
890
1146
  function classifyServerActionResult(result) {
891
- const classifier = chunkWASXTDLW_cjs.configuration().isServerActionError;
1147
+ const classifier = chunkMMLQXSSD_cjs.configuration().isServerActionError;
892
1148
  if (classifier) {
893
1149
  try {
894
1150
  const verdict = classifier(result);
@@ -899,7 +1155,7 @@ function classifyServerActionResult(result) {
899
1155
  return verdict;
900
1156
  }
901
1157
  } catch (error) {
902
- chunkV5YNKKTG_cjs.logger.debug(`isServerActionError classifier threw: ${describeError5(error)}`);
1158
+ chunkTWTG5ILJ_cjs.logger.debug(`isServerActionError classifier threw: ${describeError5(error)}`);
903
1159
  }
904
1160
  }
905
1161
  if (Array.isArray(result) && result.length === 2 && result[0] === null && isZsaError(result[1])) {
@@ -933,11 +1189,45 @@ function classifyServerActionResult(result) {
933
1189
  };
934
1190
  }
935
1191
  if (r.success === false && typeof r.error === "string" && r.error.length > 0) {
936
- return { errorMessage: truncate(r.error) };
1192
+ return { errorMessage: specificOrOwn(r, r.error) };
1193
+ }
1194
+ const rowShaped = isRowShaped(r);
1195
+ if (!rowShaped && typeof r.error === "string" && r.error.trim().length > 0 && !r.success && !r.ok && r.data == null) {
1196
+ return { errorMessage: specificOrOwn(r, r.error.trim()) };
1197
+ }
1198
+ if (!rowShaped && !r.success && !r.ok && Object.keys(r).every((k) => FORM_STATE_KEYS.has(k)) && hasErrorEntries(r.errors)) {
1199
+ return { errorMessage: formStateErrorMessage(r) };
937
1200
  }
938
1201
  }
939
1202
  return null;
940
1203
  }
1204
+ var FORM_STATE_KEYS = /* @__PURE__ */ new Set([
1205
+ "errors",
1206
+ "message",
1207
+ "success",
1208
+ "ok",
1209
+ "status",
1210
+ "fields",
1211
+ "fieldErrors",
1212
+ "formErrors"
1213
+ ]);
1214
+ function isRowShaped(r) {
1215
+ return Object.keys(r).some((k) => k === "id" || /(^|_)(created|updated)_?at$/i.test(k));
1216
+ }
1217
+ function hasErrorEntries(errors, depth = 0) {
1218
+ if (typeof errors === "string") return errors.trim().length > 0;
1219
+ if (depth > 3 || errors === null || typeof errors !== "object") return false;
1220
+ return Object.values(errors).some((v) => hasErrorEntries(v, depth + 1));
1221
+ }
1222
+ function formStateErrorMessage(r) {
1223
+ const patterns = chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys;
1224
+ const specific = Array.isArray(r.errors) ? specificErrorMessage({ errors: r.errors }, patterns) ?? specificErrorMessage({ formErrors: r.errors }, patterns) : specificErrorMessage({ fieldErrors: r.errors }, patterns);
1225
+ if (specific) return capErrorText(specific);
1226
+ if (typeof r.message === "string" && r.message.trim().length > 0) {
1227
+ return capErrorText(r.message.trim());
1228
+ }
1229
+ return "Validation failed";
1230
+ }
941
1231
  function defaultErrorMessage(result) {
942
1232
  if (result && typeof result === "object" && !Array.isArray(result)) {
943
1233
  const r = result;
@@ -945,7 +1235,7 @@ function defaultErrorMessage(result) {
945
1235
  return truncate(r.serverError);
946
1236
  }
947
1237
  const err = r.error;
948
- if (typeof err === "string" && err.length > 0) return truncate(err);
1238
+ if (typeof err === "string" && err.length > 0) return specificOrOwn(r, err);
949
1239
  if (isZsaError(err)) return truncate(err.message);
950
1240
  if (isZodErrorLike(err)) {
951
1241
  return formatZodIssues(err.issues);
@@ -957,6 +1247,10 @@ function defaultErrorMessage(result) {
957
1247
  return "Server Action returned a failure result";
958
1248
  }
959
1249
  var MAX_ERROR_MESSAGE_LENGTH = 200;
1250
+ function specificOrOwn(result, error) {
1251
+ const specific = isGenericErrorText(error) ? specificErrorMessage(result, chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys) : null;
1252
+ return capErrorText(specific ?? error);
1253
+ }
960
1254
  function truncate(value) {
961
1255
  if (value.length <= MAX_ERROR_MESSAGE_LENGTH) return value;
962
1256
  return value.slice(0, MAX_ERROR_MESSAGE_LENGTH - 1) + "\u2026";
@@ -972,16 +1266,15 @@ function isZodErrorLike(value) {
972
1266
  return Array.isArray(issues) && issues.length > 0;
973
1267
  }
974
1268
  function formatZodIssues(issues) {
1269
+ const patterns = chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys;
975
1270
  const messages = [];
976
1271
  for (const issue of issues) {
977
- if (issue && typeof issue === "object") {
978
- const m = issue.message;
979
- if (typeof m === "string" && m.length > 0) messages.push(m);
980
- }
1272
+ const m = issueMessage(issue, patterns);
1273
+ if (m) messages.push(m);
981
1274
  if (messages.length >= 3) break;
982
1275
  }
983
1276
  if (messages.length === 0) return "Validation failed";
984
- return truncate(messages.join("; "));
1277
+ return capErrorText(messages.join("; "));
985
1278
  }
986
1279
  function hasNonEmptyValidationError(errors) {
987
1280
  for (const value of Object.values(errors)) {
@@ -1038,6 +1331,35 @@ function nextControlFlowStatus(error) {
1038
1331
  }
1039
1332
  return null;
1040
1333
  }
1334
+ function pathOf(url) {
1335
+ if (!url) return "";
1336
+ try {
1337
+ return new URL(url, "http://localhost").pathname;
1338
+ } catch {
1339
+ return "";
1340
+ }
1341
+ }
1342
+ function redirectTarget(error) {
1343
+ const digest = error?.digest;
1344
+ if (typeof digest !== "string" || !digest.startsWith("NEXT_REDIRECT;")) return null;
1345
+ const parts = digest.split(";").slice(2);
1346
+ while (parts.length > 0 && (parts[parts.length - 1] === "" || /^\d{3}$/.test(parts[parts.length - 1]))) {
1347
+ parts.pop();
1348
+ }
1349
+ return parts.length > 0 ? parts.join(";") : null;
1350
+ }
1351
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
1352
+ function redirectPath(target, requestHost) {
1353
+ try {
1354
+ const absolute = /^[a-z][a-z0-9+.-]*:/i.test(target) || target.startsWith("//");
1355
+ const url = new URL(target, "http://ezlogs.internal");
1356
+ if (absolute && (!requestHost || url.host.toLowerCase() !== requestHost.toLowerCase())) return null;
1357
+ const path = url.pathname.split("/").map((seg) => /^[A-Za-z0-9_-]{20,}$/.test(seg) && !UUID.test(seg) ? "[FILTERED]" : seg).join("/");
1358
+ return path ? chunkYXZZNZG6_cjs.scrubSecretsInText(path, { emails: true }) : null;
1359
+ } catch {
1360
+ return null;
1361
+ }
1362
+ }
1041
1363
  async function emitServerActionEvent(input) {
1042
1364
  try {
1043
1365
  await flushTriggerAuditLog();
@@ -1046,7 +1368,11 @@ async function emitServerActionEvent(input) {
1046
1368
  const userAgent = await readNextHeader("user-agent");
1047
1369
  const fromPage = referer ?? nextUrl ?? null;
1048
1370
  const argParams = extractServerActionArgs(input.args, input.actionName);
1049
- const requestParams = argParams !== null || fromPage !== null ? { ...argParams ?? {}, ...fromPage !== null ? { from_page: fromPage } : {} } : null;
1371
+ const combined = argParams !== null || fromPage !== null ? { ...argParams ?? {}, ...fromPage !== null ? { from_page: fromPage } : {} } : null;
1372
+ const requestParams = chunkYXZZNZG6_cjs.maskAuthParams(
1373
+ combined,
1374
+ chunkYXZZNZG6_cjs.isAuthActionName(input.actionName) || chunkYXZZNZG6_cjs.isAuthPath(pathOf(fromPage))
1375
+ );
1050
1376
  const syntheticUrl = new URL(
1051
1377
  `http://localhost/__server-action/${encodeURIComponent(input.actionName)}`
1052
1378
  );
@@ -1060,27 +1386,32 @@ async function emitServerActionEvent(input) {
1060
1386
  userAgent,
1061
1387
  remoteIp: extractRemoteIp(await readNextHeadersAsAdapter()),
1062
1388
  contentType: null,
1063
- excludedVariableKeys: chunkWASXTDLW_cjs.configuration().excludedGraphqlVariableKeys
1389
+ excludedVariableKeys: chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys
1064
1390
  });
1391
+ if (input.redirectTo) {
1392
+ const host = await readNextHeader("x-forwarded-host") ?? await readNextHeader("host");
1393
+ const redirectTo = redirectPath(input.redirectTo, host?.split(",")[0]?.trim() ?? null);
1394
+ if (redirectTo) sourceData.redirect_to = redirectTo;
1395
+ }
1065
1396
  const { outcome, error_message } = determineOutcome(
1066
1397
  input.statusCode,
1067
1398
  input.exception,
1068
1399
  null
1069
1400
  );
1070
- const event = chunkWASXTDLW_cjs.build({
1401
+ const event = chunkYXZZNZG6_cjs.build({
1071
1402
  source_type: "http_request",
1072
1403
  source_data: sourceData,
1073
1404
  outcome,
1074
- correlation_id: chunkWASXTDLW_cjs.current(),
1405
+ correlation_id: chunkMMLQXSSD_cjs.current(),
1075
1406
  resource_ids: [],
1076
- context: chunkWASXTDLW_cjs.getCurrentActor() ? { actor: chunkWASXTDLW_cjs.getCurrentActor() } : null,
1407
+ context: chunkMMLQXSSD_cjs.getCurrentActor() ? { actor: chunkMMLQXSSD_cjs.getCurrentActor() } : null,
1077
1408
  duration_ms: input.durationMs,
1078
1409
  error_message,
1079
1410
  timestamp: input.startedAt
1080
1411
  });
1081
- chunkWASXTDLW_cjs.pushEvent(event);
1412
+ chunkYXZZNZG6_cjs.pushEvent(event);
1082
1413
  } catch (error) {
1083
- chunkV5YNKKTG_cjs.logger.error(`server-action capture emit failed: ${describeError5(error)}`);
1414
+ chunkTWTG5ILJ_cjs.logger.error(`server-action capture emit failed: ${describeError5(error)}`);
1084
1415
  }
1085
1416
  }
1086
1417
  function extractServerActionArgs(args, actionName) {
@@ -1161,7 +1492,7 @@ function actionWords(name) {
1161
1492
  return name.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([a-zA-Z])(\d)/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
1162
1493
  }
1163
1494
  function looksLikeCardNumber(digits, paymentAction) {
1164
- if (digits.length < 13 || digits.length > 19 || !chunkWASXTDLW_cjs.passesLuhn(digits)) return false;
1495
+ if (digits.length < 13 || digits.length > 19 || !chunkYXZZNZG6_cjs.passesLuhn(digits)) return false;
1165
1496
  return paymentAction || digits.length === 15 || digits.length === 16;
1166
1497
  }
1167
1498
  function maskPositional(value, flags) {
@@ -1249,7 +1580,7 @@ function serializeArgValue(value) {
1249
1580
  return void 0;
1250
1581
  }
1251
1582
  async function captureHttpEvent(input) {
1252
- if (!chunkWASXTDLW_cjs.configuration().captureHttp) return;
1583
+ if (!chunkMMLQXSSD_cjs.configuration().captureHttp) return;
1253
1584
  const snapshot = await snapshotRequest(input.request);
1254
1585
  if (snapshot === null) return;
1255
1586
  let graphqlErrorMessage = null;
@@ -1295,7 +1626,7 @@ async function snapshotRequest(request) {
1295
1626
  try {
1296
1627
  if (contentType?.includes("application/json")) {
1297
1628
  const text = await cloned.text();
1298
- const parsed = text ? safeJsonParse(text) : null;
1629
+ const parsed = text ? safeJsonParse2(text) : null;
1299
1630
  if (isGraphql) graphqlBody = parsed;
1300
1631
  else rawParams = parsed;
1301
1632
  } else if (contentType?.includes("application/x-www-form-urlencoded")) {
@@ -1310,58 +1641,59 @@ async function snapshotRequest(request) {
1310
1641
  }
1311
1642
  }
1312
1643
  } catch (error) {
1313
- chunkV5YNKKTG_cjs.logger.debug(`http snapshot body-parse failed: ${describeError5(error)}`);
1644
+ chunkTWTG5ILJ_cjs.logger.debug(`http snapshot body-parse failed: ${describeError5(error)}`);
1314
1645
  }
1315
1646
  return { method, url, userAgent, remoteIp, contentType, rawParams, graphqlBody, serverActionId };
1316
1647
  }
1317
1648
  async function maybeRunActorHook(request) {
1318
- const hook = chunkWASXTDLW_cjs.configuration().actorFromRequest;
1649
+ const hook = chunkMMLQXSSD_cjs.configuration().actorFromRequest;
1319
1650
  let hookResult = null;
1320
1651
  if (hook) {
1321
1652
  try {
1322
1653
  hookResult = await Promise.resolve(hook(request));
1323
1654
  } catch (error) {
1324
- chunkV5YNKKTG_cjs.logger.debug(`actorFromRequest hook failed: ${describeError5(error)}`);
1655
+ chunkTWTG5ILJ_cjs.logger.debug(`actorFromRequest hook failed: ${describeError5(error)}`);
1325
1656
  }
1326
1657
  }
1327
1658
  const userAgent = safeGetHeader(request.headers, "user-agent");
1328
1659
  applyActorFromHookAndUa(hookResult, userAgent);
1329
1660
  }
1330
1661
  async function maybeRunActorHookFromPages(req) {
1331
- const hook = chunkWASXTDLW_cjs.configuration().actorFromRequest;
1662
+ const hook = chunkMMLQXSSD_cjs.configuration().actorFromRequest;
1332
1663
  let hookResult = null;
1333
1664
  if (hook) {
1334
1665
  try {
1335
- hookResult = await Promise.resolve(hook(req));
1666
+ const headers = req.headers instanceof Headers ? req.headers : toWebHeaders(req.headers);
1667
+ hookResult = await Promise.resolve(hook({ headers }));
1336
1668
  } catch (error) {
1337
- chunkV5YNKKTG_cjs.logger.debug(`actorFromRequest hook (pages) failed: ${describeError5(error)}`);
1669
+ chunkTWTG5ILJ_cjs.logger.debug(`actorFromRequest hook (pages) failed: ${describeError5(error)}`);
1338
1670
  }
1339
1671
  }
1340
1672
  const userAgent = readPagesHeader(req, "user-agent");
1341
1673
  applyActorFromHookAndUa(hookResult, userAgent);
1342
1674
  }
1343
1675
  async function maybeRunActorHookFromServerAction() {
1344
- const hook = chunkWASXTDLW_cjs.configuration().actorFromRequest;
1676
+ const hook = chunkMMLQXSSD_cjs.configuration().actorFromRequest;
1345
1677
  const headers = await loadNextHeaders();
1346
1678
  if (!hook && !headers) {
1347
- chunkV5YNKKTG_cjs.logger.debug("actorFromRequest (server action): no hook + no next/headers");
1679
+ chunkTWTG5ILJ_cjs.logger.debug("actorFromRequest (server action): no hook + no next/headers");
1348
1680
  return;
1349
1681
  }
1350
1682
  let hookResult = null;
1351
1683
  if (hook) {
1352
1684
  if (!headers) {
1353
- chunkV5YNKKTG_cjs.logger.debug(
1685
+ chunkTWTG5ILJ_cjs.logger.debug(
1354
1686
  "actorFromRequest hook (server action): skipped, no next/headers available"
1355
1687
  );
1356
1688
  } else {
1357
1689
  const facade = { headers, method: "POST", url: "" };
1358
1690
  try {
1359
1691
  hookResult = await Promise.resolve(hook(facade));
1360
- chunkV5YNKKTG_cjs.logger.debug(
1692
+ chunkTWTG5ILJ_cjs.logger.debug(
1361
1693
  hookResult ? `actorFromRequest hook (server action): set actor id=${hookResult.id ?? "?"}` : "actorFromRequest hook (server action): returned null/undefined"
1362
1694
  );
1363
1695
  } catch (error) {
1364
- chunkV5YNKKTG_cjs.logger.debug(
1696
+ chunkTWTG5ILJ_cjs.logger.debug(
1365
1697
  `actorFromRequest hook (server action) failed: ${describeError5(error)}`
1366
1698
  );
1367
1699
  }
@@ -1370,18 +1702,6 @@ async function maybeRunActorHookFromServerAction() {
1370
1702
  const userAgent = headers ? safeGetHeader(headers, "user-agent") : null;
1371
1703
  applyActorFromHookAndUa(hookResult, userAgent);
1372
1704
  }
1373
- async function maybeExtractSupabaseActor() {
1374
- const config = chunkWASXTDLW_cjs.configuration();
1375
- if (!config.actorFromSupabase) return;
1376
- if (chunkWASXTDLW_cjs.getCurrentActor()) return;
1377
- try {
1378
- const mod = await import('./db/supabase.cjs');
1379
- const actor = await mod.tryExtractSupabaseActor();
1380
- if (actor) chunkWASXTDLW_cjs.setActor(actor);
1381
- } catch (error) {
1382
- chunkV5YNKKTG_cjs.logger.debug(`actorFromSupabase failed: ${describeError5(error)}`);
1383
- }
1384
- }
1385
1705
  function snapshotPagesRequest(req) {
1386
1706
  let url;
1387
1707
  try {
@@ -1456,7 +1776,7 @@ async function loadNextHeaders() {
1456
1776
  try {
1457
1777
  return await Promise.resolve(mod.headers());
1458
1778
  } catch (error) {
1459
- chunkV5YNKKTG_cjs.logger.debug(`loadNextHeaders mod.headers() failed: ${describeError5(error)}`);
1779
+ chunkTWTG5ILJ_cjs.logger.debug(`loadNextHeaders mod.headers() failed: ${describeError5(error)}`);
1460
1780
  return null;
1461
1781
  }
1462
1782
  }
@@ -1467,13 +1787,25 @@ async function tryLoadNextHeadersModule() {
1467
1787
  try {
1468
1788
  return await import('next/headers.js');
1469
1789
  } catch (secondError) {
1470
- chunkV5YNKKTG_cjs.logger.debug(
1790
+ chunkTWTG5ILJ_cjs.logger.debug(
1471
1791
  `loadNextHeaders: neither "next/headers" nor "next/headers.js" resolved (${describeError5(firstError)}; ${describeError5(secondError)})`
1472
1792
  );
1473
1793
  return null;
1474
1794
  }
1475
1795
  }
1476
1796
  }
1797
+ function toWebHeaders(raw) {
1798
+ const headers = new Headers();
1799
+ for (const [name, value] of Object.entries(raw ?? {})) {
1800
+ for (const v of Array.isArray(value) ? value : value === void 0 ? [] : [value]) {
1801
+ try {
1802
+ headers.append(name, v);
1803
+ } catch {
1804
+ }
1805
+ }
1806
+ }
1807
+ return headers;
1808
+ }
1477
1809
  function readPagesHeader(req, name) {
1478
1810
  const raw = req.headers;
1479
1811
  if (raw instanceof Headers) return raw.get(name);
@@ -1486,7 +1818,7 @@ function readPagesHeader(req, name) {
1486
1818
  async function emitEvent(input) {
1487
1819
  try {
1488
1820
  await flushTriggerAuditLog();
1489
- const config = chunkWASXTDLW_cjs.configuration();
1821
+ const config = chunkMMLQXSSD_cjs.configuration();
1490
1822
  let graphql = null;
1491
1823
  if (input.snapshot.graphqlBody !== null) {
1492
1824
  const parsed = parseGraphqlBody(
@@ -1502,7 +1834,10 @@ async function emitEvent(input) {
1502
1834
  method: input.snapshot.method,
1503
1835
  url: input.snapshot.url,
1504
1836
  statusCode: input.statusCode,
1505
- rawParams: input.snapshot.rawParams,
1837
+ rawParams: chunkYXZZNZG6_cjs.maskAuthParams(
1838
+ unwrapTrpcParams(input.snapshot.rawParams, input.snapshot.url, input.context.routeModulePath ?? null),
1839
+ chunkYXZZNZG6_cjs.isAuthPath(input.snapshot.url.pathname)
1840
+ ),
1506
1841
  routeModulePath: input.context.routeModulePath ?? null,
1507
1842
  serverActionName,
1508
1843
  userAgent: input.snapshot.userAgent,
@@ -1519,42 +1854,110 @@ async function emitEvent(input) {
1519
1854
  input.responseErrorMessage ?? null
1520
1855
  );
1521
1856
  const contextValue = buildContext();
1522
- const event = chunkWASXTDLW_cjs.build({
1857
+ const event = chunkYXZZNZG6_cjs.build({
1523
1858
  source_type: "http_request",
1524
1859
  source_data: sourceData,
1525
1860
  outcome,
1526
- correlation_id: chunkWASXTDLW_cjs.current(),
1861
+ correlation_id: chunkMMLQXSSD_cjs.current(),
1527
1862
  resource_ids: [],
1528
1863
  context: contextValue,
1529
1864
  duration_ms: input.durationMs,
1530
1865
  error_message,
1531
1866
  timestamp: input.startedAt
1532
1867
  });
1533
- chunkWASXTDLW_cjs.pushEvent(event);
1868
+ chunkYXZZNZG6_cjs.pushEvent(event);
1534
1869
  } catch (error) {
1535
- const cid = chunkWASXTDLW_cjs.current();
1870
+ const cid = chunkMMLQXSSD_cjs.current();
1536
1871
  const cidLabel = cid ? ` (correlation_id=${cid})` : "";
1537
- chunkV5YNKKTG_cjs.logger.error(`http capture emit failed${cidLabel}: ${describeError5(error)}`);
1872
+ chunkTWTG5ILJ_cjs.logger.error(`http capture emit failed${cidLabel}: ${describeError5(error)}`);
1538
1873
  }
1539
1874
  }
1875
+ function followBody(response, method, onDone, onChunk) {
1876
+ try {
1877
+ if (!response.body || method === "HEAD" || response.bodyUsed) return null;
1878
+ const capture = chunkMMLQXSSD_cjs.makeAsyncContextCapture();
1879
+ if (!capture) return null;
1880
+ const keepAlive = isServerless() ? platformWaitUntil() : null;
1881
+ if (isServerless() && !keepAlive) return null;
1882
+ const run = capture();
1883
+ let settled;
1884
+ keepAlive?.(new Promise((resolve) => settled = resolve));
1885
+ const source = response.body;
1886
+ let reader = null;
1887
+ let finished = false;
1888
+ const finish = (error) => {
1889
+ if (finished) return;
1890
+ finished = true;
1891
+ run(() => onDone(error)).catch((e) => chunkTWTG5ILJ_cjs.logger.debug(`streamed response capture failed: ${describeError5(e)}`)).finally(() => settled?.());
1892
+ };
1893
+ const body = new ReadableStream(
1894
+ {
1895
+ async pull(controller) {
1896
+ try {
1897
+ const chunk = await run(() => (reader ??= source.getReader()).read());
1898
+ if (chunk.done) {
1899
+ controller.close();
1900
+ finish(null);
1901
+ } else {
1902
+ try {
1903
+ onChunk?.(chunk.value);
1904
+ } catch (e) {
1905
+ chunkTWTG5ILJ_cjs.logger.debug(`streamed chunk scan failed: ${describeError5(e)}`);
1906
+ }
1907
+ controller.enqueue(chunk.value);
1908
+ }
1909
+ } catch (e) {
1910
+ controller.error(e);
1911
+ finish(e instanceof Error ? e : new Error(String(e)));
1912
+ }
1913
+ },
1914
+ cancel(reason) {
1915
+ finish(null);
1916
+ return reader ? reader.cancel(reason) : source.cancel(reason);
1917
+ }
1918
+ },
1919
+ // Read the source only when the consumer asks: nothing is buffered.
1920
+ { highWaterMark: 0 }
1921
+ );
1922
+ return new Response(body, {
1923
+ status: response.status,
1924
+ statusText: response.statusText,
1925
+ headers: response.headers
1926
+ });
1927
+ } catch (e) {
1928
+ chunkTWTG5ILJ_cjs.logger.debug(`could not follow the response body: ${describeError5(e)}`);
1929
+ return null;
1930
+ }
1931
+ }
1932
+ function platformWaitUntil() {
1933
+ for (const key of ["@next/request-context", "@vercel/request-context"]) {
1934
+ try {
1935
+ const holder = globalThis[Symbol.for(key)];
1936
+ const ctx = holder?.get?.();
1937
+ if (typeof ctx?.waitUntil === "function") return ctx.waitUntil.bind(ctx);
1938
+ } catch {
1939
+ }
1940
+ }
1941
+ return null;
1942
+ }
1540
1943
  function buildContext() {
1541
- const currentActor = chunkWASXTDLW_cjs.getCurrentActor();
1944
+ const currentActor = chunkMMLQXSSD_cjs.getCurrentActor();
1542
1945
  if (!currentActor) return null;
1543
1946
  return { actor: currentActor };
1544
1947
  }
1545
1948
  async function flushTriggerAuditLog() {
1546
- const reader = chunkWASXTDLW_cjs.configuration().databaseReader;
1949
+ const reader = chunkMMLQXSSD_cjs.configuration().databaseReader;
1547
1950
  if (!reader) return;
1548
- await chunkYX2XPLOA_cjs.flushAuditLog(reader);
1951
+ await chunkGMHOUAKD_cjs.flushAuditLog(reader);
1549
1952
  }
1550
1953
  function runWithActorAndAuditScope(callback) {
1551
- if (chunkWASXTDLW_cjs.configuration().databaseReader == null) {
1552
- return chunkWASXTDLW_cjs.runWithActorScope(callback);
1954
+ if (chunkMMLQXSSD_cjs.configuration().databaseReader == null) {
1955
+ return chunkMMLQXSSD_cjs.runWithActorScope(callback);
1553
1956
  }
1554
- return chunkWASXTDLW_cjs.runWithActorScope(() => chunkYX2XPLOA_cjs.runWithEmittedAuditIdsScope(callback));
1957
+ return chunkMMLQXSSD_cjs.runWithActorScope(() => chunkGMHOUAKD_cjs.runWithEmittedAuditIdsScope(callback));
1555
1958
  }
1556
1959
  function isExcludedPath(path, method) {
1557
- const config = chunkWASXTDLW_cjs.configuration();
1960
+ const config = chunkMMLQXSSD_cjs.configuration();
1558
1961
  const normalizedMethod = (method ?? "").toUpperCase();
1559
1962
  for (const pattern of config.allExcludedPaths()) {
1560
1963
  if (typeof pattern === "string") {
@@ -1566,7 +1969,7 @@ function isExcludedPath(path, method) {
1566
1969
  return true;
1567
1970
  }
1568
1971
  }
1569
- if (hasExcludedExtension(path, chunkWASXTDLW_cjs.DEFAULT_EXCLUDED_EXTENSIONS)) return true;
1972
+ if (hasExcludedExtension(path, chunkMMLQXSSD_cjs.DEFAULT_EXCLUDED_EXTENSIONS)) return true;
1570
1973
  return false;
1571
1974
  }
1572
1975
  function extractRemoteIp(headers) {
@@ -1581,7 +1984,7 @@ function safeClone(request) {
1581
1984
  return null;
1582
1985
  }
1583
1986
  }
1584
- function safeJsonParse(text) {
1987
+ function safeJsonParse2(text) {
1585
1988
  try {
1586
1989
  return JSON.parse(text);
1587
1990
  } catch {
@@ -1604,20 +2007,26 @@ function mergeRouteParams(rawParams, routeParams) {
1604
2007
  return { ...routeParams, ...rawParams };
1605
2008
  }
1606
2009
  var MAX_ERROR_BODY_LENGTH = 16384;
1607
- async function readResponseErrorMessage(response) {
2010
+ async function readResponseErrorMessage(response, trpcRoute = false) {
1608
2011
  try {
1609
- if (response.status < 400) return null;
1610
- if (!(response.headers.get("content-type") ?? "").includes("json")) return null;
2012
+ if (response.status < 400 && response.status !== 207) return null;
2013
+ if (!trpcRoute && !(response.headers.get("content-type") ?? "").includes("json")) return null;
1611
2014
  if (Number(response.headers.get("content-length") ?? 0) > MAX_ERROR_BODY_LENGTH) return null;
1612
2015
  const text = await response.clone().text();
1613
2016
  if (!text || text.length > MAX_ERROR_BODY_LENGTH) return null;
1614
- const body = safeJsonParse(text);
2017
+ const parsed = safeJsonParse2(text);
2018
+ const trpc = trpcErrorMessage(parsed, chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys);
2019
+ if (trpc) return trpc;
2020
+ if (response.status === 207) return null;
2021
+ const body = parsed;
1615
2022
  if (!body || typeof body !== "object") return null;
1616
2023
  const nested = body.error;
1617
2024
  const raw = [body.error, body.message, nested?.message].find(
1618
2025
  (v) => typeof v === "string" && v.trim().length > 0
1619
2026
  );
1620
- return raw ? truncate(chunkWASXTDLW_cjs.scrubSecretsInText(raw.trim(), { emails: true })) : null;
2027
+ const specific = !raw || isGenericErrorText(raw) ? specificErrorMessage(body, chunkMMLQXSSD_cjs.configuration().excludedGraphqlVariableKeys) : null;
2028
+ if (specific) return capErrorText(specific);
2029
+ return raw ? truncate(chunkYXZZNZG6_cjs.scrubSecretsInText(raw.trim(), { emails: true })) : null;
1621
2030
  } catch {
1622
2031
  return null;
1623
2032
  }
@@ -1627,7 +2036,7 @@ async function readGraphqlErrors(response) {
1627
2036
  const cloned = response.clone();
1628
2037
  const text = await cloned.text();
1629
2038
  if (!text) return null;
1630
- const parsed = safeJsonParse(text);
2039
+ const parsed = safeJsonParse2(text);
1631
2040
  return extractGraphqlErrorsFromBody(parsed);
1632
2041
  } catch {
1633
2042
  return null;
@@ -1641,23 +2050,23 @@ function applyActorFromHookAndUa(hookResult, userAgent) {
1641
2050
  const uaMatch = classifyUserAgent(userAgent);
1642
2051
  if (hookResult != null && typeof hookResult === "object" && !Array.isArray(hookResult)) {
1643
2052
  if (uaMatch === null) {
1644
- chunkWASXTDLW_cjs.setActor(hookResult);
2053
+ chunkMMLQXSSD_cjs.setActor(hookResult);
1645
2054
  return;
1646
2055
  }
1647
2056
  const hookObj = hookResult;
1648
2057
  const existingKind = hookObj.kind;
1649
2058
  if (typeof existingKind === "string" && existingKind.length > 0) {
1650
- chunkWASXTDLW_cjs.setActor(hookObj);
2059
+ chunkMMLQXSSD_cjs.setActor(hookObj);
1651
2060
  return;
1652
2061
  }
1653
- chunkWASXTDLW_cjs.setActor({ ...hookObj, kind: uaMatch.kind });
2062
+ chunkMMLQXSSD_cjs.setActor({ ...hookObj, kind: uaMatch.kind });
1654
2063
  return;
1655
2064
  }
1656
2065
  if (uaMatch !== null) {
1657
- chunkWASXTDLW_cjs.setActor(synthesizeAgentActor(uaMatch));
2066
+ chunkMMLQXSSD_cjs.setActor(synthesizeAgentActor(uaMatch));
1658
2067
  return;
1659
2068
  }
1660
- chunkWASXTDLW_cjs.setActor(null);
2069
+ chunkMMLQXSSD_cjs.setActor(null);
1661
2070
  }
1662
2071
  function synthesizeAgentActor(detection) {
1663
2072
  return {
@@ -1683,12 +2092,33 @@ function isBeforeExitInstalled() {
1683
2092
  function markBeforeExitInstalled() {
1684
2093
  globalThis[BEFORE_EXIT_INSTALLED_KEY] = true;
1685
2094
  }
2095
+ var STARTUP_ANNOUNCED_KEY = /* @__PURE__ */ Symbol.for("ezlogs-nextjs:startupAnnounced");
2096
+ function announceStartup(serverUrl, projectToken) {
2097
+ const g = globalThis;
2098
+ if (g[STARTUP_ANNOUNCED_KEY]) return;
2099
+ g[STARTUP_ANNOUNCED_KEY] = true;
2100
+ if (!serverUrl || !projectToken) {
2101
+ chunkTWTG5ILJ_cjs.logger.warn("not capturing: projectToken missing in ezlogs.init() (check EZLOGS_PROJECT_TOKEN)");
2102
+ return;
2103
+ }
2104
+ let host = serverUrl;
2105
+ try {
2106
+ host = new URL(serverUrl).host;
2107
+ } catch {
2108
+ }
2109
+ const project = projectToken.startsWith("ezl_") && projectToken.length >= 24 ? ` (key ${projectToken.slice(0, 12)}\u2026)` : "";
2110
+ chunkTWTG5ILJ_cjs.logger.notice(`capturing \u2192 ${host}${project}`);
2111
+ }
2112
+ function _resetStartupAnnouncementForTests() {
2113
+ delete globalThis[STARTUP_ANNOUNCED_KEY];
2114
+ }
1686
2115
  var ezlogs = {
1687
2116
  init(options) {
1688
- const config = chunkWASXTDLW_cjs.configuration();
2117
+ const config = chunkMMLQXSSD_cjs.configuration();
1689
2118
  config.apply(options);
1690
- if (options.logLevel) chunkV5YNKKTG_cjs.setLogLevel(options.logLevel);
2119
+ if (options.logLevel) chunkTWTG5ILJ_cjs.setLogLevel(options.logLevel);
1691
2120
  warnIfInsecureServerUrl(config.serverUrl, config.allowInsecureTransport);
2121
+ announceStartup(config.serverUrl, config.projectToken);
1692
2122
  flushScheduler.start();
1693
2123
  if (config.patchGlobalFetch) patchGlobalFetch();
1694
2124
  const resolvedDbUrl = options.databaseUrl ?? detectDatabaseUrlFromEnv();
@@ -1703,7 +2133,7 @@ var ezlogs = {
1703
2133
  }
1704
2134
  });
1705
2135
  } else if (options.patchDatabaseClient) {
1706
- chunkY5NSHKWQ_cjs.patchPgClient(
2136
+ chunkNX4EL7BY_cjs.patchPgClient(
1707
2137
  options.patchDatabaseClient
1708
2138
  );
1709
2139
  }
@@ -1750,7 +2180,7 @@ function detectDatabaseUrlFromEnv() {
1750
2180
  return null;
1751
2181
  }
1752
2182
  async function autoWireTriggerPathFromDatabaseUrl(options) {
1753
- const config = chunkWASXTDLW_cjs.configuration();
2183
+ const config = chunkMMLQXSSD_cjs.configuration();
1754
2184
  let pg;
1755
2185
  try {
1756
2186
  const dynImport = new Function(
@@ -1759,7 +2189,7 @@ async function autoWireTriggerPathFromDatabaseUrl(options) {
1759
2189
  );
1760
2190
  pg = await dynImport("pg");
1761
2191
  } catch {
1762
- chunkV5YNKKTG_cjs.logger.warn(
2192
+ chunkTWTG5ILJ_cjs.logger.warn(
1763
2193
  "a Postgres URL is configured but the `pg` package is not installed, so trigger-based DB capture is off. Run `npm i pg` and `npx ezlogs-nextjs install-triggers`, or use a per-ORM adapter (docs/database.md)."
1764
2194
  );
1765
2195
  return;
@@ -1769,7 +2199,7 @@ async function autoWireTriggerPathFromDatabaseUrl(options) {
1769
2199
  max: 4
1770
2200
  });
1771
2201
  const reader = (sql, params) => pool.query(sql, params);
1772
- if (await chunkYX2XPLOA_cjs.auditLogInstalled(reader) === false) {
2202
+ if (await chunkGMHOUAKD_cjs.auditLogInstalled(reader) === false) {
1773
2203
  warnAuditLogMissing();
1774
2204
  void pool.end?.().catch(() => {
1775
2205
  });
@@ -1778,44 +2208,44 @@ async function autoWireTriggerPathFromDatabaseUrl(options) {
1778
2208
  if (config.databaseReader === null) {
1779
2209
  config.databaseReader = reader;
1780
2210
  }
1781
- chunkY5NSHKWQ_cjs.patchPgClient(pg);
1782
- void chunkYX2XPLOA_cjs.checkAuditLogAccess(reader);
2211
+ chunkNX4EL7BY_cjs.patchPgClient(pg);
2212
+ void chunkGMHOUAKD_cjs.checkAuditLogAccess(reader);
1783
2213
  runTriggerTrackedTablesDetection();
1784
2214
  }
1785
2215
  function applyDatabaseReaderDefaults() {
1786
- const config = chunkWASXTDLW_cjs.configuration();
2216
+ const config = chunkMMLQXSSD_cjs.configuration();
1787
2217
  const reader = config.databaseReader;
1788
2218
  if (!reader) return;
1789
- chunkYX2XPLOA_cjs.auditLogInstalled(reader).then((installed) => {
2219
+ chunkGMHOUAKD_cjs.auditLogInstalled(reader).then((installed) => {
1790
2220
  if (installed === false && config.databaseReader === reader) {
1791
2221
  config.databaseReader = null;
1792
2222
  warnAuditLogMissing();
1793
2223
  return;
1794
2224
  }
1795
- if (installed === true) void chunkYX2XPLOA_cjs.checkAuditLogAccess(reader);
2225
+ if (installed === true) void chunkGMHOUAKD_cjs.checkAuditLogAccess(reader);
1796
2226
  runTriggerTrackedTablesDetection();
1797
2227
  }).catch(() => {
1798
2228
  });
1799
2229
  }
1800
2230
  function warnAuditLogMissing() {
1801
- chunkV5YNKKTG_cjs.logger.warn(
2231
+ chunkTWTG5ILJ_cjs.logger.warn(
1802
2232
  "table `ezlogs_audit_log` was not found, so trigger-based DB capture is off. Run `npx ezlogs-nextjs install-triggers` against this database and restart."
1803
2233
  );
1804
2234
  }
1805
2235
  function runTriggerTrackedTablesDetection() {
1806
- const config = chunkWASXTDLW_cjs.configuration();
2236
+ const config = chunkMMLQXSSD_cjs.configuration();
1807
2237
  if (!config.databaseReader) return;
1808
2238
  if (config.triggerTrackedTables !== null) return;
1809
- chunkYX2XPLOA_cjs.detectTriggerTrackedTables(config.databaseReader).then((tables) => {
2239
+ chunkGMHOUAKD_cjs.detectTriggerTrackedTables(config.databaseReader).then((tables) => {
1810
2240
  if (tables === null) {
1811
- chunkV5YNKKTG_cjs.logger.debug(
1812
- "[ezlogs] trigger-tracked-table detection failed; falling back to suppress-all on `databaseReader` paths. Untracked tables will not appear in the dashboard until detection succeeds or the table is added with `SELECT ezlogs_track('table_name')`."
2241
+ chunkTWTG5ILJ_cjs.logger.debug(
2242
+ "trigger-tracked-table detection failed; falling back to suppress-all on `databaseReader` paths. Untracked tables will not appear in the dashboard until detection succeeds or the table is added with `SELECT ezlogs_track('table_name')`."
1813
2243
  );
1814
2244
  return;
1815
2245
  }
1816
2246
  config.triggerTrackedTables = tables;
1817
- chunkV5YNKKTG_cjs.logger.debug(
1818
- `[ezlogs] trigger-tracked tables: ${tables.size === 0 ? "(none)" : Array.from(tables).sort().join(", ")}`
2247
+ chunkTWTG5ILJ_cjs.logger.debug(
2248
+ `trigger-tracked tables: ${tables.size === 0 ? "(none)" : Array.from(tables).sort().join(", ")}`
1819
2249
  );
1820
2250
  }).catch(() => {
1821
2251
  });
@@ -1846,20 +2276,21 @@ function warnIfInsecureServerUrl(serverUrl, allowInsecure) {
1846
2276
  );
1847
2277
  }
1848
2278
  function _internalsForTests() {
1849
- return { buffer: chunkWASXTDLW_cjs.buffer_exports, flushScheduler };
2279
+ return { buffer: chunkYXZZNZG6_cjs.buffer_exports, flushScheduler };
1850
2280
  }
1851
2281
 
1852
2282
  Object.defineProperty(exports, "ArgError", {
1853
2283
  enumerable: true,
1854
- get: function () { return chunkWASXTDLW_cjs.ArgError; }
2284
+ get: function () { return chunkYXZZNZG6_cjs.ArgError; }
1855
2285
  });
1856
2286
  Object.defineProperty(exports, "buildEvent", {
1857
2287
  enumerable: true,
1858
- get: function () { return chunkWASXTDLW_cjs.build; }
2288
+ get: function () { return chunkYXZZNZG6_cjs.build; }
1859
2289
  });
1860
2290
  exports.__ezlogs_run_inline_server_action = __ezlogs_run_inline_server_action;
1861
2291
  exports._detectDatabaseUrlFromEnvForTests = _detectDatabaseUrlFromEnvForTests;
1862
2292
  exports._internalsForTests = _internalsForTests;
2293
+ exports._resetStartupAnnouncementForTests = _resetStartupAnnouncementForTests;
1863
2294
  exports.captureHttpEvent = captureHttpEvent;
1864
2295
  exports.capturePagesApi = capturePagesApi;
1865
2296
  exports.captureRoute = captureRoute;