bugstack-sdk 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -433,8 +433,451 @@ var RetryQueue = class {
433
433
  }
434
434
  };
435
435
 
436
+ // src/core/utils/stack-parser.ts
437
+ var V8_STACK_FRAME_REGEX = /^\s*at\s+(?:async\s+)?(?:(.+?)\s+\()?(?:(.+?):(\d+):(\d+))\)?$/;
438
+ function isNodeModule(filePath) {
439
+ return filePath.includes("node_modules");
440
+ }
441
+ function isInternalCode(filePath) {
442
+ return filePath.startsWith("node:") || filePath.startsWith("internal/") || // A bare name ("native", "<anonymous>") has no directory. A Windows
443
+ // path has backslashes and is app code.
444
+ !filePath.includes("/") && !filePath.includes("\\");
445
+ }
446
+ function cleanFunctionName(name) {
447
+ if (!name) return void 0;
448
+ return name.replace(/^Object\./, "").replace(/^Module\./, "").replace(/^__webpack_require__\./, "").replace(/^webpack_require\./, "").trim();
449
+ }
450
+ function parseStackTrace(stack) {
451
+ if (!stack) return [];
452
+ const lines = stack.split("\n");
453
+ const frames = [];
454
+ for (const line of lines) {
455
+ const match = V8_STACK_FRAME_REGEX.exec(line);
456
+ if (match) {
457
+ const [, functionName, file, lineStr, columnStr] = match;
458
+ const frame = {
459
+ function: cleanFunctionName(functionName),
460
+ file: file ?? void 0,
461
+ line: lineStr ? parseInt(lineStr, 10) : void 0,
462
+ column: columnStr ? parseInt(columnStr, 10) : void 0
463
+ };
464
+ if (frame.file) {
465
+ frame.isNodeModule = isNodeModule(frame.file);
466
+ frame.isInternal = isInternalCode(frame.file);
467
+ }
468
+ frames.push(frame);
469
+ }
470
+ }
471
+ return frames;
472
+ }
473
+ function getFirstAppFrame(frames) {
474
+ return frames.find((frame) => !frame.isNodeModule && !frame.isInternal);
475
+ }
476
+ function getAppFrames(frames) {
477
+ return frames.filter((frame) => !frame.isNodeModule && !frame.isInternal);
478
+ }
479
+ function formatStackFrames(frames) {
480
+ return frames.map((frame) => {
481
+ const location = [frame.file, frame.line, frame.column].filter(Boolean).join(":");
482
+ if (frame.function) {
483
+ return ` at ${frame.function} (${location})`;
484
+ }
485
+ return ` at ${location}`;
486
+ }).join("\n");
487
+ }
488
+
436
489
  // src/core/sdk-version.ts
437
- var SDK_VERSION = "2.2.2" ;
490
+ var SDK_VERSION = "2.3.0" ;
491
+
492
+ // src/core/logged-errors.ts
493
+ var DEFAULT_MAX_PER_MINUTE = 20;
494
+ var DEFAULT_REPEAT_WINDOW_MS = 5 * 6e4;
495
+ var MAX_REMEMBERED = 500;
496
+ var MESSAGE_MAX = 300;
497
+ var ANCHORED_MESSAGE_MAX = 500;
498
+ var CAUSE_STACK_MAX = 2e3;
499
+ function resolveLoggedErrorOptions(value) {
500
+ const opts = typeof value === "object" && value !== null ? value : {};
501
+ return {
502
+ console: value !== false,
503
+ messages: opts.messages ?? false,
504
+ maxPerMinute: opts.maxPerMinute ?? DEFAULT_MAX_PER_MINUTE,
505
+ repeatWindowMs: opts.repeatWindowMs ?? DEFAULT_REPEAT_WINDOW_MS,
506
+ ignore: opts.ignore ?? []
507
+ };
508
+ }
509
+ var SHARED_KEY = /* @__PURE__ */ Symbol.for("bugstack-sdk.logged-errors");
510
+ function emptyStats() {
511
+ return {
512
+ forwarded: 0,
513
+ messageOnly: 0,
514
+ dropped: {
515
+ no_error_argument: 0,
516
+ sdk_line: 0,
517
+ node_warning: 0,
518
+ ignored: 0,
519
+ already_reported: 0,
520
+ repeat: 0,
521
+ rate_limited: 0,
522
+ no_client: 0
523
+ }
524
+ };
525
+ }
526
+ function shared() {
527
+ const g = globalThis;
528
+ let s = g[SHARED_KEY];
529
+ if (!s) {
530
+ s = {
531
+ reported: /* @__PURE__ */ new WeakSet(),
532
+ sink: null,
533
+ consoleOriginal: null,
534
+ consoleWrapper: null,
535
+ busy: false,
536
+ windowStart: 0,
537
+ inWindow: 0,
538
+ lastSent: /* @__PURE__ */ new Map(),
539
+ stats: emptyStats(),
540
+ now: Date.now
541
+ };
542
+ g[SHARED_KEY] = s;
543
+ }
544
+ return s;
545
+ }
546
+ var defer = typeof setImmediate === "function" ? (fn) => void setImmediate(fn) : (fn) => void setTimeout(fn, 0);
547
+ function markErrorReported(error) {
548
+ try {
549
+ if (error !== null && typeof error === "object") shared().reported.add(error);
550
+ } catch {
551
+ }
552
+ }
553
+ function loggedErrorStats() {
554
+ const s = shared();
555
+ return {
556
+ consoleInstalled: s.consoleWrapper !== null && s.sink !== null && s.sink.options.console,
557
+ forwarded: s.stats.forwarded,
558
+ messageOnly: s.stats.messageOnly,
559
+ dropped: { ...s.stats.dropped }
560
+ };
561
+ }
562
+ function isError(value) {
563
+ if (value instanceof Error) return true;
564
+ if (value === null || typeof value !== "object") return false;
565
+ try {
566
+ const v = value;
567
+ return typeof v.message === "string" && typeof v.stack === "string";
568
+ } catch {
569
+ return false;
570
+ }
571
+ }
572
+ function findError(args) {
573
+ for (const a of args) if (isError(a)) return a;
574
+ for (const a of args) {
575
+ if (a === null || typeof a !== "object" || Array.isArray(a)) continue;
576
+ try {
577
+ const o = a;
578
+ for (const k of ["err", "error", "cause"]) if (isError(o[k])) return o[k];
579
+ } catch {
580
+ }
581
+ }
582
+ return void 0;
583
+ }
584
+ var STACK_TEXT = /(^|\n)\s*([A-Za-z_$][\w$.]*(?:Error|Exception)\b[^\n]*)\n\s+at \S/;
585
+ function findStackText(args) {
586
+ for (const a of args) {
587
+ if (typeof a !== "string") continue;
588
+ const m = STACK_TEXT.exec(a);
589
+ if (!m) continue;
590
+ const header = m[2].trim();
591
+ const colon = header.indexOf(":");
592
+ const err = new Error(colon > 0 ? header.slice(colon + 1).trim() : header);
593
+ err.name = colon > 0 ? header.slice(0, colon).trim() : "Error";
594
+ err.stack = a.slice(m.index + m[1].length).trim();
595
+ return err;
596
+ }
597
+ return void 0;
598
+ }
599
+ function messageOfArgs(args) {
600
+ const parts = [];
601
+ for (const a of args) {
602
+ if (typeof a === "string") parts.push(a);
603
+ else if (typeof a === "number" || typeof a === "boolean") parts.push(String(a));
604
+ else if (a !== null && typeof a === "object" && !Array.isArray(a) && !isError(a)) {
605
+ try {
606
+ const o = a;
607
+ for (const k of ["error", "message", "reason", "err", "msg"]) {
608
+ if (typeof o[k] === "string" && o[k].length > 0) {
609
+ parts.push(o[k]);
610
+ break;
611
+ }
612
+ }
613
+ } catch {
614
+ }
615
+ }
616
+ }
617
+ return parts.join(" ").replace(/\s+/g, " ").trim().slice(0, MESSAGE_MAX);
618
+ }
619
+ function logRoute(label) {
620
+ const tag = label?.match(/^\s*\[([A-Za-z0-9_.:/-]{1,60})\]/)?.[1];
621
+ return tag ? `log:${tag}` : "log";
622
+ }
623
+ var SDK_LINE = /^\s*\[bugstack[^\]]*\]/i;
624
+ var NODE_WARNING_LINE = /^\s*\(node:\d+\)\s+(?:\[[A-Z0-9_]+\]\s+)?\w*Warning:/;
625
+ function escapeRegExp(s) {
626
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
627
+ }
628
+ function redactText(text, redactFields) {
629
+ let out = text.replace(/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]{8,}/gi, "$1 [REDACTED]");
630
+ if (redactFields.length > 0) {
631
+ const names = redactFields.filter((f) => f.length > 0).map(escapeRegExp).join("|");
632
+ if (names) {
633
+ const re = new RegExp(
634
+ `(["']?\\b\\w*(?:${names})\\w*["']?\\s*[=:]\\s*)("[^"]*"|'[^']*'|[^\\s,;&)}\\]]+)`,
635
+ "gi"
636
+ );
637
+ out = out.replace(re, "$1[REDACTED]");
638
+ }
639
+ }
640
+ return out;
641
+ }
642
+ function firstFrame(stack) {
643
+ return (stack ?? "").split("\n").find((l) => /^\s+at /.test(l))?.trim() ?? "";
644
+ }
645
+ function trimLibraryFrames(stack) {
646
+ const lines = stack.split("\n");
647
+ const header = [];
648
+ let i = 0;
649
+ while (i < lines.length && !/^\s+at /.test(lines[i])) header.push(lines[i++]);
650
+ let j = i;
651
+ while (j < lines.length && /node_modules|[/\\]bugstack-sdk[/\\]|\(node:internal|^\s+at node:internal/.test(lines[j])) j++;
652
+ if (j >= lines.length) return stack;
653
+ return [...header, ...lines.slice(j)].join("\n");
654
+ }
655
+ function siteOf(label, cause) {
656
+ if (label === void 0) return "";
657
+ const first = label.split("\n")[0].trim();
658
+ if (!first || first === cause.message || first === `${cause.name}: ${cause.message}`) return "";
659
+ return first.slice(0, 200);
660
+ }
661
+ function matchesIgnore(text, ignore) {
662
+ for (const p of ignore) {
663
+ try {
664
+ if (typeof p === "string" ? text.includes(p) : p.test(text)) return true;
665
+ } catch {
666
+ }
667
+ }
668
+ return false;
669
+ }
670
+ function captureLoggedCall(args, source, boundary) {
671
+ const s = shared();
672
+ if (s.busy) return;
673
+ try {
674
+ const sink = s.sink;
675
+ if (!sink) {
676
+ s.stats.dropped.no_client += 1;
677
+ return;
678
+ }
679
+ const label = args.find((a) => typeof a === "string");
680
+ if (label !== void 0 && SDK_LINE.test(label)) {
681
+ s.stats.dropped.sdk_line += 1;
682
+ return;
683
+ }
684
+ if (label !== void 0 && NODE_WARNING_LINE.test(label)) {
685
+ s.stats.dropped.node_warning += 1;
686
+ return;
687
+ }
688
+ const cause = findError(args) ?? findStackText(args) ?? null;
689
+ if (sink.options.ignore.length > 0 && matchesIgnore(`${messageOfArgs(args)} ${cause ? `${cause.name}: ${cause.message}` : ""}`, sink.options.ignore)) {
690
+ s.stats.dropped.ignored += 1;
691
+ return;
692
+ }
693
+ let message;
694
+ if (cause) {
695
+ message = `${siteOf(label, cause) || source}: ${cause.message}`;
696
+ } else {
697
+ message = sink.options.messages ? messageOfArgs(args) : "";
698
+ if (!message) {
699
+ s.stats.dropped.no_error_argument += 1;
700
+ return;
701
+ }
702
+ }
703
+ const anchored = new Error(redactText(message, sink.redactFields).slice(0, ANCHORED_MESSAGE_MAX));
704
+ anchored.name = "LoggedError";
705
+ const capture = Error.captureStackTrace;
706
+ if (capture) capture(anchored, boundary);
707
+ if (anchored.stack) anchored.stack = trimLibraryFrames(anchored.stack);
708
+ if (cause) anchored.cause = cause;
709
+ const pending = { anchored, cause, label, source, messageOnly: !cause };
710
+ defer(() => forward(pending));
711
+ } catch {
712
+ }
713
+ }
714
+ function forward(p) {
715
+ const s = shared();
716
+ const sink = s.sink;
717
+ if (!sink) {
718
+ s.stats.dropped.no_client += 1;
719
+ return;
720
+ }
721
+ try {
722
+ if (p.cause && s.reported.has(p.cause)) {
723
+ s.stats.dropped.already_reported += 1;
724
+ return;
725
+ }
726
+ const now = s.now();
727
+ const key = p.messageOnly ? `${firstFrame(p.anchored.stack)}|message-only` : `${firstFrame(p.anchored.stack)}|${p.anchored.message}`;
728
+ const last = s.lastSent.get(key);
729
+ if (last !== void 0 && now - last < sink.options.repeatWindowMs) {
730
+ s.stats.dropped.repeat += 1;
731
+ return;
732
+ }
733
+ if (now - s.windowStart >= 6e4) {
734
+ s.windowStart = now;
735
+ s.inWindow = 0;
736
+ }
737
+ if (s.inWindow >= sink.options.maxPerMinute) {
738
+ s.stats.dropped.rate_limited += 1;
739
+ return;
740
+ }
741
+ s.inWindow += 1;
742
+ s.lastSent.set(key, now);
743
+ if (s.lastSent.size > MAX_REMEMBERED) {
744
+ const oldest = s.lastSent.keys().next().value;
745
+ if (oldest !== void 0) s.lastSent.delete(oldest);
746
+ }
747
+ if (p.cause) s.reported.add(p.cause);
748
+ const captured = buildLoggedCapturedError(p, sink);
749
+ s.busy = true;
750
+ try {
751
+ const result = sink.report(captured);
752
+ if (result && typeof result.catch === "function") {
753
+ result.catch(() => {
754
+ });
755
+ }
756
+ s.stats.forwarded += 1;
757
+ if (p.messageOnly) s.stats.messageOnly += 1;
758
+ } finally {
759
+ s.busy = false;
760
+ }
761
+ } catch {
762
+ }
763
+ }
764
+ function nodeVersion() {
765
+ try {
766
+ return typeof process !== "undefined" && process.version ? process.version : "unknown";
767
+ } catch {
768
+ return "unknown";
769
+ }
770
+ }
771
+ function buildLoggedCapturedError(p, sink) {
772
+ const stackFrames = parseStackTrace(p.anchored.stack);
773
+ const firstAppFrame = getFirstAppFrame(stackFrames);
774
+ const route = logRoute(p.label);
775
+ const metadata = {
776
+ source: p.source,
777
+ handled: true,
778
+ ...firstAppFrame && {
779
+ sourceLocation: {
780
+ file: firstAppFrame.file,
781
+ line: firstAppFrame.line,
782
+ column: firstAppFrame.column,
783
+ function: firstAppFrame.function
784
+ }
785
+ }
786
+ };
787
+ if (p.cause) {
788
+ metadata.causeName = p.cause.name;
789
+ if (p.cause.stack) metadata.causeStack = redactText(p.cause.stack, sink.redactFields).slice(0, CAUSE_STACK_MAX);
790
+ } else {
791
+ metadata.messageOnly = true;
792
+ }
793
+ return {
794
+ id: `err_${Date.now().toString(36)}_${Math.random().toString(36).substring(2, 9)}`,
795
+ name: p.anchored.name,
796
+ message: p.anchored.message,
797
+ stack: p.anchored.stack,
798
+ stackFrames,
799
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
800
+ route,
801
+ method: "LOG",
802
+ statusCode: 500,
803
+ url: route,
804
+ environment: sink.environment,
805
+ projectId: sink.projectId,
806
+ sdkVersion: SDK_VERSION,
807
+ nodeVersion: nodeVersion(),
808
+ metadata
809
+ };
810
+ }
811
+ function attachLoggedErrorSink(sink) {
812
+ try {
813
+ const s = shared();
814
+ s.sink = sink;
815
+ if (sink.options.console) installConsoleWrapper(s);
816
+ } catch {
817
+ }
818
+ }
819
+ function detachLoggedErrorSink(sink) {
820
+ try {
821
+ const s = shared();
822
+ if (s.sink !== sink) return;
823
+ s.sink = null;
824
+ if (s.consoleWrapper && typeof console !== "undefined" && console.error === s.consoleWrapper && s.consoleOriginal) {
825
+ console.error = s.consoleOriginal;
826
+ s.consoleWrapper = null;
827
+ s.consoleOriginal = null;
828
+ }
829
+ } catch {
830
+ }
831
+ }
832
+ function installConsoleWrapper(s) {
833
+ if (typeof console === "undefined" || typeof console.error !== "function") return;
834
+ if (s.consoleWrapper && console.error === s.consoleWrapper) return;
835
+ const original = console.error;
836
+ const wrapper = function consoleErrorCapturedByBugstack(...args) {
837
+ original.apply(this === void 0 ? console : this, args);
838
+ const st = shared();
839
+ if (!st.sink || !st.sink.options.console) return;
840
+ captureLoggedCall(args, "console-error", wrapper);
841
+ };
842
+ s.consoleOriginal = original;
843
+ s.consoleWrapper = wrapper;
844
+ console.error = wrapper;
845
+ }
846
+ function bugstackPinoHooks() {
847
+ const logMethod = function bugstackPinoLogMethod(inputArgs, method, level) {
848
+ if (typeof level === "number" && level >= 50) {
849
+ captureLoggedCall(inputArgs, "pino", logMethod);
850
+ }
851
+ return method.apply(this, inputArgs);
852
+ };
853
+ return { logMethod };
854
+ }
855
+ var WINSTON_LEVEL = /* @__PURE__ */ Symbol.for("level");
856
+ var WINSTON_SPLAT = /* @__PURE__ */ Symbol.for("splat");
857
+ var WINSTON_ERROR_LEVELS = /* @__PURE__ */ new Set(["error", "crit", "alert", "emerg", "fatal"]);
858
+ function bugstackWinstonFormat() {
859
+ const transform = function bugstackWinstonTransform(info) {
860
+ try {
861
+ const level = info[WINSTON_LEVEL] ?? info.level;
862
+ if (typeof level === "string" && WINSTON_ERROR_LEVELS.has(level)) {
863
+ const splat = Array.isArray(info[WINSTON_SPLAT]) ? info[WINSTON_SPLAT] : [];
864
+ const args = [];
865
+ if (typeof info.message === "string") args.push(info.message);
866
+ if (typeof info.stack === "string" && typeof info.message === "string") {
867
+ const e = new Error(info.message);
868
+ e.name = typeof info.name === "string" ? info.name : "Error";
869
+ e.stack = info.stack;
870
+ args.push(e);
871
+ }
872
+ args.push(...splat, info);
873
+ captureLoggedCall(args, "winston", transform);
874
+ }
875
+ } catch {
876
+ }
877
+ return info;
878
+ };
879
+ return { transform };
880
+ }
438
881
 
439
882
  // src/core/client.ts
440
883
  var DEFAULT_ENDPOINT = "https://dashboard.bugstack.ai/api/ingest/sdk";
@@ -464,6 +907,7 @@ var ErrorCaptureClient = class _ErrorCaptureClient {
464
907
  static instance = null;
465
908
  deduplicator;
466
909
  retryQueue;
910
+ loggedErrorSink = null;
467
911
  constructor(config) {
468
912
  const isProduction = process.env.NODE_ENV === "production";
469
913
  this.config = {
@@ -490,7 +934,8 @@ var ErrorCaptureClient = class _ErrorCaptureClient {
490
934
  dropChunkErrors: config.dropChunkErrors ?? false,
491
935
  chunkErrorsEndpoint: config.chunkErrorsEndpoint ?? deriveChunkErrorsEndpoint(
492
936
  config.endpoint ?? process.env.BUGSTACK_ENDPOINT ?? DEFAULT_ENDPOINT
493
- )
937
+ ),
938
+ captureConsoleErrors: resolveLoggedErrorOptions(config.captureConsoleErrors)
494
939
  };
495
940
  this.deduplicator = new ErrorDeduplicator(this.config.deduplicationWindow);
496
941
  this.retryQueue = new RetryQueue(
@@ -502,12 +947,23 @@ var ErrorCaptureClient = class _ErrorCaptureClient {
502
947
  debug: this.config.debug
503
948
  }
504
949
  );
950
+ if (this.config.enabled) {
951
+ this.loggedErrorSink = {
952
+ options: this.config.captureConsoleErrors,
953
+ environment: this.config.environment,
954
+ projectId: this.config.projectId,
955
+ redactFields: this.config.redactFields,
956
+ report: (error) => this.reportError(error)
957
+ };
958
+ attachLoggedErrorSink(this.loggedErrorSink);
959
+ }
505
960
  this.log("BugStack client initialized", {
506
961
  endpoint: this.config.endpoint,
507
962
  projectId: this.config.projectId,
508
963
  environment: this.config.environment,
509
964
  autoFix: this.config.autoFix,
510
- deduplicationWindow: this.config.deduplicationWindow
965
+ deduplicationWindow: this.config.deduplicationWindow,
966
+ captureConsoleErrors: this.config.captureConsoleErrors.console
511
967
  });
512
968
  }
513
969
  /**
@@ -706,6 +1162,10 @@ var ErrorCaptureClient = class _ErrorCaptureClient {
706
1162
  * Should be called when shutting down to prevent memory leaks
707
1163
  */
708
1164
  destroy() {
1165
+ if (this.loggedErrorSink) {
1166
+ detachLoggedErrorSink(this.loggedErrorSink);
1167
+ this.loggedErrorSink = null;
1168
+ }
709
1169
  this.deduplicator.destroy();
710
1170
  this.retryQueue.destroy();
711
1171
  }
@@ -900,57 +1360,6 @@ async function safeParseBody(request, maxSize, client) {
900
1360
  }
901
1361
  }
902
1362
 
903
- // src/core/utils/stack-parser.ts
904
- var V8_STACK_FRAME_REGEX = /^\s*at\s+(?:async\s+)?(?:(.+?)\s+\()?(?:(.+?):(\d+):(\d+))\)?$/;
905
- function isNodeModule(filePath) {
906
- return filePath.includes("node_modules");
907
- }
908
- function isInternalCode(filePath) {
909
- return filePath.startsWith("node:") || filePath.startsWith("internal/") || !filePath.includes("/");
910
- }
911
- function cleanFunctionName(name) {
912
- if (!name) return void 0;
913
- return name.replace(/^Object\./, "").replace(/^Module\./, "").replace(/^__webpack_require__\./, "").replace(/^webpack_require\./, "").trim();
914
- }
915
- function parseStackTrace(stack) {
916
- if (!stack) return [];
917
- const lines = stack.split("\n");
918
- const frames = [];
919
- for (const line of lines) {
920
- const match = V8_STACK_FRAME_REGEX.exec(line);
921
- if (match) {
922
- const [, functionName, file, lineStr, columnStr] = match;
923
- const frame = {
924
- function: cleanFunctionName(functionName),
925
- file: file ?? void 0,
926
- line: lineStr ? parseInt(lineStr, 10) : void 0,
927
- column: columnStr ? parseInt(columnStr, 10) : void 0
928
- };
929
- if (frame.file) {
930
- frame.isNodeModule = isNodeModule(frame.file);
931
- frame.isInternal = isInternalCode(frame.file);
932
- }
933
- frames.push(frame);
934
- }
935
- }
936
- return frames;
937
- }
938
- function getFirstAppFrame(frames) {
939
- return frames.find((frame) => !frame.isNodeModule && !frame.isInternal);
940
- }
941
- function getAppFrames(frames) {
942
- return frames.filter((frame) => !frame.isNodeModule && !frame.isInternal);
943
- }
944
- function formatStackFrames(frames) {
945
- return frames.map((frame) => {
946
- const location = [frame.file, frame.line, frame.column].filter(Boolean).join(":");
947
- if (frame.function) {
948
- return ` at ${frame.function} (${location})`;
949
- }
950
- return ` at ${location}`;
951
- }).join("\n");
952
- }
953
-
954
1363
  // src/adapters/nextjs/index.ts
955
1364
  function generateErrorId() {
956
1365
  const timestamp = Date.now().toString(36);
@@ -1055,6 +1464,7 @@ function withErrorCapture(handler, config, routeOptions) {
1055
1464
  const response = await handler(request, context);
1056
1465
  return response;
1057
1466
  } catch (error) {
1467
+ markErrorReported(error);
1058
1468
  const err = error instanceof Error ? error : new Error(String(error));
1059
1469
  if (client) {
1060
1470
  const clientConfig = client.getConfig();
@@ -1075,6 +1485,6 @@ function withErrorCapture(handler, config, routeOptions) {
1075
1485
  }
1076
1486
  var withBugStack = withErrorCapture;
1077
1487
 
1078
- export { BugStackClient, ErrorCaptureClient, ErrorDeduplicator, RetryQueue, formatStackFrames, generateErrorFingerprint, generateFingerprintFromParts, getAppFrames, getFirstAppFrame, isChunkLoadError, parseStackTrace, safeParseBody, sanitizeHeaders, sanitizeObject, sanitizeQueryParams, truncateBody, withBugStack, withErrorCapture };
1488
+ export { BugStackClient, ErrorCaptureClient, ErrorDeduplicator, RetryQueue, bugstackPinoHooks, bugstackWinstonFormat, formatStackFrames, generateErrorFingerprint, generateFingerprintFromParts, getAppFrames, getFirstAppFrame, isChunkLoadError, loggedErrorStats, markErrorReported, parseStackTrace, safeParseBody, sanitizeHeaders, sanitizeObject, sanitizeQueryParams, truncateBody, withBugStack, withErrorCapture };
1079
1489
  //# sourceMappingURL=index.mjs.map
1080
1490
  //# sourceMappingURL=index.mjs.map