glitchgrab 1.68.0 → 1.68.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.
package/dist/index.mjs CHANGED
@@ -159,9 +159,11 @@ var SENSITIVE_KEY_RE = /(pass|pwd|secret|token|auth|session|cookie|credential|ap
159
159
  var EMAIL_RE = /[\w.+-]+@[\w-]+\.[\w.-]+/g;
160
160
  var JWT_RE = /\beyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]{8,}\b/g;
161
161
  var BEARER_RE = /\b(bearer\s+)[\w-.~+/]{12,}=*/gi;
162
+ 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;
162
163
  var MAX_BODY_LENGTH = 500;
164
+ var URL_CREDENTIALS_RE = /\b([a-z][a-z0-9+.-]*:\/\/[^\s:@/]+):[^\s@/]+@/gi;
163
165
  function redactString(value) {
164
- return value.replace(JWT_RE, "[REDACTED]").replace(BEARER_RE, "$1[REDACTED]").replace(EMAIL_RE, "[REDACTED_EMAIL]");
166
+ 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]");
165
167
  }
166
168
  function redactValue(value, depth) {
167
169
  if (depth > 4) return "[DEPTH]";
@@ -210,6 +212,29 @@ function mayCaptureBody(url) {
210
212
  return false;
211
213
  }
212
214
  }
215
+ var consoleObserver = null;
216
+ var requestObserver = null;
217
+ function setConsoleObserver(observer2) {
218
+ consoleObserver = observer2;
219
+ }
220
+ function setRequestObserver(observer2) {
221
+ requestObserver = observer2;
222
+ }
223
+ function isOwnOrigin(url) {
224
+ return mayCaptureBody(url);
225
+ }
226
+ function notifyConsole(level, args) {
227
+ try {
228
+ consoleObserver == null ? void 0 : consoleObserver(level, args);
229
+ } catch (e) {
230
+ }
231
+ }
232
+ function notifyRequest(request) {
233
+ try {
234
+ requestObserver == null ? void 0 : requestObserver(request);
235
+ } catch (e) {
236
+ }
237
+ }
213
238
  function initBreadcrumbs(max, options) {
214
239
  var _a;
215
240
  if ((_a = options == null ? void 0 : options.responseBodyOrigins) == null ? void 0 : _a.length) {
@@ -261,10 +286,12 @@ function interceptConsole() {
261
286
  console.warn = function(...args) {
262
287
  addBreadcrumb("console", `[warn] ${argsToString(args)}`);
263
288
  origWarn.apply(console, args);
289
+ notifyConsole("warn", args);
264
290
  };
265
291
  console.error = function(...args) {
266
292
  addBreadcrumb("console", `[error] ${argsToString(args)}`);
267
293
  origError.apply(console, args);
294
+ notifyConsole("error", args);
268
295
  };
269
296
  }
270
297
  var CONSOLE_TEXT_MAX = 200;
@@ -360,7 +387,7 @@ function interceptFetch() {
360
387
  window.fetch = async function(input, init) {
361
388
  var _a;
362
389
  const url = typeof input === "string" ? input : input instanceof URL ? input.toString() : input instanceof Request ? input.url : String(input);
363
- const method = (_a = init == null ? void 0 : init.method) != null ? _a : "GET";
390
+ const method = ((_a = init == null ? void 0 : init.method) != null ? _a : input instanceof Request ? input.method : "GET").toUpperCase();
364
391
  const start = Date.now();
365
392
  try {
366
393
  const response = await origFetch(
@@ -374,6 +401,7 @@ function interceptFetch() {
374
401
  duration: `${Date.now() - start}ms`,
375
402
  ...body ? { responseBody: body } : {}
376
403
  });
404
+ notifyRequest({ method, url, status: response.status, durationMs: Date.now() - start });
377
405
  return response;
378
406
  } catch (err) {
379
407
  addBreadcrumb("api", `${method} ${url.slice(0, 100)} \u2192 FAILED`, {
@@ -394,7 +422,7 @@ function interceptXhr() {
394
422
  this.__ggMethod = method;
395
423
  this.__ggUrl = typeof url === "string" ? url : url.toString();
396
424
  const record = () => {
397
- var _a, _b, _c, _d;
425
+ var _a, _b, _c, _d, _e, _f;
398
426
  try {
399
427
  const recordedMethod = (_a = this.__ggMethod) != null ? _a : "GET";
400
428
  const recordedUrl = ((_b = this.__ggUrl) != null ? _b : "").slice(0, 100);
@@ -406,8 +434,14 @@ function interceptXhr() {
406
434
  });
407
435
  return;
408
436
  }
437
+ notifyRequest({
438
+ method: recordedMethod,
439
+ url: (_d = this.__ggUrl) != null ? _d : "",
440
+ status: this.status,
441
+ durationMs: Date.now() - ((_e = this.__ggStart) != null ? _e : Date.now())
442
+ });
409
443
  const failed = this.status < 200 || this.status >= 300;
410
- const body = failed && mayCaptureBody((_d = this.__ggUrl) != null ? _d : "") ? readXhrBody(this) : "";
444
+ const body = failed && mayCaptureBody((_f = this.__ggUrl) != null ? _f : "") ? readXhrBody(this) : "";
411
445
  addBreadcrumb("api", `${recordedMethod} ${recordedUrl} \u2192 ${this.status}`, {
412
446
  method: recordedMethod,
413
447
  status: String(this.status),
@@ -1305,6 +1339,23 @@ var config = null;
1305
1339
  function registerCaptureConfig(next) {
1306
1340
  config = next;
1307
1341
  }
1342
+ function getCaptureConfig() {
1343
+ return config;
1344
+ }
1345
+ var reportedErrors = /* @__PURE__ */ new WeakSet();
1346
+ function markErrorReported(error) {
1347
+ try {
1348
+ if (error && typeof error === "object") reportedErrors.add(error);
1349
+ } catch (e) {
1350
+ }
1351
+ }
1352
+ function wasErrorReported(error) {
1353
+ try {
1354
+ return !!error && typeof error === "object" && reportedErrors.has(error);
1355
+ } catch (e) {
1356
+ return false;
1357
+ }
1358
+ }
1308
1359
  function matchesIgnorePatterns(message, patterns) {
1309
1360
  if (!patterns || patterns.length === 0) return false;
1310
1361
  return patterns.some(
@@ -1325,6 +1376,7 @@ function buildCapturedErrorPayload(error, options, cfg, capturedBy = "captureErr
1325
1376
  const errorMessage = err ? err.message : String(error);
1326
1377
  if (!errorMessage) return null;
1327
1378
  if (matchesIgnorePatterns(errorMessage, cfg.ignoreErrors)) return null;
1379
+ markErrorReported(error);
1328
1380
  incrementErrorCount();
1329
1381
  const context = captureContext(cfg.getVisitedPages());
1330
1382
  const digest = (_a = options == null ? void 0 : options.digest) != null ? _a : typeof (error == null ? void 0 : error.digest) === "string" ? error.digest : void 0;
@@ -1984,18 +2036,6 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
1984
2036
  }
1985
2037
  );
1986
2038
  }
1987
- var SEVERITY_LEVELS = [
1988
- "low",
1989
- "medium",
1990
- "high",
1991
- "critical"
1992
- ];
1993
- var SEVERITY_LABELS = {
1994
- low: "Low",
1995
- medium: "Medium",
1996
- high: "High",
1997
- critical: "Critical"
1998
- };
1999
2039
  var MAX_ASSIST_IMAGES = 3;
2000
2040
  var MAX_ASSIST_IMAGE_CHARS = 35e5;
2001
2041
  var MAX_ASSIST_FILES = 3;
@@ -2772,11 +2812,7 @@ function AssistSheet({
2772
2812
  onDescriptionChange,
2773
2813
  issueTitle,
2774
2814
  onIssueTitleChange,
2775
- severity,
2776
- onSeverityChange,
2777
- showSeverity,
2778
2815
  validationError,
2779
- severityRefused = false,
2780
2816
  onDuplicateChange,
2781
2817
  onConversationChange,
2782
2818
  isSubmitting,
@@ -2792,7 +2828,6 @@ function AssistSheet({
2792
2828
  }) {
2793
2829
  var _a;
2794
2830
  const narrow = useIsNarrow();
2795
- const severityAsked = showSeverity && currentTile === "BUG";
2796
2831
  const [messages, setMessages] = useState2([]);
2797
2832
  const [input, setInput] = useState2("");
2798
2833
  const [busy, setBusy] = useState2(false);
@@ -2818,15 +2853,13 @@ function AssistSheet({
2818
2853
  const [duplicate, setDuplicate] = useState2(null);
2819
2854
  const [glitchgrabOffer, setGlitchgrabOffer] = useState2(false);
2820
2855
  const [solved, setSolved] = useState2(null);
2821
- const needsSeverity = (tile) => showSeverity && tile === "BUG" && !severity;
2822
2856
  const [phase, setPhase] = useState2(
2823
- () => !typePicked ? "type" : currentTile === "RATING" ? "rating" : needsSeverity(currentTile) ? "severity" : "chat"
2857
+ () => !typePicked ? "type" : currentTile === "RATING" ? "rating" : "chat"
2824
2858
  );
2825
2859
  const scrollRef = useRef2(null);
2826
2860
  const draftRef = useRef2(null);
2827
2861
  const composerRef = useRef2(null);
2828
2862
  const seededRef = useRef2(false);
2829
- const seedPendingRef = useRef2(false);
2830
2863
  const resumeAskRef = useRef2(false);
2831
2864
  const eventsRef = useRef2([]);
2832
2865
  const inferredTypeRef = useRef2(false);
@@ -3094,10 +3127,6 @@ function AssistSheet({
3094
3127
  }
3095
3128
  return;
3096
3129
  }
3097
- if (phase === "severity") {
3098
- seedPendingRef.current = true;
3099
- return;
3100
- }
3101
3130
  seedFromDescription();
3102
3131
  }, []);
3103
3132
  function seedFromDescription() {
@@ -3107,15 +3136,7 @@ function AssistSheet({
3107
3136
  setMessages(history2);
3108
3137
  void runTurn(history2);
3109
3138
  }
3110
- function answerSeverity(value) {
3111
- onSeverityChange(value);
3112
- setPhase("chat");
3113
- if (seedPendingRef.current) {
3114
- seedPendingRef.current = false;
3115
- seedFromDescription();
3116
- }
3117
- }
3118
- function send(text) {
3139
+ function send2(text) {
3119
3140
  const value = text.trim();
3120
3141
  if (!value || busy) return;
3121
3142
  setStalled(null);
@@ -3207,7 +3228,6 @@ function AssistSheet({
3207
3228
  setShowChats(false);
3208
3229
  setViewingChat(null);
3209
3230
  resumeAskRef.current = (last == null ? void 0 : last.role) === "user";
3210
- seedPendingRef.current = false;
3211
3231
  }
3212
3232
  useEffect2(() => {
3213
3233
  if (!resumeAskRef.current) return;
@@ -3595,7 +3615,6 @@ function AssistSheet({
3595
3615
  ),
3596
3616
  /* @__PURE__ */ jsxs3("div", { style: { fontSize: "11.5px", color: t.textMuted, marginTop: "3px" }, children: [
3597
3617
  phase === "type" || !typePicked || inferredTypeRef.current && phase !== "draft" ? null : reportTypeLabel,
3598
- phase !== "type" && severityAsked && severity ? ` \xB7 ${SEVERITY_LABELS[severity]}` : null,
3599
3618
  projectSlot ? /* @__PURE__ */ jsx3("span", { style: { marginLeft: "6px" }, children: projectSlot }) : null
3600
3619
  ] })
3601
3620
  ] }),
@@ -3706,63 +3725,6 @@ function AssistSheet({
3706
3725
  minWidth: 0
3707
3726
  },
3708
3727
  children: /* @__PURE__ */ jsxs3("div", { style: { display: showChats ? "none" : "contents" }, children: [
3709
- phase === "severity" && /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [
3710
- resumeCard,
3711
- /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
3712
- /* @__PURE__ */ jsx3(Avatar, { who: "assistant", theme: t }),
3713
- /* @__PURE__ */ jsx3(
3714
- "div",
3715
- {
3716
- style: {
3717
- padding: "9px 12px",
3718
- borderRadius: "12px 12px 12px 4px",
3719
- backgroundColor: t.bgSecondary,
3720
- fontSize: "13px",
3721
- lineHeight: 1.55,
3722
- maxWidth: "88%"
3723
- },
3724
- children: "How bad is it?"
3725
- }
3726
- )
3727
- ] }),
3728
- /* @__PURE__ */ jsx3(
3729
- "div",
3730
- {
3731
- role: "radiogroup",
3732
- "aria-label": "Severity",
3733
- style: {
3734
- display: "flex",
3735
- flexWrap: "wrap",
3736
- gap: "6px",
3737
- paddingLeft: "32px"
3738
- },
3739
- children: SEVERITY_LEVELS.map((s) => /* @__PURE__ */ jsx3(
3740
- "button",
3741
- {
3742
- type: "button",
3743
- role: "radio",
3744
- "aria-checked": severity === s,
3745
- "data-gg-chip": "",
3746
- "data-gg-severity": s,
3747
- onClick: () => answerSeverity(s),
3748
- style: {
3749
- border: `1px solid ${t.inputBorder}`,
3750
- background: "transparent",
3751
- color: t.textMuted,
3752
- borderRadius: "999px",
3753
- // Same as the picker and option chips — one chip size.
3754
- padding: "8px 12px",
3755
- fontSize: "12px",
3756
- fontFamily: "inherit",
3757
- cursor: "pointer"
3758
- },
3759
- children: SEVERITY_LABELS[s]
3760
- },
3761
- s
3762
- ))
3763
- }
3764
- )
3765
- ] }),
3766
3728
  phase === "rating" && !submitted && /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [
3767
3729
  /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
3768
3730
  /* @__PURE__ */ jsx3(Avatar, { who: "assistant", theme: t }),
@@ -3919,7 +3881,7 @@ function AssistSheet({
3919
3881
  "data-gg-chip": "",
3920
3882
  onClick: () => {
3921
3883
  logEvent("starter_tap", s);
3922
- send(s);
3884
+ send2(s);
3923
3885
  },
3924
3886
  style: {
3925
3887
  border: `1px solid ${t.inputBorder}`,
@@ -4086,7 +4048,7 @@ function AssistSheet({
4086
4048
  "data-gg-glitchgrab-offer-no": "",
4087
4049
  onClick: () => {
4088
4050
  logEvent("glitchgrab_offer_declined");
4089
- send("No \u2014 it's about this app, not the reporting tool");
4051
+ send2("No \u2014 it's about this app, not the reporting tool");
4090
4052
  },
4091
4053
  style: {
4092
4054
  padding: "8px 12px",
@@ -4131,7 +4093,7 @@ function AssistSheet({
4131
4093
  "data-gg-option": "",
4132
4094
  onClick: () => {
4133
4095
  logEvent("option_tap", option);
4134
- send(option);
4096
+ send2(option);
4135
4097
  },
4136
4098
  style: {
4137
4099
  border: primary ? "1px solid transparent" : `1px solid ${t.inputBorder}`,
@@ -4365,71 +4327,6 @@ function AssistSheet({
4365
4327
  }
4366
4328
  }
4367
4329
  ),
4368
- severityAsked && /* @__PURE__ */ jsxs3("div", { children: [
4369
- /* @__PURE__ */ jsxs3(
4370
- "span",
4371
- {
4372
- style: {
4373
- fontSize: "11.5px",
4374
- color: t.textMuted,
4375
- display: "block",
4376
- marginBottom: "6px"
4377
- },
4378
- children: [
4379
- "How bad is it?",
4380
- !severity && /* @__PURE__ */ jsx3(
4381
- "span",
4382
- {
4383
- style: {
4384
- marginLeft: "6px",
4385
- fontSize: "11px",
4386
- color: severityRefused ? "#ef4444" : t.textMuted
4387
- },
4388
- children: "\xB7 required"
4389
- }
4390
- )
4391
- ]
4392
- }
4393
- ),
4394
- /* @__PURE__ */ jsx3(
4395
- "div",
4396
- {
4397
- role: "radiogroup",
4398
- "aria-label": "Severity",
4399
- style: { display: "flex", gap: "6px" },
4400
- children: SEVERITY_LEVELS.map((s) => {
4401
- const on = severity === s;
4402
- return /* @__PURE__ */ jsx3(
4403
- "button",
4404
- {
4405
- type: "button",
4406
- onClick: () => onSeverityChange(s),
4407
- role: "radio",
4408
- "aria-checked": on,
4409
- style: {
4410
- flex: 1,
4411
- minWidth: 0,
4412
- padding: "8px 2px",
4413
- borderRadius: "8px",
4414
- border: `1px solid ${on ? t.accent : severityRefused ? "#ef4444" : t.inputBorder}`,
4415
- backgroundColor: on ? t.accent : "transparent",
4416
- color: on ? t.accentText : t.textMuted,
4417
- fontSize: "12px",
4418
- fontWeight: 600,
4419
- fontFamily: "inherit",
4420
- whiteSpace: "nowrap",
4421
- overflow: "hidden",
4422
- textOverflow: "ellipsis",
4423
- cursor: "pointer"
4424
- },
4425
- children: SEVERITY_LABELS[s]
4426
- },
4427
- s
4428
- );
4429
- })
4430
- }
4431
- )
4432
- ] }),
4433
4330
  attachmentCount > 0 && /* @__PURE__ */ jsxs3("span", { style: { fontSize: "11.5px", color: t.textMuted }, children: [
4434
4331
  attachmentCount,
4435
4332
  " ",
@@ -4485,7 +4382,7 @@ function AssistSheet({
4485
4382
  ]
4486
4383
  }
4487
4384
  ),
4488
- !submitted && !showChats && phase !== "severity" && /* @__PURE__ */ jsxs3(
4385
+ !submitted && !showChats && /* @__PURE__ */ jsxs3(
4489
4386
  "div",
4490
4387
  {
4491
4388
  style: {
@@ -4899,7 +4796,7 @@ function AssistSheet({
4899
4796
  onKeyDown: (e) => {
4900
4797
  if (e.key === "Enter" && !e.shiftKey) {
4901
4798
  e.preventDefault();
4902
- send(input);
4799
+ send2(input);
4903
4800
  }
4904
4801
  },
4905
4802
  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",
@@ -4929,7 +4826,7 @@ function AssistSheet({
4929
4826
  {
4930
4827
  type: "button",
4931
4828
  "data-gg-sheet-send": "",
4932
- onClick: () => send(input),
4829
+ onClick: () => send2(input),
4933
4830
  disabled: busy || !input.trim(),
4934
4831
  "aria-label": "Send message",
4935
4832
  "data-gg-send-message": "",
@@ -5064,7 +4961,7 @@ function describeSentAlong(hasChat, screenshotCount) {
5064
4961
  return `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
5065
4962
  }
5066
4963
  function GlitchgrabProblemPanel({
5067
- send,
4964
+ send: send2,
5068
4965
  theme: t,
5069
4966
  surface,
5070
4967
  conversationId,
@@ -5135,7 +5032,7 @@ function GlitchgrabProblemPanel({
5135
5032
  setBusy(true);
5136
5033
  setError(null);
5137
5034
  try {
5138
- const result = await send({
5035
+ const result = await send2({
5139
5036
  description,
5140
5037
  surface,
5141
5038
  conversationId,
@@ -5746,7 +5643,6 @@ function detectHostAccent() {
5746
5643
  return null;
5747
5644
  }
5748
5645
  }
5749
- var SEVERITY_REQUIRED = "Pick how bad it is before sending.";
5750
5646
  var SHOT_WAIT_MS = 3e3;
5751
5647
  var SIMILAR_WAIT_MS = 2500;
5752
5648
  var MAX_SIMILAR_SHOWN = 3;
@@ -5977,7 +5873,6 @@ function ReportDialog({
5977
5873
  assistContext = null,
5978
5874
  transcribeAudio: transcribeAudio2,
5979
5875
  types,
5980
- showSeverity = true,
5981
5876
  captureScreenshot = captureDefaultScreenshot,
5982
5877
  reporter: reporter2,
5983
5878
  onClose,
@@ -6104,14 +5999,12 @@ function ReportDialog({
6104
5999
  }, [isOpen]);
6105
6000
  const [step, setStep] = useState4(1);
6106
6001
  const [reportType, setReportType] = useState4("BUG");
6107
- const [severity, setSeverity] = useState4(null);
6108
6002
  const [validationError, setValidationError] = useState4(null);
6109
6003
  const [placeholderIdx, setPlaceholderIdx] = useState4(0);
6110
6004
  const [rating, setRating] = useState4(0);
6111
6005
  const [hoveredStar, setHoveredStar] = useState4(0);
6112
6006
  const isRating = reportType === "RATING";
6113
6007
  const submitDisabled = isSubmitting || (isRating ? rating < 1 : !description.trim());
6114
- const needsSeverity = validationError === SEVERITY_REQUIRED && showSeverity && reportType === "BUG" && !severity;
6115
6008
  const availableTypes = types != null ? types : [
6116
6009
  "BUG",
6117
6010
  "FEATURE_REQUEST",
@@ -6456,7 +6349,6 @@ function ReportDialog({
6456
6349
  setPickedSimilar(null);
6457
6350
  setCheckingSimilar(false);
6458
6351
  setAttachingTo(null);
6459
- setSeverity(null);
6460
6352
  setValidationError(null);
6461
6353
  setSelfReportFrom(null);
6462
6354
  setVoiceError(null);
@@ -6682,11 +6574,6 @@ function ReportDialog({
6682
6574
  setStep(2);
6683
6575
  return;
6684
6576
  }
6685
- if (showSeverity && reportType === "BUG" && !severity) {
6686
- setValidationError(SEVERITY_REQUIRED);
6687
- setStep(2);
6688
- return;
6689
- }
6690
6577
  const duplicateOf = (_a2 = opts == null ? void 0 : opts.duplicateOf) != null ? _a2 : duplicateIssueNumber;
6691
6578
  const attachKind = (opts == null ? void 0 : opts.duplicateOf) ? (_b = opts.kind) != null ? _b : "duplicate" : duplicateKind;
6692
6579
  if (findSimilarIssues2 && !(opts == null ? void 0 : opts.skipSimilar) && !duplicateOf) {
@@ -6727,9 +6614,6 @@ function ReportDialog({
6727
6614
  const metadata = {};
6728
6615
  if (shots.length > 0) metadata.screenshots = JSON.stringify(shots);
6729
6616
  if (attachments.length > 0) metadata.attachments = JSON.stringify(attachments);
6730
- if (showSeverity && reportType === "BUG" && severity) {
6731
- metadata.severity = severity;
6732
- }
6733
6617
  if (duplicateOf) {
6734
6618
  metadata.duplicateIssueNumber = String(duplicateOf);
6735
6619
  if (attachKind === "related") metadata.duplicateKind = "related";
@@ -8495,82 +8379,6 @@ function ReportDialog({
8495
8379
  }
8496
8380
  )
8497
8381
  ] }),
8498
- showSeverity && reportType === "BUG" && /* @__PURE__ */ jsxs5("div", { style: { marginTop: "10px" }, children: [
8499
- /* @__PURE__ */ jsxs5(
8500
- "span",
8501
- {
8502
- style: {
8503
- fontSize: "12px",
8504
- color: t.textMuted,
8505
- marginBottom: "6px",
8506
- display: "flex",
8507
- alignItems: "center",
8508
- gap: "6px"
8509
- },
8510
- children: [
8511
- "How bad is it?",
8512
- /* @__PURE__ */ jsx5(
8513
- "span",
8514
- {
8515
- style: {
8516
- color: severity ? t.textMuted : needsSeverity ? "#ef4444" : t.textMuted,
8517
- fontSize: "11px"
8518
- },
8519
- children: severity ? "" : "\xB7 required"
8520
- }
8521
- )
8522
- ]
8523
- }
8524
- ),
8525
- /* @__PURE__ */ jsx5(
8526
- "div",
8527
- {
8528
- role: "radiogroup",
8529
- "aria-label": "Severity",
8530
- style: { display: "flex", gap: "6px" },
8531
- children: SEVERITY_LEVELS.map((s) => {
8532
- const on = severity === s;
8533
- return /* @__PURE__ */ jsx5(
8534
- "button",
8535
- {
8536
- type: "button",
8537
- role: "radio",
8538
- "aria-checked": on,
8539
- onClick: () => {
8540
- setSeverity(s);
8541
- if (validationError)
8542
- setValidationError(null);
8543
- },
8544
- style: {
8545
- flex: 1,
8546
- minWidth: 0,
8547
- // 9px + 12px line + borders clears a 36px
8548
- // tap target; 6px left it at ~29px.
8549
- padding: "9px 2px",
8550
- borderRadius: "6px",
8551
- border: `1px solid ${on ? t.accent : needsSeverity ? "#ef4444" : t.inputBorder}`,
8552
- background: on ? t.accent : "transparent",
8553
- color: on ? t.accentText : t.text,
8554
- fontSize: "12px",
8555
- fontWeight: 600,
8556
- cursor: "pointer",
8557
- fontFamily: "inherit",
8558
- whiteSpace: "nowrap",
8559
- // Four labels where there were three: clip
8560
- // rather than spill if a host squeezes the
8561
- // dialog below ~260px.
8562
- overflow: "hidden",
8563
- textOverflow: "ellipsis",
8564
- transition: "all 0.15s ease"
8565
- },
8566
- children: SEVERITY_LABELS[s]
8567
- },
8568
- s
8569
- );
8570
- })
8571
- }
8572
- )
8573
- ] }),
8574
8382
  validationError && /* @__PURE__ */ jsx5(
8575
8383
  "p",
8576
8384
  {
@@ -8921,14 +8729,6 @@ function ReportDialog({
8921
8729
  },
8922
8730
  issueTitle,
8923
8731
  onIssueTitleChange: setIssueTitle,
8924
- severity,
8925
- onSeverityChange: (value) => {
8926
- setSeverity(value);
8927
- if (validationError) setValidationError(null);
8928
- },
8929
- showSeverity,
8930
- validationError,
8931
- severityRefused: needsSeverity,
8932
8732
  isSubmitting,
8933
8733
  submitted,
8934
8734
  onSend: () => void handleSubmit(),
@@ -10761,6 +10561,174 @@ function describeRejection(reason) {
10761
10561
  }
10762
10562
  }
10763
10563
 
10564
+ // src/auto-signals.ts
10565
+ var DEFAULT_CAPTURE_CONSOLE = ["error", "warn"];
10566
+ var DEFAULT_SLOW_REQUEST_MS = 1e4;
10567
+ var CONSOLE_MESSAGE_MAX = 500;
10568
+ var ERROR_ARG_DELAY_MS = 1e3;
10569
+ var CONSOLE_NOISE = [
10570
+ /^\[glitchgrab\]/i,
10571
+ /ResizeObserver loop/i,
10572
+ /\b(?:chrome|safari|moz)-extension:\/\//,
10573
+ /Download the React DevTools/i
10574
+ ];
10575
+ var filing = false;
10576
+ var MAX_SIGNALS_PER_PAGE = 10;
10577
+ var sentThisPage = 0;
10578
+ function firstError(args) {
10579
+ return args.find((a) => a instanceof Error);
10580
+ }
10581
+ function routeOf(url) {
10582
+ var _a;
10583
+ try {
10584
+ const base = typeof window !== "undefined" ? window.location.href : "http://localhost";
10585
+ const { pathname } = new URL(url, base);
10586
+ return pathname.split("/").map(
10587
+ (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
10588
+ ).join("/") || "/";
10589
+ } catch (e) {
10590
+ return (_a = url.split("?")[0]) != null ? _a : url;
10591
+ }
10592
+ }
10593
+ function send(payload, baseUrl) {
10594
+ const cfg = getCaptureConfig();
10595
+ if (sentThisPage >= MAX_SIGNALS_PER_PAGE) return;
10596
+ sentThisPage += 1;
10597
+ filing = true;
10598
+ try {
10599
+ void sendReport(payload, baseUrl).then((result) => {
10600
+ if (result && (cfg == null ? void 0 : cfg.onReportSent)) cfg.onReportSent(result);
10601
+ });
10602
+ } finally {
10603
+ filing = false;
10604
+ }
10605
+ }
10606
+ function fileConsole(level, args) {
10607
+ var _a;
10608
+ try {
10609
+ const cfg = getCaptureConfig();
10610
+ if (!(cfg == null ? void 0 : cfg.token)) return;
10611
+ const err = firstError(args);
10612
+ if (err && wasErrorReported(err)) return;
10613
+ const text = redactString(
10614
+ (err && args.length === 1 ? err.message : argsToString(args)).slice(0, CONSOLE_MESSAGE_MAX)
10615
+ );
10616
+ if (!text.trim()) return;
10617
+ if (CONSOLE_NOISE.some((re) => re.test(text))) return;
10618
+ if (matchesIgnorePatterns(text, cfg.ignoreErrors)) return;
10619
+ const errorMessage = `console.${level}: ${text}`;
10620
+ const errorStack = (err == null ? void 0 : err.stack) ? redactString(err.stack) : void 0;
10621
+ const context = captureContext(cfg.getVisitedPages());
10622
+ const sig = computeSignature({ errorMessage, pageUrl: context.url, errorStack });
10623
+ if (shouldSkipDuplicate(sig)) return;
10624
+ send(
10625
+ {
10626
+ token: cfg.token,
10627
+ source: "SDK_AUTO",
10628
+ type: "BUG",
10629
+ errorMessage,
10630
+ errorStack,
10631
+ pageUrl: context.url,
10632
+ userAgent: context.userAgent,
10633
+ breadcrumbs: context.breadcrumbs,
10634
+ deviceInfo: (_a = context.deviceInfo) != null ? _a : void 0,
10635
+ metadata: {
10636
+ timestamp: context.timestamp,
10637
+ visitedPages: JSON.stringify(context.visitedPages),
10638
+ capturedBy: `console.${level}`,
10639
+ autoKind: "console",
10640
+ consoleLevel: level,
10641
+ ...contextMetadata(context),
10642
+ ...originMetadata(err == null ? void 0 : err.stack),
10643
+ ...sessionMetadata2(cfg.session)
10644
+ }
10645
+ },
10646
+ cfg.baseUrl
10647
+ );
10648
+ } catch (e) {
10649
+ }
10650
+ }
10651
+ function fileSlowRequest(request, thresholdMs) {
10652
+ var _a, _b;
10653
+ try {
10654
+ const cfg = getCaptureConfig();
10655
+ if (!(cfg == null ? void 0 : cfg.token)) return;
10656
+ if (request.durationMs < thresholdMs) return;
10657
+ if (!isOwnOrigin(request.url)) return;
10658
+ const own = (_a = cfg.baseUrl) != null ? _a : DEFAULT_BASE_URL;
10659
+ if (request.url.startsWith(own) || request.url.includes("/api/v1/sdk/")) return;
10660
+ const method = request.method.toUpperCase();
10661
+ const route = routeOf(request.url);
10662
+ const errorMessage = `Slow request: ${method} ${route}`;
10663
+ if (matchesIgnorePatterns(errorMessage, cfg.ignoreErrors)) return;
10664
+ const context = captureContext(cfg.getVisitedPages());
10665
+ const sig = computeSignature({ errorMessage, pageUrl: context.url });
10666
+ if (shouldSkipDuplicate(sig)) return;
10667
+ const seconds = (request.durationMs / 1e3).toFixed(1);
10668
+ send(
10669
+ {
10670
+ token: cfg.token,
10671
+ source: "SDK_AUTO",
10672
+ type: "PERFORMANCE",
10673
+ errorMessage,
10674
+ description: `${method} ${route} took ${seconds}s (threshold ${(thresholdMs / 1e3).toFixed(1)}s)${request.status ? `, answered ${request.status}` : ", never completed"}.`,
10675
+ pageUrl: context.url,
10676
+ userAgent: context.userAgent,
10677
+ breadcrumbs: context.breadcrumbs,
10678
+ deviceInfo: (_b = context.deviceInfo) != null ? _b : void 0,
10679
+ metadata: {
10680
+ timestamp: context.timestamp,
10681
+ visitedPages: JSON.stringify(context.visitedPages),
10682
+ capturedBy: "slowRequestMs",
10683
+ autoKind: "slow-request",
10684
+ requestMethod: method,
10685
+ requestRoute: route,
10686
+ durationMs: String(request.durationMs),
10687
+ thresholdMs: String(thresholdMs),
10688
+ ...request.status ? { status: String(request.status) } : {},
10689
+ ...contextMetadata(context),
10690
+ ...sessionMetadata2(cfg.session)
10691
+ }
10692
+ },
10693
+ cfg.baseUrl
10694
+ );
10695
+ } catch (e) {
10696
+ }
10697
+ }
10698
+ function sessionMetadata2(session) {
10699
+ return {
10700
+ ...(session == null ? void 0 : session.userId) ? { sessionUserId: session.userId } : {},
10701
+ ...(session == null ? void 0 : session.name) ? { sessionUserName: String(session.name) } : {},
10702
+ ...(session == null ? void 0 : session.email) ? { sessionUserEmail: String(session.email) } : {},
10703
+ ...(session == null ? void 0 : session.phone) ? { sessionUserPhone: String(session.phone) } : {}
10704
+ };
10705
+ }
10706
+ function installAutoSignals(options) {
10707
+ var _a;
10708
+ try {
10709
+ const levels = new Set((_a = options.captureConsole) != null ? _a : []);
10710
+ const slowMs = options.slowRequestMs && options.slowRequestMs > 0 ? options.slowRequestMs : 0;
10711
+ setConsoleObserver(
10712
+ levels.size ? (level, args) => {
10713
+ if (filing || !levels.has(level)) return;
10714
+ if (firstError(args)) {
10715
+ setTimeout(() => fileConsole(level, args), ERROR_ARG_DELAY_MS);
10716
+ } else {
10717
+ fileConsole(level, args);
10718
+ }
10719
+ } : null
10720
+ );
10721
+ setRequestObserver(slowMs ? (request) => fileSlowRequest(request, slowMs) : null);
10722
+ return () => {
10723
+ setConsoleObserver(null);
10724
+ setRequestObserver(null);
10725
+ };
10726
+ } catch (e) {
10727
+ return () => {
10728
+ };
10729
+ }
10730
+ }
10731
+
10764
10732
  // src/shortcut.ts
10765
10733
  var GLITCHGRAB_SHORTCUT2 = "Ctrl+Shift+G";
10766
10734
  var GLITCHGRAB_SHORTCUT_MAC2 = "\u2318\u21E7G";
@@ -10801,11 +10769,12 @@ function GlitchgrabProviderInner({
10801
10769
  children,
10802
10770
  fallback,
10803
10771
  types,
10804
- showSeverity,
10805
10772
  ignoreErrors,
10806
10773
  release: release2,
10807
10774
  context: appContext2,
10808
- responseBodyOrigins: responseBodyOrigins2
10775
+ responseBodyOrigins: responseBodyOrigins2,
10776
+ captureConsole = DEFAULT_CAPTURE_CONSOLE,
10777
+ slowRequestMs = DEFAULT_SLOW_REQUEST_MS
10809
10778
  }) {
10810
10779
  const visitedPagesRef = useRef5([]);
10811
10780
  const sessionKey = sessionProp ? [
@@ -10836,6 +10805,16 @@ function GlitchgrabProviderInner({
10836
10805
  initBreadcrumbs(maxBreadcrumbs2, { responseBodyOrigins: responseBodyOrigins2 });
10837
10806
  }
10838
10807
  }, [enableBreadcrumbs, maxBreadcrumbs2, responseBodyOrigins2 == null ? void 0 : responseBodyOrigins2.join(",")]);
10808
+ const captureConsoleKey = captureConsole ? captureConsole.join(",") : "";
10809
+ useEffect6(() => {
10810
+ if (!enableBreadcrumbs) return;
10811
+ if (process.env.NODE_ENV === "development") return;
10812
+ if (!captureConsoleKey && !slowRequestMs) return;
10813
+ return installAutoSignals({
10814
+ captureConsole: captureConsoleKey ? captureConsoleKey.split(",") : [],
10815
+ slowRequestMs
10816
+ });
10817
+ }, [enableBreadcrumbs, captureConsoleKey, slowRequestMs]);
10839
10818
  useEffect6(() => {
10840
10819
  try {
10841
10820
  if (typeof window === "undefined") return;
@@ -10902,6 +10881,7 @@ function GlitchgrabProviderInner({
10902
10881
  return;
10903
10882
  }
10904
10883
  if (isHandledHydrationError(event.error)) return;
10884
+ markErrorReported(event.error);
10905
10885
  incrementErrorCount();
10906
10886
  const context = captureContext(visitedPagesRef.current);
10907
10887
  const sig = computeSignature({
@@ -10959,6 +10939,7 @@ function GlitchgrabProviderInner({
10959
10939
  }
10960
10940
  if (errStack && EXTENSION_ORIGIN_RE.test(errStack)) return;
10961
10941
  if (isUnactionableRejection(description)) return;
10942
+ markErrorReported(reason);
10962
10943
  incrementErrorCount();
10963
10944
  const context = captureContext(visitedPagesRef.current);
10964
10945
  const sig = computeSignature({
@@ -11362,7 +11343,6 @@ function GlitchgrabProviderInner({
11362
11343
  reportGlitchgrabProblem: glitchgrabReport ? reportGlitchgrabProblem : void 0,
11363
11344
  transcribeAudio: aiBlockedUnsigned ? void 0 : transcribe,
11364
11345
  types,
11365
- showSeverity,
11366
11346
  reporter: reporter2,
11367
11347
  chatHistoryKey: chatHistoryKey("sdk", token, session == null ? void 0 : session.userId),
11368
11348
  headerSlot: projectName ? /* @__PURE__ */ jsxs7("div", { style: { fontSize: 11, color: "#9aa0a6" }, children: [