glitchgrab 1.68.0 → 1.68.1

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/README.md CHANGED
@@ -884,6 +884,31 @@ hydrateRoot(document, <App />, {
884
884
 
885
885
  Next.js does not expose `hydrateRoot` options, so App Router apps should use the `error.tsx` snippets above.
886
886
 
887
+ ### Console lines and slow requests (browser)
888
+
889
+ On by default — nothing to add. In production the provider files:
890
+
891
+ - every distinct `console.error` / `console.warn` line, and
892
+ - every same-origin request slower than 10 seconds (a `PERFORMANCE` issue,
893
+ labelled `gg:performance`).
894
+
895
+ ```tsx
896
+ <GlitchgrabProvider
897
+ token={token}
898
+ captureConsole={["error"]} // only errors; false turns console capture off
899
+ slowRequestMs={20000} // a different threshold; 0 turns it off
900
+ >
901
+ ```
902
+
903
+ - Production only. A dev server prints hundreds of warnings a minute.
904
+ - One issue per message, and one per endpoint for slow requests (ids folded to
905
+ `[id]`, so `/api/users/42` and `/api/users/97` are one issue). Later repeats
906
+ are added to the open issue as comments. At most 10 such reports per page load.
907
+ - Tokens, emails and URL passwords are scrubbed from the line before it is sent.
908
+ - Third-party calls are ignored. An error React logs and your `error.tsx` then
909
+ files with `captureError` is filed once.
910
+ - `ignoreErrors` silences a noisy line. Needs `breadcrumbs` on (the default).
911
+
887
912
  ### Hydration errors (React #418 family)
888
913
 
889
914
  Nothing to wire. In production the provider catches React #418/#419/#422/#423/#425 with the **component stack** React built for them (Next.js normally throws it away), the server HTML React replaced, any extension or Translate nodes found in the page, and fetch timing. The issue is labelled `gg:hydration` and its title names the element that mismatched. The same mismatch groups into one issue across pages, browsers and deploys. If your site serves source maps (`productionBrowserSourceMaps: true`), Glitchgrab also maps the stack to your source files, so the issue names the nearest component file too.
@@ -1000,6 +1025,40 @@ export function register() {
1000
1025
  without taking over — your process still crashes exactly as it would have. A
1001
1026
  reporter that keeps a broken process alive is worse than no reporter.
1002
1027
 
1028
+ ### Errors Next.js catches in routes, pages and server actions
1029
+
1030
+ Next.js catches these itself and only prints them, so `captureServerErrors()`
1031
+ never sees them. Hand them over from `onRequestError`:
1032
+
1033
+ ```ts
1034
+ // instrumentation.ts
1035
+ export async function register() {
1036
+ if (process.env.NEXT_RUNTIME !== "nodejs") return;
1037
+ const { captureServerErrors } = await import("glitchgrab/server");
1038
+ // Crashes, unhandled rejections AND console.error / console.warn lines.
1039
+ captureServerErrors();
1040
+ }
1041
+
1042
+ export async function onRequestError(
1043
+ ...args: Parameters<typeof import("glitchgrab/server").reportRequestError>
1044
+ ) {
1045
+ if (process.env.NEXT_RUNTIME !== "nodejs") return;
1046
+ const { reportRequestError } = await import("glitchgrab/server");
1047
+ await reportRequestError(...args);
1048
+ }
1049
+ ```
1050
+
1051
+ - One issue per route **file** (`/app/api/users/[id]/route`), not per URL.
1052
+ - Client hang-ups (`Error: aborted`, `ECONNRESET`) are never filed: the browser
1053
+ closed the request, nothing broke.
1054
+ - An error that both `onRequestError` and `console.error` see is filed once.
1055
+ - `captureServerErrors()` files console errors and warnings by default:
1056
+ `captureServerErrors({ console: ["error"] })` for errors only, `console: false`
1057
+ to turn it off. For an `ignore: [/pattern/]` list, set `console: false` and
1058
+ call `captureServerConsole({ levels, ignore })` yourself. Repeats of one line
1059
+ land on one issue; tokens, emails and URL passwords are scrubbed first.
1060
+ - Production only, like everything else here, unless `enableInDevelopment: true`.
1061
+
1003
1062
  ### `context` is the grouping key
1004
1063
 
1005
1064
  It is sent as the report's `pageUrl` (as `server://<context>`), and `pageUrl`
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { h as GlitchgrabProviderProps, U as UseGlitchgrabReturn, R as ReportButtonProps, B as BookedDemo, F as FeedbackButtonProps, i as GlitchgrabSession, C as CaptureErrorOptions, g as GlitchgrabFeedback, c as BreadcrumbType, b as Breadcrumb, d as CapturedContext, D as DeviceInfo, e as FeedbackPayload, f as FeedbackResult, L as LeadInput, j as LeadResult, k as ReportPayload, l as ReportResult } from './types-Dw587jLi.mjs';
3
- export { a as BookingDialogOptions, G as GlitchgrabConfig, m as ReportSeverity, n as ReportType, o as RuntimeInfo } from './types-Dw587jLi.mjs';
2
+ import { h as GlitchgrabProviderProps, U as UseGlitchgrabReturn, R as ReportButtonProps, B as BookedDemo, F as FeedbackButtonProps, i as GlitchgrabSession, C as CaptureErrorOptions, g as GlitchgrabFeedback, c as BreadcrumbType, b as Breadcrumb, d as CapturedContext, D as DeviceInfo, e as FeedbackPayload, f as FeedbackResult, L as LeadInput, j as LeadResult, k as ReportPayload, l as ReportResult } from './types-Dadt801V.mjs';
3
+ export { a as BookingDialogOptions, G as GlitchgrabConfig, m as ReportSeverity, n as ReportType, o as RuntimeInfo } from './types-Dadt801V.mjs';
4
4
  import * as React from 'react';
5
5
  import { ReactNode } from 'react';
6
6
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { h as GlitchgrabProviderProps, U as UseGlitchgrabReturn, R as ReportButtonProps, B as BookedDemo, F as FeedbackButtonProps, i as GlitchgrabSession, C as CaptureErrorOptions, g as GlitchgrabFeedback, c as BreadcrumbType, b as Breadcrumb, d as CapturedContext, D as DeviceInfo, e as FeedbackPayload, f as FeedbackResult, L as LeadInput, j as LeadResult, k as ReportPayload, l as ReportResult } from './types-Dw587jLi.js';
3
- export { a as BookingDialogOptions, G as GlitchgrabConfig, m as ReportSeverity, n as ReportType, o as RuntimeInfo } from './types-Dw587jLi.js';
2
+ import { h as GlitchgrabProviderProps, U as UseGlitchgrabReturn, R as ReportButtonProps, B as BookedDemo, F as FeedbackButtonProps, i as GlitchgrabSession, C as CaptureErrorOptions, g as GlitchgrabFeedback, c as BreadcrumbType, b as Breadcrumb, d as CapturedContext, D as DeviceInfo, e as FeedbackPayload, f as FeedbackResult, L as LeadInput, j as LeadResult, k as ReportPayload, l as ReportResult } from './types-Dadt801V.js';
3
+ export { a as BookingDialogOptions, G as GlitchgrabConfig, m as ReportSeverity, n as ReportType, o as RuntimeInfo } from './types-Dadt801V.js';
4
4
  import * as React from 'react';
5
5
  import { ReactNode } from 'react';
6
6
 
package/dist/index.js CHANGED
@@ -224,9 +224,11 @@ var SENSITIVE_KEY_RE = /(pass|pwd|secret|token|auth|session|cookie|credential|ap
224
224
  var EMAIL_RE = /[\w.+-]+@[\w-]+\.[\w.-]+/g;
225
225
  var JWT_RE = /\beyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]{8,}\b/g;
226
226
  var BEARER_RE = /\b(bearer\s+)[\w-.~+/]{12,}=*/gi;
227
+ var KEY_PREFIX_RE = /\b(?:(?:sk|rk|pk)_(?:live|test)_[A-Za-z0-9]{10,}|sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|AKIA[0-9A-Z]{16}|xox[abposr]-[A-Za-z0-9-]{10,}|gg[cswi]?_[A-Za-z0-9]{20,})\b/g;
227
228
  var MAX_BODY_LENGTH = 500;
229
+ var URL_CREDENTIALS_RE = /\b([a-z][a-z0-9+.-]*:\/\/[^\s:@/]+):[^\s@/]+@/gi;
228
230
  function redactString(value) {
229
- return value.replace(JWT_RE, "[REDACTED]").replace(BEARER_RE, "$1[REDACTED]").replace(EMAIL_RE, "[REDACTED_EMAIL]");
231
+ return value.replace(URL_CREDENTIALS_RE, "$1:[REDACTED]@").replace(KEY_PREFIX_RE, "[REDACTED]").replace(JWT_RE, "[REDACTED]").replace(BEARER_RE, "$1[REDACTED]").replace(EMAIL_RE, "[REDACTED_EMAIL]");
230
232
  }
231
233
  function redactValue(value, depth) {
232
234
  if (depth > 4) return "[DEPTH]";
@@ -275,6 +277,29 @@ function mayCaptureBody(url) {
275
277
  return false;
276
278
  }
277
279
  }
280
+ var consoleObserver = null;
281
+ var requestObserver = null;
282
+ function setConsoleObserver(observer2) {
283
+ consoleObserver = observer2;
284
+ }
285
+ function setRequestObserver(observer2) {
286
+ requestObserver = observer2;
287
+ }
288
+ function isOwnOrigin(url) {
289
+ return mayCaptureBody(url);
290
+ }
291
+ function notifyConsole(level, args) {
292
+ try {
293
+ consoleObserver == null ? void 0 : consoleObserver(level, args);
294
+ } catch (e) {
295
+ }
296
+ }
297
+ function notifyRequest(request) {
298
+ try {
299
+ requestObserver == null ? void 0 : requestObserver(request);
300
+ } catch (e) {
301
+ }
302
+ }
278
303
  function initBreadcrumbs(max, options) {
279
304
  var _a;
280
305
  if ((_a = options == null ? void 0 : options.responseBodyOrigins) == null ? void 0 : _a.length) {
@@ -326,10 +351,12 @@ function interceptConsole() {
326
351
  console.warn = function(...args) {
327
352
  addBreadcrumb("console", `[warn] ${argsToString(args)}`);
328
353
  origWarn.apply(console, args);
354
+ notifyConsole("warn", args);
329
355
  };
330
356
  console.error = function(...args) {
331
357
  addBreadcrumb("console", `[error] ${argsToString(args)}`);
332
358
  origError.apply(console, args);
359
+ notifyConsole("error", args);
333
360
  };
334
361
  }
335
362
  var CONSOLE_TEXT_MAX = 200;
@@ -425,7 +452,7 @@ function interceptFetch() {
425
452
  window.fetch = async function(input, init) {
426
453
  var _a;
427
454
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input instanceof Request ? input.url : String(input);
428
- const method = (_a = init == null ? void 0 : init.method) != null ? _a : "GET";
455
+ const method = ((_a = init == null ? void 0 : init.method) != null ? _a : input instanceof Request ? input.method : "GET").toUpperCase();
429
456
  const start = Date.now();
430
457
  try {
431
458
  const response = await origFetch(
@@ -439,6 +466,7 @@ function interceptFetch() {
439
466
  duration: `${Date.now() - start}ms`,
440
467
  ...body ? { responseBody: body } : {}
441
468
  });
469
+ notifyRequest({ method, url, status: response.status, durationMs: Date.now() - start });
442
470
  return response;
443
471
  } catch (err) {
444
472
  addBreadcrumb("api", `${method} ${url.slice(0, 100)} \u2192 FAILED`, {
@@ -459,7 +487,7 @@ function interceptXhr() {
459
487
  this.__ggMethod = method;
460
488
  this.__ggUrl = typeof url === "string" ? url : url.toString();
461
489
  const record = () => {
462
- var _a, _b, _c, _d;
490
+ var _a, _b, _c, _d, _e, _f;
463
491
  try {
464
492
  const recordedMethod = (_a = this.__ggMethod) != null ? _a : "GET";
465
493
  const recordedUrl = ((_b = this.__ggUrl) != null ? _b : "").slice(0, 100);
@@ -471,8 +499,14 @@ function interceptXhr() {
471
499
  });
472
500
  return;
473
501
  }
502
+ notifyRequest({
503
+ method: recordedMethod,
504
+ url: (_d = this.__ggUrl) != null ? _d : "",
505
+ status: this.status,
506
+ durationMs: Date.now() - ((_e = this.__ggStart) != null ? _e : Date.now())
507
+ });
474
508
  const failed = this.status < 200 || this.status >= 300;
475
- const body = failed && mayCaptureBody((_d = this.__ggUrl) != null ? _d : "") ? readXhrBody(this) : "";
509
+ const body = failed && mayCaptureBody((_f = this.__ggUrl) != null ? _f : "") ? readXhrBody(this) : "";
476
510
  addBreadcrumb("api", `${recordedMethod} ${recordedUrl} \u2192 ${this.status}`, {
477
511
  method: recordedMethod,
478
512
  status: String(this.status),
@@ -1370,6 +1404,23 @@ var config = null;
1370
1404
  function registerCaptureConfig(next) {
1371
1405
  config = next;
1372
1406
  }
1407
+ function getCaptureConfig() {
1408
+ return config;
1409
+ }
1410
+ var reportedErrors = /* @__PURE__ */ new WeakSet();
1411
+ function markErrorReported(error) {
1412
+ try {
1413
+ if (error && typeof error === "object") reportedErrors.add(error);
1414
+ } catch (e) {
1415
+ }
1416
+ }
1417
+ function wasErrorReported(error) {
1418
+ try {
1419
+ return !!error && typeof error === "object" && reportedErrors.has(error);
1420
+ } catch (e) {
1421
+ return false;
1422
+ }
1423
+ }
1373
1424
  function matchesIgnorePatterns(message, patterns) {
1374
1425
  if (!patterns || patterns.length === 0) return false;
1375
1426
  return patterns.some(
@@ -1390,6 +1441,7 @@ function buildCapturedErrorPayload(error, options, cfg, capturedBy = "captureErr
1390
1441
  const errorMessage = err ? err.message : String(error);
1391
1442
  if (!errorMessage) return null;
1392
1443
  if (matchesIgnorePatterns(errorMessage, cfg.ignoreErrors)) return null;
1444
+ markErrorReported(error);
1393
1445
  incrementErrorCount();
1394
1446
  const context = captureContext(cfg.getVisitedPages());
1395
1447
  const digest = (_a = options == null ? void 0 : options.digest) != null ? _a : typeof (error == null ? void 0 : error.digest) === "string" ? error.digest : void 0;
@@ -3175,7 +3227,7 @@ function AssistSheet({
3175
3227
  seedFromDescription();
3176
3228
  }
3177
3229
  }
3178
- function send(text) {
3230
+ function send2(text) {
3179
3231
  const value = text.trim();
3180
3232
  if (!value || busy) return;
3181
3233
  setStalled(null);
@@ -3979,7 +4031,7 @@ function AssistSheet({
3979
4031
  "data-gg-chip": "",
3980
4032
  onClick: () => {
3981
4033
  logEvent("starter_tap", s);
3982
- send(s);
4034
+ send2(s);
3983
4035
  },
3984
4036
  style: {
3985
4037
  border: `1px solid ${t.inputBorder}`,
@@ -4146,7 +4198,7 @@ function AssistSheet({
4146
4198
  "data-gg-glitchgrab-offer-no": "",
4147
4199
  onClick: () => {
4148
4200
  logEvent("glitchgrab_offer_declined");
4149
- send("No \u2014 it's about this app, not the reporting tool");
4201
+ send2("No \u2014 it's about this app, not the reporting tool");
4150
4202
  },
4151
4203
  style: {
4152
4204
  padding: "8px 12px",
@@ -4191,7 +4243,7 @@ function AssistSheet({
4191
4243
  "data-gg-option": "",
4192
4244
  onClick: () => {
4193
4245
  logEvent("option_tap", option);
4194
- send(option);
4246
+ send2(option);
4195
4247
  },
4196
4248
  style: {
4197
4249
  border: primary ? "1px solid transparent" : `1px solid ${t.inputBorder}`,
@@ -4959,7 +5011,7 @@ function AssistSheet({
4959
5011
  onKeyDown: (e) => {
4960
5012
  if (e.key === "Enter" && !e.shiftKey) {
4961
5013
  e.preventDefault();
4962
- send(input);
5014
+ send2(input);
4963
5015
  }
4964
5016
  },
4965
5017
  placeholder: phase === "draft" ? "Anything to change? Tell me here\u2026" : phase === "type" ? "What went wrong, or what would you like? Type it here\u2026" : "Type your answer\u2026",
@@ -4989,7 +5041,7 @@ function AssistSheet({
4989
5041
  {
4990
5042
  type: "button",
4991
5043
  "data-gg-sheet-send": "",
4992
- onClick: () => send(input),
5044
+ onClick: () => send2(input),
4993
5045
  disabled: busy || !input.trim(),
4994
5046
  "aria-label": "Send message",
4995
5047
  "data-gg-send-message": "",
@@ -5124,7 +5176,7 @@ function describeSentAlong(hasChat, screenshotCount) {
5124
5176
  return `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
5125
5177
  }
5126
5178
  function GlitchgrabProblemPanel({
5127
- send,
5179
+ send: send2,
5128
5180
  theme: t,
5129
5181
  surface,
5130
5182
  conversationId,
@@ -5195,7 +5247,7 @@ function GlitchgrabProblemPanel({
5195
5247
  setBusy(true);
5196
5248
  setError(null);
5197
5249
  try {
5198
- const result = await send({
5250
+ const result = await send2({
5199
5251
  description,
5200
5252
  surface,
5201
5253
  conversationId,
@@ -10821,6 +10873,174 @@ function describeRejection(reason) {
10821
10873
  }
10822
10874
  }
10823
10875
 
10876
+ // src/auto-signals.ts
10877
+ var DEFAULT_CAPTURE_CONSOLE = ["error", "warn"];
10878
+ var DEFAULT_SLOW_REQUEST_MS = 1e4;
10879
+ var CONSOLE_MESSAGE_MAX = 500;
10880
+ var ERROR_ARG_DELAY_MS = 1e3;
10881
+ var CONSOLE_NOISE = [
10882
+ /^\[glitchgrab\]/i,
10883
+ /ResizeObserver loop/i,
10884
+ /\b(?:chrome|safari|moz)-extension:\/\//,
10885
+ /Download the React DevTools/i
10886
+ ];
10887
+ var filing = false;
10888
+ var MAX_SIGNALS_PER_PAGE = 10;
10889
+ var sentThisPage = 0;
10890
+ function firstError(args) {
10891
+ return args.find((a) => a instanceof Error);
10892
+ }
10893
+ function routeOf(url) {
10894
+ var _a;
10895
+ try {
10896
+ const base = typeof window !== "undefined" ? window.location.href : "http://localhost";
10897
+ const { pathname } = new URL(url, base);
10898
+ return pathname.split("/").map(
10899
+ (part) => /^\d+$/.test(part) || /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(part) || /^c[a-z0-9]{20,}$/.test(part) || /^[0-9a-f]{24}$/i.test(part) ? "[id]" : part
10900
+ ).join("/") || "/";
10901
+ } catch (e) {
10902
+ return (_a = url.split("?")[0]) != null ? _a : url;
10903
+ }
10904
+ }
10905
+ function send(payload, baseUrl) {
10906
+ const cfg = getCaptureConfig();
10907
+ if (sentThisPage >= MAX_SIGNALS_PER_PAGE) return;
10908
+ sentThisPage += 1;
10909
+ filing = true;
10910
+ try {
10911
+ void sendReport(payload, baseUrl).then((result) => {
10912
+ if (result && (cfg == null ? void 0 : cfg.onReportSent)) cfg.onReportSent(result);
10913
+ });
10914
+ } finally {
10915
+ filing = false;
10916
+ }
10917
+ }
10918
+ function fileConsole(level, args) {
10919
+ var _a;
10920
+ try {
10921
+ const cfg = getCaptureConfig();
10922
+ if (!(cfg == null ? void 0 : cfg.token)) return;
10923
+ const err = firstError(args);
10924
+ if (err && wasErrorReported(err)) return;
10925
+ const text = redactString(
10926
+ (err && args.length === 1 ? err.message : argsToString(args)).slice(0, CONSOLE_MESSAGE_MAX)
10927
+ );
10928
+ if (!text.trim()) return;
10929
+ if (CONSOLE_NOISE.some((re) => re.test(text))) return;
10930
+ if (matchesIgnorePatterns(text, cfg.ignoreErrors)) return;
10931
+ const errorMessage = `console.${level}: ${text}`;
10932
+ const errorStack = (err == null ? void 0 : err.stack) ? redactString(err.stack) : void 0;
10933
+ const context = captureContext(cfg.getVisitedPages());
10934
+ const sig = computeSignature({ errorMessage, pageUrl: context.url, errorStack });
10935
+ if (shouldSkipDuplicate(sig)) return;
10936
+ send(
10937
+ {
10938
+ token: cfg.token,
10939
+ source: "SDK_AUTO",
10940
+ type: "BUG",
10941
+ errorMessage,
10942
+ errorStack,
10943
+ pageUrl: context.url,
10944
+ userAgent: context.userAgent,
10945
+ breadcrumbs: context.breadcrumbs,
10946
+ deviceInfo: (_a = context.deviceInfo) != null ? _a : void 0,
10947
+ metadata: {
10948
+ timestamp: context.timestamp,
10949
+ visitedPages: JSON.stringify(context.visitedPages),
10950
+ capturedBy: `console.${level}`,
10951
+ autoKind: "console",
10952
+ consoleLevel: level,
10953
+ ...contextMetadata(context),
10954
+ ...originMetadata(err == null ? void 0 : err.stack),
10955
+ ...sessionMetadata2(cfg.session)
10956
+ }
10957
+ },
10958
+ cfg.baseUrl
10959
+ );
10960
+ } catch (e) {
10961
+ }
10962
+ }
10963
+ function fileSlowRequest(request, thresholdMs) {
10964
+ var _a, _b;
10965
+ try {
10966
+ const cfg = getCaptureConfig();
10967
+ if (!(cfg == null ? void 0 : cfg.token)) return;
10968
+ if (request.durationMs < thresholdMs) return;
10969
+ if (!isOwnOrigin(request.url)) return;
10970
+ const own = (_a = cfg.baseUrl) != null ? _a : DEFAULT_BASE_URL;
10971
+ if (request.url.startsWith(own) || request.url.includes("/api/v1/sdk/")) return;
10972
+ const method = request.method.toUpperCase();
10973
+ const route = routeOf(request.url);
10974
+ const errorMessage = `Slow request: ${method} ${route}`;
10975
+ if (matchesIgnorePatterns(errorMessage, cfg.ignoreErrors)) return;
10976
+ const context = captureContext(cfg.getVisitedPages());
10977
+ const sig = computeSignature({ errorMessage, pageUrl: context.url });
10978
+ if (shouldSkipDuplicate(sig)) return;
10979
+ const seconds = (request.durationMs / 1e3).toFixed(1);
10980
+ send(
10981
+ {
10982
+ token: cfg.token,
10983
+ source: "SDK_AUTO",
10984
+ type: "PERFORMANCE",
10985
+ errorMessage,
10986
+ description: `${method} ${route} took ${seconds}s (threshold ${(thresholdMs / 1e3).toFixed(1)}s)${request.status ? `, answered ${request.status}` : ", never completed"}.`,
10987
+ pageUrl: context.url,
10988
+ userAgent: context.userAgent,
10989
+ breadcrumbs: context.breadcrumbs,
10990
+ deviceInfo: (_b = context.deviceInfo) != null ? _b : void 0,
10991
+ metadata: {
10992
+ timestamp: context.timestamp,
10993
+ visitedPages: JSON.stringify(context.visitedPages),
10994
+ capturedBy: "slowRequestMs",
10995
+ autoKind: "slow-request",
10996
+ requestMethod: method,
10997
+ requestRoute: route,
10998
+ durationMs: String(request.durationMs),
10999
+ thresholdMs: String(thresholdMs),
11000
+ ...request.status ? { status: String(request.status) } : {},
11001
+ ...contextMetadata(context),
11002
+ ...sessionMetadata2(cfg.session)
11003
+ }
11004
+ },
11005
+ cfg.baseUrl
11006
+ );
11007
+ } catch (e) {
11008
+ }
11009
+ }
11010
+ function sessionMetadata2(session) {
11011
+ return {
11012
+ ...(session == null ? void 0 : session.userId) ? { sessionUserId: session.userId } : {},
11013
+ ...(session == null ? void 0 : session.name) ? { sessionUserName: String(session.name) } : {},
11014
+ ...(session == null ? void 0 : session.email) ? { sessionUserEmail: String(session.email) } : {},
11015
+ ...(session == null ? void 0 : session.phone) ? { sessionUserPhone: String(session.phone) } : {}
11016
+ };
11017
+ }
11018
+ function installAutoSignals(options) {
11019
+ var _a;
11020
+ try {
11021
+ const levels = new Set((_a = options.captureConsole) != null ? _a : []);
11022
+ const slowMs = options.slowRequestMs && options.slowRequestMs > 0 ? options.slowRequestMs : 0;
11023
+ setConsoleObserver(
11024
+ levels.size ? (level, args) => {
11025
+ if (filing || !levels.has(level)) return;
11026
+ if (firstError(args)) {
11027
+ setTimeout(() => fileConsole(level, args), ERROR_ARG_DELAY_MS);
11028
+ } else {
11029
+ fileConsole(level, args);
11030
+ }
11031
+ } : null
11032
+ );
11033
+ setRequestObserver(slowMs ? (request) => fileSlowRequest(request, slowMs) : null);
11034
+ return () => {
11035
+ setConsoleObserver(null);
11036
+ setRequestObserver(null);
11037
+ };
11038
+ } catch (e) {
11039
+ return () => {
11040
+ };
11041
+ }
11042
+ }
11043
+
10824
11044
  // src/shortcut.ts
10825
11045
  var GLITCHGRAB_SHORTCUT2 = "Ctrl+Shift+G";
10826
11046
  var GLITCHGRAB_SHORTCUT_MAC2 = "\u2318\u21E7G";
@@ -10865,7 +11085,9 @@ function GlitchgrabProviderInner({
10865
11085
  ignoreErrors,
10866
11086
  release: release2,
10867
11087
  context: appContext2,
10868
- responseBodyOrigins: responseBodyOrigins2
11088
+ responseBodyOrigins: responseBodyOrigins2,
11089
+ captureConsole = DEFAULT_CAPTURE_CONSOLE,
11090
+ slowRequestMs = DEFAULT_SLOW_REQUEST_MS
10869
11091
  }) {
10870
11092
  const visitedPagesRef = (0, import_react6.useRef)([]);
10871
11093
  const sessionKey = sessionProp ? [
@@ -10896,6 +11118,16 @@ function GlitchgrabProviderInner({
10896
11118
  initBreadcrumbs(maxBreadcrumbs2, { responseBodyOrigins: responseBodyOrigins2 });
10897
11119
  }
10898
11120
  }, [enableBreadcrumbs, maxBreadcrumbs2, responseBodyOrigins2 == null ? void 0 : responseBodyOrigins2.join(",")]);
11121
+ const captureConsoleKey = captureConsole ? captureConsole.join(",") : "";
11122
+ (0, import_react6.useEffect)(() => {
11123
+ if (!enableBreadcrumbs) return;
11124
+ if (process.env.NODE_ENV === "development") return;
11125
+ if (!captureConsoleKey && !slowRequestMs) return;
11126
+ return installAutoSignals({
11127
+ captureConsole: captureConsoleKey ? captureConsoleKey.split(",") : [],
11128
+ slowRequestMs
11129
+ });
11130
+ }, [enableBreadcrumbs, captureConsoleKey, slowRequestMs]);
10899
11131
  (0, import_react6.useEffect)(() => {
10900
11132
  try {
10901
11133
  if (typeof window === "undefined") return;
@@ -10962,6 +11194,7 @@ function GlitchgrabProviderInner({
10962
11194
  return;
10963
11195
  }
10964
11196
  if (isHandledHydrationError(event.error)) return;
11197
+ markErrorReported(event.error);
10965
11198
  incrementErrorCount();
10966
11199
  const context = captureContext(visitedPagesRef.current);
10967
11200
  const sig = computeSignature({
@@ -11019,6 +11252,7 @@ function GlitchgrabProviderInner({
11019
11252
  }
11020
11253
  if (errStack && EXTENSION_ORIGIN_RE.test(errStack)) return;
11021
11254
  if (isUnactionableRejection(description)) return;
11255
+ markErrorReported(reason);
11022
11256
  incrementErrorCount();
11023
11257
  const context = captureContext(visitedPagesRef.current);
11024
11258
  const sig = computeSignature({