miaoda-react-devkit 0.1.1-beta.2 → 0.1.1-beta.20

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.js CHANGED
@@ -4,12 +4,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
 
5
5
  // src/capture/console.ts
6
6
  import { addConsoleInstrumentationHandler } from "@sentry/core";
7
- var DEFAULT_CONSOLE_FILTER_KEYWORDS = [
8
- "Sentry initialized successfully",
9
- "[vite] ",
10
- "Download the React DevTools for a better development experience"
11
- ];
12
- function serializeArg(arg) {
7
+ function formatConsoleArg(arg) {
13
8
  if (typeof arg === "string") return arg;
14
9
  if (arg instanceof Error) return arg.message;
15
10
  try {
@@ -18,9 +13,17 @@ function serializeArg(arg) {
18
13
  return String(arg);
19
14
  }
20
15
  }
16
+ function formatConsoleArgs(args) {
17
+ return args.map(formatConsoleArg).join(" ");
18
+ }
19
+ var DEFAULT_CONSOLE_FILTER_KEYWORDS = [
20
+ "Sentry initialized successfully",
21
+ "[vite] ",
22
+ "Download the React DevTools for a better development experience"
23
+ ];
21
24
  function shouldFilterConsole(args, keywords) {
22
25
  if (keywords.length === 0) return false;
23
- const text = args.map(serializeArg).join(" ");
26
+ const text = formatConsoleArgs(args);
24
27
  return keywords.some((kw) => text.includes(kw));
25
28
  }
26
29
  function shouldFilterConsoleMessage(message, keywords) {
@@ -36,9 +39,20 @@ function createConsoleObserver(keywords, subscribers) {
36
39
  for (const sub of subscribers) sub.onConsole(info);
37
40
  });
38
41
  },
39
- beforeBreadcrumb(breadcrumb, _hint) {
42
+ beforeBreadcrumb(breadcrumb, hint) {
40
43
  if (breadcrumb.category === "console" && breadcrumb.message != null) {
41
44
  if (shouldFilterConsoleMessage(breadcrumb.message, keywords)) return null;
45
+ const h = hint;
46
+ const consoleType = h?.level ?? "log";
47
+ const stacks = (h?.input ?? []).filter((arg) => arg instanceof Error && arg.stack != null).map((err) => err.stack);
48
+ const originalMessage = breadcrumb.message;
49
+ breadcrumb.message = `[${consoleType}]${originalMessage}`;
50
+ breadcrumb.data = {
51
+ ...breadcrumb.data ?? {},
52
+ consoleType,
53
+ message: originalMessage,
54
+ ...stacks.length > 0 ? { stack: stacks.join("\n\n") } : {}
55
+ };
42
56
  }
43
57
  return breadcrumb;
44
58
  }
@@ -46,7 +60,7 @@ function createConsoleObserver(keywords, subscribers) {
46
60
  }
47
61
 
48
62
  // src/capture/network.ts
49
- import { getClient } from "@sentry/core";
63
+ import { getClient, getIsolationScope } from "@sentry/core";
50
64
 
51
65
  // ../../node_modules/.pnpm/@sentry-internal+browser-utils@9.47.1/node_modules/@sentry-internal/browser-utils/build/esm/debug-build.js
52
66
  var DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
@@ -84,9 +98,42 @@ function getFetchRequestArgBody(fetchArgs = []) {
84
98
  return fetchArgs[1].body;
85
99
  }
86
100
 
101
+ // src/utils.ts
102
+ function stripUrlOrigin(url) {
103
+ try {
104
+ const u = new URL(url);
105
+ return u.pathname + u.search + u.hash;
106
+ } catch {
107
+ return url;
108
+ }
109
+ }
110
+
87
111
  // src/capture/pgrest.ts
88
112
  var DEFAULT_PGREST_URL_PATTERNS = [/\/rest\/v1\//];
89
- var DEFAULT_PGREST_WHITELIST_CODES = [];
113
+ var DEFAULT_PGREST_WHITELIST_CODES = [
114
+ "22P02",
115
+ // 无效的文本表示(如类型转换失败)
116
+ "42703",
117
+ // 未定义的列
118
+ "42P01",
119
+ // 未定义的表
120
+ "42501",
121
+ // 权限不足
122
+ "23503",
123
+ // 外键约束失败
124
+ "42P17",
125
+ // 对象已存在
126
+ "22008",
127
+ // 日期时间字段值超出范围
128
+ "23505",
129
+ // 唯一键冲突
130
+ "PGRST116",
131
+ // 期望单行但返回多行
132
+ "PGRST200",
133
+ // 外键关系查找失败
134
+ "PGRST204"
135
+ // 响应中找不到列
136
+ ];
90
137
  function isPgRestRequest(url, patterns) {
91
138
  return patterns.some((p) => (typeof p === "string" ? new RegExp(p) : p).test(url));
92
139
  }
@@ -111,8 +158,64 @@ function parsePgRestErrorBody(body) {
111
158
  };
112
159
  }
113
160
 
161
+ // src/capture/auth.ts
162
+ var DEFAULT_AUTH_URL_PATTERNS = [/\/auth\/v1\//];
163
+ var DEFAULT_AUTH_WHITELIST_CODES = ["unexpected_failure"];
164
+ function isAuthRequest(url, patterns) {
165
+ return patterns.some((p) => (typeof p === "string" ? new RegExp(p) : p).test(url));
166
+ }
167
+ function parseAuthErrorBody(body) {
168
+ if (!body) return null;
169
+ let parsed;
170
+ try {
171
+ parsed = JSON.parse(body);
172
+ } catch {
173
+ return null;
174
+ }
175
+ if (typeof parsed !== "object") return null;
176
+ if (parsed === null) return null;
177
+ const p = parsed;
178
+ if (typeof p["code"] !== "string") return null;
179
+ if (typeof p["message"] !== "string") return null;
180
+ return {
181
+ code: p["code"],
182
+ message: p["message"],
183
+ requestId: typeof p["requestId"] === "string" ? p["requestId"] : null
184
+ };
185
+ }
186
+
187
+ // src/capture/storage.ts
188
+ var DEFAULT_STORAGE_URL_PATTERNS = [/\/storage\/v1\//];
189
+ var DEFAULT_STORAGE_WHITELIST_ERRORS = ["new row violates row-level security policy"];
190
+ function isStorageRequest(url, patterns) {
191
+ return patterns.some((p) => (typeof p === "string" ? new RegExp(p) : p).test(url));
192
+ }
193
+ function parseStorageErrorBody(body) {
194
+ if (!body) return null;
195
+ let parsed;
196
+ try {
197
+ parsed = JSON.parse(body);
198
+ } catch {
199
+ return null;
200
+ }
201
+ if (typeof parsed !== "object" || parsed === null) return null;
202
+ const p = parsed;
203
+ if (typeof p["statusCode"] !== "string") return null;
204
+ if (typeof p["error"] !== "string") return null;
205
+ if (typeof p["message"] !== "string") return null;
206
+ return {
207
+ statusCode: p["statusCode"],
208
+ error: p["error"],
209
+ message: p["message"]
210
+ };
211
+ }
212
+
114
213
  // src/capture/network.ts
115
214
  var BODY_TRUNCATE_LIMIT = 2e3;
215
+ function calcDuration(hint) {
216
+ if (hint?.startTimestamp == null || hint?.endTimestamp == null) return void 0;
217
+ return Math.round(hint.endTimestamp - hint.startTimestamp);
218
+ }
116
219
  var DEFAULT_IGNORE_URLS = [
117
220
  /\.(js|css|png|jpg|jpeg|gif|svg|ico|woff|woff2|ttf|eot|map)(\?.*)?$/,
118
221
  /\.chunk\./,
@@ -162,7 +265,15 @@ function handleXhrBreadcrumb(breadcrumb, hint, handler) {
162
265
  breadcrumb.data["requestBody"] = requestBody;
163
266
  breadcrumb.data["responseBody"] = responseBody;
164
267
  }
165
- void handler({ type: "xhr", method, url, statusCode, requestBody, responseBody, isError });
268
+ const duration = calcDuration(hint);
269
+ const relativeUrl = stripUrlOrigin(url);
270
+ const statusStr = statusCode != null ? String(statusCode) : "failed";
271
+ const durationStr = duration != null ? ` (${duration}ms)` : "";
272
+ breadcrumb.message = `XHR ${method} ${relativeUrl} -> ${statusStr}${durationStr}`;
273
+ if (breadcrumb.data) {
274
+ breadcrumb.data["duration"] = duration;
275
+ }
276
+ void handler({ type: "xhr", method, url, statusCode, requestBody, responseBody, isError, duration });
166
277
  }
167
278
  async function handleFetchBreadcrumb(breadcrumb, hint, handler) {
168
279
  const data = breadcrumb.data;
@@ -172,19 +283,24 @@ async function handleFetchBreadcrumb(breadcrumb, hint, handler) {
172
283
  const isError = hint?.data != null;
173
284
  const response = hint?.response;
174
285
  const cause = hint?.data instanceof Error ? hint.data : void 0;
175
- const fetchArgs = hint?.input;
176
- const reqBody = getFetchRequestArgBody(fetchArgs ?? []);
286
+ const reqBody = getFetchRequestArgBody(hint?.input ?? []);
177
287
  const [rawRequestBody] = getBodyString(reqBody);
178
288
  const requestBody = rawRequestBody != null ? truncateBody(rawRequestBody) : void 0;
289
+ const duration = calcDuration(hint);
290
+ const relativeUrl = stripUrlOrigin(url);
291
+ const statusStr = statusCode != null ? String(statusCode) : "failed";
292
+ const durationStr = duration != null ? ` (${duration}ms)` : "";
293
+ breadcrumb.message = `Fetch ${method} ${relativeUrl} -> ${statusStr}${durationStr}`;
179
294
  if (breadcrumb.data) {
180
295
  breadcrumb.data["requestBody"] = requestBody;
296
+ breadcrumb.data["duration"] = duration;
181
297
  }
182
298
  const contentType = response?.headers?.get("content-type") ?? "";
183
299
  if (isStreamByContentType(contentType)) {
184
300
  if (breadcrumb.data) {
185
301
  breadcrumb.data["responseBody"] = "[streaming response - not captured]";
186
302
  }
187
- await handler({ type: "fetch", method, url, statusCode, requestBody, responseBody: "[streaming response - not captured]", isError, cause });
303
+ await handler({ type: "fetch", method, url, statusCode, requestBody, responseBody: "[streaming response - not captured]", isError, cause, duration });
188
304
  return;
189
305
  }
190
306
  let responseBody;
@@ -204,33 +320,77 @@ async function handleFetchBreadcrumb(breadcrumb, hint, handler) {
204
320
  if (breadcrumb.data) {
205
321
  breadcrumb.data["responseBody"] = responseBody;
206
322
  }
207
- await handler({ type: "fetch", method, url, statusCode, requestBody, responseBody, isError, cause });
323
+ await handler({ type: "fetch", method, url, statusCode, requestBody, responseBody, isError, cause, duration });
208
324
  }
209
325
  function createNetworkObserver(opts, subscribers) {
210
- const shouldIgnore = createUrlMatcher(opts.ignoreUrls);
326
+ const isIgnored = createUrlMatcher(opts.ignoreUrls);
211
327
  const pgRestPatterns = opts.pgRestUrlPatterns ?? DEFAULT_PGREST_URL_PATTERNS;
212
328
  const pgRestWhitelistCodes = opts.pgRestWhitelistCodes ?? DEFAULT_PGREST_WHITELIST_CODES;
213
- function tryDispatchPgRestWhitelistError(requestType, method, url, statusCode, requestBody, responseBody) {
329
+ const precedingBreadcrumbsLimit = opts.precedingBreadcrumbsLimit;
330
+ const authPatterns = opts.authUrlPatterns ?? DEFAULT_AUTH_URL_PATTERNS;
331
+ const authWhitelistCodes = opts.authWhitelistCodes ?? DEFAULT_AUTH_WHITELIST_CODES;
332
+ const storagePatterns = opts.storageUrlPatterns ?? DEFAULT_STORAGE_URL_PATTERNS;
333
+ const storageWhitelistErrors = opts.storageWhitelistErrors ?? DEFAULT_STORAGE_WHITELIST_ERRORS;
334
+ const shouldIgnore = (url) => {
335
+ return isIgnored(url) && !isPgRestRequest(url, pgRestPatterns) && !isAuthRequest(url, authPatterns) && !isStorageRequest(url, storagePatterns);
336
+ };
337
+ function tryDispatchError(requestType, method, url, statusCode, requestBody, responseBody) {
214
338
  if (statusCode == null) return;
215
- if (!isPgRestRequest(url, pgRestPatterns)) return;
216
- const pgRestError = parsePgRestErrorBody(responseBody);
217
- if (!pgRestError) return;
218
- if (pgRestWhitelistCodes.length > 0 && !pgRestWhitelistCodes.includes(pgRestError.code)) return;
219
- const info = {
220
- type: requestType,
221
- method,
222
- url,
223
- statusCode,
224
- pgRestError,
225
- requestBody,
226
- responseBody
227
- };
228
- for (const sub of subscribers) sub.onPgRestWhitelistError(info);
339
+ const errorRequestType = isPgRestRequest(url, pgRestPatterns) ? "pgrest" : isAuthRequest(url, authPatterns) ? "auth" : isStorageRequest(url, storagePatterns) ? "storage" : null;
340
+ if (!errorRequestType) return;
341
+ const allBreadcrumbs = getIsolationScope().getScopeData().breadcrumbs;
342
+ const precedingBreadcrumbs = precedingBreadcrumbsLimit != null ? allBreadcrumbs.slice(-precedingBreadcrumbsLimit) : allBreadcrumbs.slice();
343
+ if (errorRequestType === "pgrest") {
344
+ const pgRestError = parsePgRestErrorBody(responseBody);
345
+ if (!pgRestError) return;
346
+ if (pgRestWhitelistCodes.length > 0 && !pgRestWhitelistCodes.includes(pgRestError.code)) return;
347
+ const info = {
348
+ type: requestType,
349
+ method,
350
+ url,
351
+ statusCode,
352
+ pgRestError,
353
+ requestBody,
354
+ responseBody,
355
+ precedingBreadcrumbs
356
+ };
357
+ for (const sub of subscribers) sub.onPgRestWhitelistError(info);
358
+ } else if (errorRequestType === "auth") {
359
+ const authError = parseAuthErrorBody(responseBody);
360
+ if (!authError) return;
361
+ if (authWhitelistCodes.length > 0 && !authWhitelistCodes.includes(authError.code)) return;
362
+ const info = {
363
+ type: requestType,
364
+ method,
365
+ url,
366
+ statusCode,
367
+ authError,
368
+ requestBody,
369
+ responseBody,
370
+ precedingBreadcrumbs
371
+ };
372
+ for (const sub of subscribers) sub.onAuthWhitelistError(info);
373
+ } else if (errorRequestType === "storage") {
374
+ const storageError = parseStorageErrorBody(responseBody);
375
+ if (!storageError) return;
376
+ if (storageWhitelistErrors.length > 0 && !storageWhitelistErrors.includes(storageError.message)) return;
377
+ const info = {
378
+ type: requestType,
379
+ method,
380
+ url,
381
+ statusCode,
382
+ storageError,
383
+ requestBody,
384
+ responseBody,
385
+ precedingBreadcrumbs
386
+ };
387
+ for (const sub of subscribers) sub.onStorageWhitelistError(info);
388
+ }
229
389
  }
230
390
  function makeHandler(requestType) {
231
391
  return (info) => {
232
392
  for (const sub of subscribers) void sub.onNetworkRequest(info);
233
- tryDispatchPgRestWhitelistError(
393
+ tryDispatchError(
234
394
  requestType,
235
395
  info.method,
236
396
  info.url,
@@ -250,10 +410,11 @@ function createNetworkObserver(opts, subscribers) {
250
410
  const fetchHandler = makeHandler("fetch");
251
411
  client.on("beforeAddBreadcrumb", (breadcrumb, hint) => {
252
412
  const url = breadcrumb.data?.url ?? "";
253
- if (shouldIgnore(url)) return;
254
413
  if (breadcrumb.category === "xhr") {
414
+ if (shouldIgnore(url)) return;
255
415
  handleXhrBreadcrumb(breadcrumb, hint, xhrHandler);
256
416
  } else if (breadcrumb.category === "fetch") {
417
+ if (shouldIgnore(url)) return;
257
418
  void handleFetchBreadcrumb(breadcrumb, hint, fetchHandler);
258
419
  }
259
420
  });
@@ -346,56 +507,10 @@ var PostMessageSubscriber = class {
346
507
  };
347
508
  this.send(msg, "*");
348
509
  }
349
- onNetworkRequest({ method, url, statusCode, requestBody, responseBody, isError, cause }) {
350
- const isClientError = statusCode != null && statusCode >= 400 && statusCode < 500;
351
- if (!isError && !isClientError) return;
352
- const urlPath = extractUrlPath(url);
353
- if (isError) {
354
- const causeDesc = cause != null ? String(cause) : "NetworkError";
355
- const errorMessage = `${method} ${urlPath} failed: ${causeDesc}`;
356
- const msg = {
357
- type: "GLOBAL_ERROR",
358
- message: errorMessage,
359
- error: cause != null ? { name: cause.name, message: cause.message, stack: cause.stack } : null,
360
- errorData: {
361
- name: cause?.name ?? "NetworkError",
362
- message: cause?.message ?? causeDesc,
363
- stack: cause?.stack ?? null,
364
- fileName: url,
365
- lineNumber: 0,
366
- columnNumber: 0,
367
- httpPath: urlPath,
368
- httpStatus: 0,
369
- httpMethod: method,
370
- requestBody: requestBody ?? "",
371
- responseBody: ""
372
- }
373
- };
374
- this.send(msg, "*");
375
- } else {
376
- const errorMessage = `${method} ${urlPath} -> ${statusCode}`;
377
- const msg = {
378
- type: "GLOBAL_ERROR",
379
- message: errorMessage,
380
- error: null,
381
- errorData: {
382
- name: "HTTPClientError",
383
- message: errorMessage,
384
- stack: null,
385
- fileName: url,
386
- lineNumber: 0,
387
- columnNumber: 0,
388
- httpPath: urlPath,
389
- httpStatus: statusCode,
390
- httpMethod: method,
391
- requestBody: requestBody ?? "",
392
- responseBody: responseBody ?? ""
393
- }
394
- };
395
- this.send(msg, "*");
396
- }
510
+ // postMessage 场景不需要上报 network 日志
511
+ onNetworkRequest(_info) {
397
512
  }
398
- onPgRestWhitelistError({ type, method, url, statusCode, pgRestError, requestBody, responseBody }) {
513
+ onPgRestWhitelistError({ type, method, url, statusCode, pgRestError, requestBody, responseBody, precedingBreadcrumbs }) {
399
514
  const urlPath = extractUrlPath(url);
400
515
  const code = pgRestError.code;
401
516
  const errorMessage = `${method} ${urlPath} -> ${statusCode} [PgRest:${code}]`;
@@ -418,7 +533,63 @@ var PostMessageSubscriber = class {
418
533
  pgRestCode: code,
419
534
  pgRestDetails: pgRestError.details ?? void 0,
420
535
  pgRestHint: pgRestError.hint ?? void 0,
421
- requestType: type
536
+ requestType: type,
537
+ precedingBreadcrumbs
538
+ }
539
+ };
540
+ this.send(msg, "*");
541
+ }
542
+ onAuthWhitelistError({ type, method, url, statusCode, authError, requestBody, responseBody, precedingBreadcrumbs }) {
543
+ const urlPath = extractUrlPath(url);
544
+ const code = authError.code;
545
+ const errorMessage = `${method} ${urlPath} -> ${statusCode} [Auth:${code}]`;
546
+ const msg = {
547
+ type: "GLOBAL_ERROR",
548
+ message: errorMessage,
549
+ error: null,
550
+ errorData: {
551
+ name: "AuthWhitelistError",
552
+ message: authError.message,
553
+ stack: null,
554
+ fileName: url,
555
+ lineNumber: 0,
556
+ columnNumber: 0,
557
+ httpPath: urlPath,
558
+ httpStatus: statusCode,
559
+ httpMethod: method,
560
+ requestBody: requestBody ?? "",
561
+ responseBody,
562
+ authCode: code,
563
+ authRequestId: authError.requestId ?? void 0,
564
+ requestType: type,
565
+ precedingBreadcrumbs
566
+ }
567
+ };
568
+ this.send(msg, "*");
569
+ }
570
+ onStorageWhitelistError({ type, method, url, statusCode, storageError, requestBody, responseBody, precedingBreadcrumbs }) {
571
+ const urlPath = extractUrlPath(url);
572
+ const errorMessage = `${method} ${urlPath} -> ${statusCode} [Storage:${storageError.error}]`;
573
+ const msg = {
574
+ type: "GLOBAL_ERROR",
575
+ message: errorMessage,
576
+ error: null,
577
+ errorData: {
578
+ name: "StorageWhitelistError",
579
+ message: storageError.message,
580
+ stack: null,
581
+ fileName: url,
582
+ lineNumber: 0,
583
+ columnNumber: 0,
584
+ httpPath: urlPath,
585
+ httpStatus: statusCode,
586
+ httpMethod: method,
587
+ requestBody: requestBody ?? "",
588
+ responseBody,
589
+ storageError: storageError.error,
590
+ storageStatusCode: storageError.statusCode,
591
+ requestType: type,
592
+ precedingBreadcrumbs
422
593
  }
423
594
  };
424
595
  this.send(msg, "*");
@@ -438,15 +609,95 @@ function createNoopSubscriber() {
438
609
  onNetworkRequest() {
439
610
  },
440
611
  onPgRestWhitelistError() {
612
+ },
613
+ onAuthWhitelistError() {
614
+ },
615
+ onStorageWhitelistError() {
441
616
  }
442
617
  };
443
618
  }
619
+
620
+ // src/subscribers/sentryEventSubscriber.ts
621
+ import { captureEvent } from "@sentry/core";
622
+ function toSentryLevel(consoleLevel) {
623
+ switch (consoleLevel) {
624
+ case "error":
625
+ return "error";
626
+ case "warn":
627
+ return "warning";
628
+ case "debug":
629
+ return "debug";
630
+ case "info":
631
+ return "info";
632
+ default:
633
+ return "log";
634
+ }
635
+ }
636
+ var SentryEventSubscriber = class {
637
+ constructor(opts = {}) {
638
+ __publicField(this, "captureAllNetworkRequests");
639
+ this.captureAllNetworkRequests = opts.captureAllNetworkRequests ?? true;
640
+ }
641
+ onConsole(info) {
642
+ const { level, args } = info;
643
+ const formattedMessage = formatConsoleArgs(args);
644
+ const sentryLevel = toSentryLevel(level);
645
+ captureEvent({
646
+ message: `[${level}]${formattedMessage}`,
647
+ level: sentryLevel,
648
+ // 按 level + 消息内容前 100 字符分组,同一类日志聚合为同一个 Issue
649
+ fingerprint: ["console", level, formattedMessage.slice(0, 100)],
650
+ tags: {
651
+ type: "console"
652
+ },
653
+ extra: { consoleType: level, args }
654
+ });
655
+ }
656
+ // Sentry 已自动捕获 JS 错误,不重复上报
657
+ onError(_info) {
658
+ }
659
+ onNetworkRequest(info) {
660
+ const { type, method, url, statusCode, requestBody, responseBody, isError, duration } = info;
661
+ const shouldCapture = this.captureAllNetworkRequests || isError || statusCode != null && statusCode >= 400;
662
+ if (!shouldCapture) return;
663
+ const urlPath = stripUrlOrigin(url);
664
+ const requestTypeLabel = type === "xhr" ? "XHR" : "Fetch";
665
+ const statusStr = statusCode != null ? String(statusCode) : "failed";
666
+ const durationStr = duration != null ? ` (${duration}ms)` : "";
667
+ const message = `${requestTypeLabel} ${method} ${urlPath} -> ${statusStr}${durationStr}`;
668
+ const level = isError ? "error" : statusCode != null && statusCode >= 400 ? "warning" : "info";
669
+ captureEvent({
670
+ message,
671
+ level,
672
+ // 按 method + url 路径固定分组,同一接口的多次报错聚合为同一个 Issue
673
+ fingerprint: ["network", method, urlPath],
674
+ tags: {
675
+ type: "network"
676
+ },
677
+ extra: { url, method, statusCode, duration, requestBody, responseBody }
678
+ });
679
+ }
680
+ onPgRestWhitelistError(_info) {
681
+ }
682
+ onAuthWhitelistError(_info) {
683
+ }
684
+ onStorageWhitelistError(_info) {
685
+ }
686
+ };
687
+ function createSentryEventSubscriber(opts) {
688
+ return new SentryEventSubscriber(opts);
689
+ }
444
690
  export {
691
+ DEFAULT_AUTH_URL_PATTERNS,
692
+ DEFAULT_AUTH_WHITELIST_CODES,
445
693
  DEFAULT_CONSOLE_FILTER_KEYWORDS,
446
694
  DEFAULT_IGNORE_URLS,
447
695
  DEFAULT_PGREST_URL_PATTERNS,
448
696
  DEFAULT_PGREST_WHITELIST_CODES,
697
+ DEFAULT_STORAGE_URL_PATTERNS,
698
+ DEFAULT_STORAGE_WHITELIST_ERRORS,
449
699
  SentryCapture,
450
700
  createNoopSubscriber,
451
- createPostMessageSubscriber
701
+ createPostMessageSubscriber,
702
+ createSentryEventSubscriber
452
703
  };
@@ -0,0 +1,144 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/stubs/sentry-react-noop-stub.ts
6
+ import { Component, createElement, isValidElement } from "react";
7
+ var INITIAL_ERROR_BOUNDARY_STATE = {
8
+ error: null,
9
+ componentStack: "",
10
+ hasError: false
11
+ };
12
+ var init = (_options) => {
13
+ };
14
+ var configureStubSubscribers = (_subscribers) => {
15
+ };
16
+ var getDefaultIntegrations = (_options) => [];
17
+ var browserTracingIntegration = () => ({});
18
+ var breadcrumbsIntegration = (_options) => ({});
19
+ var httpContextIntegration = (_options) => ({});
20
+ var linkedErrorsIntegration = (_options) => ({});
21
+ var dedupeIntegration = (_options) => ({});
22
+ var captureException = (_err) => "";
23
+ var captureMessage = (_msg) => "";
24
+ var captureEvent = (_event) => "";
25
+ var addBreadcrumb = (_breadcrumb) => {
26
+ };
27
+ var setUser = (_user) => {
28
+ };
29
+ var setTag = (_key, _value) => {
30
+ };
31
+ var setTags = (_tags) => {
32
+ };
33
+ var setContext = (_key, _ctx) => {
34
+ };
35
+ var setExtra = (_key, _value) => {
36
+ };
37
+ var setExtras = (_extras) => {
38
+ };
39
+ var getClient = () => void 0;
40
+ var flush = () => Promise.resolve(true);
41
+ var close = () => Promise.resolve(true);
42
+ var lastEventId = () => void 0;
43
+ var SDK_VERSION = "0.0.0-stub";
44
+ var ErrorBoundary = class extends Component {
45
+ constructor() {
46
+ super(...arguments);
47
+ __publicField(this, "state", INITIAL_ERROR_BOUNDARY_STATE);
48
+ }
49
+ static getDerivedStateFromError(error) {
50
+ return { error, componentStack: "", hasError: true };
51
+ }
52
+ componentDidCatch(error, errorInfo) {
53
+ const componentStack = errorInfo.componentStack ?? "";
54
+ this.setState({ componentStack });
55
+ this.props.onError?.(error, componentStack, "");
56
+ }
57
+ componentDidMount() {
58
+ this.props.onMount?.();
59
+ }
60
+ componentWillUnmount() {
61
+ if (this.state.hasError) {
62
+ this.props.onUnmount?.(this.state.error, this.state.componentStack, "");
63
+ } else {
64
+ this.props.onUnmount?.(null, null, null);
65
+ }
66
+ }
67
+ resetErrorBoundary() {
68
+ if (this.state.hasError) {
69
+ this.props.onReset?.(this.state.error, this.state.componentStack, "");
70
+ }
71
+ this.setState(INITIAL_ERROR_BOUNDARY_STATE);
72
+ }
73
+ render() {
74
+ const { children, fallback } = this.props;
75
+ if (!this.state.hasError) return typeof children === "function" ? children() : children ?? null;
76
+ const fallbackElement = typeof fallback === "function" ? createElement(fallback, {
77
+ error: this.state.error,
78
+ componentStack: this.state.componentStack,
79
+ eventId: "",
80
+ resetError: () => this.resetErrorBoundary()
81
+ }) : fallback;
82
+ return isValidElement(fallbackElement) ? fallbackElement : null;
83
+ }
84
+ };
85
+ var withErrorBoundary = (WrappedComponent, errorBoundaryOptions) => {
86
+ const Wrapped = (props) => createElement(
87
+ ErrorBoundary,
88
+ errorBoundaryOptions,
89
+ createElement(WrappedComponent, props)
90
+ );
91
+ Object.assign(Wrapped, WrappedComponent);
92
+ Wrapped.displayName = `errorBoundary(${WrappedComponent.displayName || WrappedComponent.name || "unknown"})`;
93
+ return Wrapped;
94
+ };
95
+ var withProfiler = (Component2) => Component2;
96
+ var useProfiler = (_name) => {
97
+ };
98
+ var Profiler = ({ children }) => children ?? null;
99
+ var withSentryRouting = (Component2) => Component2;
100
+ var withSentryReactRouterV6Routing = (Component2) => Component2;
101
+ var wrapCreateBrowserRouterV6 = (fn) => fn;
102
+ var wrapCreateBrowserRouterV7 = (fn) => fn;
103
+ var reactRouterV6BrowserTracingIntegration = () => ({});
104
+ var reactRouterV7BrowserTracingIntegration = () => ({});
105
+ var getCurrentScope = () => ({});
106
+ var replayIntegration = (_options) => ({});
107
+ export {
108
+ ErrorBoundary,
109
+ Profiler,
110
+ SDK_VERSION,
111
+ addBreadcrumb,
112
+ breadcrumbsIntegration,
113
+ browserTracingIntegration,
114
+ captureEvent,
115
+ captureException,
116
+ captureMessage,
117
+ close,
118
+ configureStubSubscribers,
119
+ dedupeIntegration,
120
+ flush,
121
+ getClient,
122
+ getCurrentScope,
123
+ getDefaultIntegrations,
124
+ httpContextIntegration,
125
+ init,
126
+ lastEventId,
127
+ linkedErrorsIntegration,
128
+ reactRouterV6BrowserTracingIntegration,
129
+ reactRouterV7BrowserTracingIntegration,
130
+ replayIntegration,
131
+ setContext,
132
+ setExtra,
133
+ setExtras,
134
+ setTag,
135
+ setTags,
136
+ setUser,
137
+ useProfiler,
138
+ withErrorBoundary,
139
+ withProfiler,
140
+ withSentryReactRouterV6Routing,
141
+ withSentryRouting,
142
+ wrapCreateBrowserRouterV6,
143
+ wrapCreateBrowserRouterV7
144
+ };