glitchgrab 1.24.0 → 1.25.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
@@ -2212,7 +2212,8 @@ function GlitchgrabProviderInner({
2212
2212
  children,
2213
2213
  fallback,
2214
2214
  types,
2215
- showSeverity
2215
+ showSeverity,
2216
+ ignoreErrors
2216
2217
  }) {
2217
2218
  const visitedPagesRef = useRef2([]);
2218
2219
  useEffect2(() => {
@@ -2262,6 +2263,12 @@ function GlitchgrabProviderInner({
2262
2263
  if (typeof window === "undefined") return;
2263
2264
  if (process.env.NODE_ENV === "development") return;
2264
2265
  const EXTENSION_ORIGIN_RE = /\b(?:chrome|safari|moz)-extension:\/\//;
2266
+ const matchesIgnore = (message) => {
2267
+ if (!ignoreErrors || ignoreErrors.length === 0) return false;
2268
+ return ignoreErrors.some(
2269
+ (pattern) => pattern instanceof RegExp ? pattern.test(message) : message.includes(pattern)
2270
+ );
2271
+ };
2265
2272
  const handleError = (event) => {
2266
2273
  var _a, _b, _c, _d, _e, _f, _g;
2267
2274
  try {
@@ -2269,6 +2276,9 @@ function GlitchgrabProviderInner({
2269
2276
  if (isOpaqueCrossOrigin) {
2270
2277
  return;
2271
2278
  }
2279
+ if (matchesIgnore(event.message)) {
2280
+ return;
2281
+ }
2272
2282
  if (event.message === "ResizeObserver loop completed with undelivered notifications." || event.message === "ResizeObserver loop limit exceeded") {
2273
2283
  return;
2274
2284
  }
@@ -2320,6 +2330,9 @@ function GlitchgrabProviderInner({
2320
2330
  if (errMsg === "Script error." || errMsg === "Script error") {
2321
2331
  return;
2322
2332
  }
2333
+ if (matchesIgnore(errMsg)) {
2334
+ return;
2335
+ }
2323
2336
  const errStack = reason instanceof Error ? reason.stack : void 0;
2324
2337
  if (errStack && EXTENSION_ORIGIN_RE.test(errStack)) return;
2325
2338
  const sig = computeSignature({
@@ -2363,7 +2376,7 @@ function GlitchgrabProviderInner({
2363
2376
  };
2364
2377
  } catch (e) {
2365
2378
  }
2366
- }, [token, baseUrl, onError, onReportSent, session]);
2379
+ }, [token, baseUrl, onError, onReportSent, session, ignoreErrors]);
2367
2380
  const report = useCallback(
2368
2381
  async (type, description, metadata) => {
2369
2382
  var _a;