@seliseblocks/genesis-os 4.4.6 → 4.4.8

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.
Files changed (152) hide show
  1. package/dist/{all-OJ5YSNAN.js → all-O45OXFJ7.js} +80 -80
  2. package/dist/{all-OJ5YSNAN.js.map → all-O45OXFJ7.js.map} +1 -1
  3. package/dist/{all-2UHIE3HU.cjs → all-UJTAKIGL.cjs} +80 -80
  4. package/dist/all-UJTAKIGL.cjs.map +1 -0
  5. package/dist/aspnet-4V2TYHQE.cjs +13 -0
  6. package/dist/{aspnet-7QL7EKM4.cjs.map → aspnet-4V2TYHQE.cjs.map} +1 -1
  7. package/dist/aspnet-R3X2H2AO.js +7 -0
  8. package/dist/{aspnet-I623QV26.js.map → aspnet-R3X2H2AO.js.map} +1 -1
  9. package/dist/chunk-2MP66EX3.cjs +16 -0
  10. package/dist/chunk-2MP66EX3.cjs.map +1 -0
  11. package/dist/chunk-3LBTW4A3.cjs +70 -0
  12. package/dist/chunk-3LBTW4A3.cjs.map +1 -0
  13. package/dist/{chunk-ZR6LRRN6.js → chunk-3OO2YVXW.js} +13 -7
  14. package/dist/chunk-3OO2YVXW.js.map +1 -0
  15. package/dist/chunk-3V7O45KN.js +86 -0
  16. package/dist/chunk-3V7O45KN.js.map +1 -0
  17. package/dist/{chunk-5L6BSYZR.cjs → chunk-45XWYZ67.cjs} +3 -3
  18. package/dist/{chunk-5L6BSYZR.cjs.map → chunk-45XWYZ67.cjs.map} +1 -1
  19. package/dist/{chunk-356ZGDMJ.cjs → chunk-5IOXQBUO.cjs} +3 -3
  20. package/dist/{chunk-356ZGDMJ.cjs.map → chunk-5IOXQBUO.cjs.map} +1 -1
  21. package/dist/chunk-6QSPMPJD.js +3 -0
  22. package/dist/chunk-6QSPMPJD.js.map +1 -0
  23. package/dist/chunk-7ZZ3KLZD.js +14 -0
  24. package/dist/chunk-7ZZ3KLZD.js.map +1 -0
  25. package/dist/{chunk-JQ4U53QV.cjs → chunk-A373J4BR.cjs} +82 -82
  26. package/dist/{chunk-JQ4U53QV.cjs.map → chunk-A373J4BR.cjs.map} +1 -1
  27. package/dist/{chunk-QTSTAWK3.cjs → chunk-AIUUCMAI.cjs} +8 -7
  28. package/dist/chunk-AIUUCMAI.cjs.map +1 -0
  29. package/dist/{chunk-IJMKS4XG.cjs → chunk-CTIGX76P.cjs} +15 -8
  30. package/dist/chunk-CTIGX76P.cjs.map +1 -0
  31. package/dist/{chunk-XRAO7JBH.js → chunk-ECDNFX6H.js} +11 -4
  32. package/dist/chunk-ECDNFX6H.js.map +1 -0
  33. package/dist/{chunk-WL6LTNZN.js → chunk-G24RPSJG.js} +79 -79
  34. package/dist/{chunk-WL6LTNZN.js.map → chunk-G24RPSJG.js.map} +1 -1
  35. package/dist/chunk-GAQGM46C.cjs +4 -0
  36. package/dist/chunk-GAQGM46C.cjs.map +1 -0
  37. package/dist/{chunk-VJAVGV6Z.js → chunk-GFUHF4DC.js} +3 -3
  38. package/dist/{chunk-VJAVGV6Z.js.map → chunk-GFUHF4DC.js.map} +1 -1
  39. package/dist/chunk-GSCW3WIQ.cjs +90 -0
  40. package/dist/chunk-GSCW3WIQ.cjs.map +1 -0
  41. package/dist/{chunk-4CMIWUZW.cjs → chunk-IPMRZNNS.cjs} +25 -24
  42. package/dist/chunk-IPMRZNNS.cjs.map +1 -0
  43. package/dist/{chunk-JITR3QYC.js → chunk-JYA5S4XN.js} +3 -64
  44. package/dist/chunk-JYA5S4XN.js.map +1 -0
  45. package/dist/{chunk-NPMO67H6.js → chunk-KA2OOMCU.js} +743 -544
  46. package/dist/chunk-KA2OOMCU.js.map +1 -0
  47. package/dist/{chunk-R5OAGX3J.js → chunk-ND6E3LWI.js} +3 -3
  48. package/dist/{chunk-R5OAGX3J.js.map → chunk-ND6E3LWI.js.map} +1 -1
  49. package/dist/chunk-OPMWK5SY.cjs +871 -0
  50. package/dist/chunk-OPMWK5SY.cjs.map +1 -0
  51. package/dist/{chunk-JUVLHPQI.js → chunk-POJIHGRY.js} +3 -14
  52. package/dist/chunk-POJIHGRY.js.map +1 -0
  53. package/dist/{chunk-CGVT7IFM.cjs → chunk-QBL4VIE4.cjs} +909 -710
  54. package/dist/chunk-QBL4VIE4.cjs.map +1 -0
  55. package/dist/{chunk-JSXAKNHQ.js → chunk-QHNZOBXR.js} +7 -6
  56. package/dist/chunk-QHNZOBXR.js.map +1 -0
  57. package/dist/{chunk-4QN4CYSC.cjs → chunk-RO55MFZA.cjs} +2 -64
  58. package/dist/chunk-RO55MFZA.cjs.map +1 -0
  59. package/dist/{chunk-VGOVEFEP.cjs → chunk-SAK3QQCD.cjs} +3 -3
  60. package/dist/{chunk-VGOVEFEP.cjs.map → chunk-SAK3QQCD.cjs.map} +1 -1
  61. package/dist/chunk-SQG7DJNY.js +68 -0
  62. package/dist/chunk-SQG7DJNY.js.map +1 -0
  63. package/dist/{chunk-X4YCRWXO.cjs → chunk-TSRDXJUG.cjs} +2 -14
  64. package/dist/chunk-TSRDXJUG.cjs.map +1 -0
  65. package/dist/{chunk-6GCU5LM7.cjs → chunk-U2LA7LBX.cjs} +2 -84
  66. package/dist/chunk-U2LA7LBX.cjs.map +1 -0
  67. package/dist/{chunk-XL7EULGP.js → chunk-U6GTLTLO.js} +3 -3
  68. package/dist/{chunk-XL7EULGP.js.map → chunk-U6GTLTLO.js.map} +1 -1
  69. package/dist/{chunk-O5ACQLWB.js → chunk-UDFH7SJI.js} +5 -4
  70. package/dist/chunk-UDFH7SJI.js.map +1 -0
  71. package/dist/{chunk-IRIDGVV2.cjs → chunk-VLZJP6FH.cjs} +70 -64
  72. package/dist/chunk-VLZJP6FH.cjs.map +1 -0
  73. package/dist/chunk-XYPSBVXL.js +842 -0
  74. package/dist/chunk-XYPSBVXL.js.map +1 -0
  75. package/dist/{chunk-4UHGGHI6.js → chunk-Z4ZDSA2A.js} +3 -82
  76. package/dist/chunk-Z4ZDSA2A.js.map +1 -0
  77. package/dist/components/index.cjs +438 -433
  78. package/dist/components/index.d.cts +5 -1
  79. package/dist/components/index.d.ts +5 -1
  80. package/dist/components/index.js +91 -86
  81. package/dist/cshtml-IPCDTLX7.cjs +13 -0
  82. package/dist/{cshtml-ETL7US3D.cjs.map → cshtml-IPCDTLX7.cjs.map} +1 -1
  83. package/dist/cshtml-XPUEHA6K.js +7 -0
  84. package/dist/{cshtml-TVLCSBKU.js.map → cshtml-XPUEHA6K.js.map} +1 -1
  85. package/dist/eslint/index.cjs +33 -0
  86. package/dist/eslint/index.cjs.map +1 -0
  87. package/dist/eslint/index.d.cts +12 -0
  88. package/dist/eslint/index.d.ts +12 -0
  89. package/dist/eslint/index.js +28 -0
  90. package/dist/eslint/index.js.map +1 -0
  91. package/dist/guards/index.cjs +97 -92
  92. package/dist/guards/index.js +91 -86
  93. package/dist/hooks/index.cjs +65 -62
  94. package/dist/hooks/index.d.cts +1 -1
  95. package/dist/hooks/index.d.ts +1 -1
  96. package/dist/hooks/index.js +8 -5
  97. package/dist/i18n/index.cjs +125 -0
  98. package/dist/i18n/index.cjs.map +1 -0
  99. package/dist/i18n/index.d.cts +137 -0
  100. package/dist/i18n/index.d.ts +137 -0
  101. package/dist/i18n/index.js +8 -0
  102. package/dist/i18n/index.js.map +1 -0
  103. package/dist/index.cjs +747 -630
  104. package/dist/index.d.cts +1 -0
  105. package/dist/index.d.ts +1 -0
  106. package/dist/index.js +91 -86
  107. package/dist/layouts/index.cjs +98 -93
  108. package/dist/layouts/index.js +91 -86
  109. package/dist/lib/index.cjs +38 -36
  110. package/dist/lib/index.js +5 -3
  111. package/dist/observability/index.cjs +102 -25
  112. package/dist/observability/index.cjs.map +1 -1
  113. package/dist/observability/index.d.cts +47 -5
  114. package/dist/observability/index.d.ts +47 -5
  115. package/dist/observability/index.js +98 -23
  116. package/dist/observability/index.js.map +1 -1
  117. package/dist/pages/index.cjs +96 -91
  118. package/dist/pages/index.js +91 -86
  119. package/dist/providers/index.cjs +11 -7
  120. package/dist/providers/index.js +7 -3
  121. package/dist/store/index.cjs +15 -13
  122. package/dist/store/index.js +4 -2
  123. package/dist/{tsx-PN3P5NJP.cjs → tsx-MALMUEWS.cjs} +5 -5
  124. package/dist/tsx-MALMUEWS.cjs.map +1 -0
  125. package/dist/{tsx-UJQQBLY4.js → tsx-MJR7GSNC.js} +4 -4
  126. package/dist/tsx-MJR7GSNC.js.map +1 -0
  127. package/dist/utils/index.cjs +77 -72
  128. package/dist/utils/index.js +9 -4
  129. package/package.json +11 -1
  130. package/dist/all-2UHIE3HU.cjs.map +0 -1
  131. package/dist/aspnet-7QL7EKM4.cjs +0 -13
  132. package/dist/aspnet-I623QV26.js +0 -7
  133. package/dist/chunk-4CMIWUZW.cjs.map +0 -1
  134. package/dist/chunk-4QN4CYSC.cjs.map +0 -1
  135. package/dist/chunk-4UHGGHI6.js.map +0 -1
  136. package/dist/chunk-6GCU5LM7.cjs.map +0 -1
  137. package/dist/chunk-CGVT7IFM.cjs.map +0 -1
  138. package/dist/chunk-IJMKS4XG.cjs.map +0 -1
  139. package/dist/chunk-IRIDGVV2.cjs.map +0 -1
  140. package/dist/chunk-JITR3QYC.js.map +0 -1
  141. package/dist/chunk-JSXAKNHQ.js.map +0 -1
  142. package/dist/chunk-JUVLHPQI.js.map +0 -1
  143. package/dist/chunk-NPMO67H6.js.map +0 -1
  144. package/dist/chunk-O5ACQLWB.js.map +0 -1
  145. package/dist/chunk-QTSTAWK3.cjs.map +0 -1
  146. package/dist/chunk-X4YCRWXO.cjs.map +0 -1
  147. package/dist/chunk-XRAO7JBH.js.map +0 -1
  148. package/dist/chunk-ZR6LRRN6.js.map +0 -1
  149. package/dist/cshtml-ETL7US3D.cjs +0 -13
  150. package/dist/cshtml-TVLCSBKU.js +0 -7
  151. package/dist/tsx-PN3P5NJP.cjs.map +0 -1
  152. package/dist/tsx-UJQQBLY4.js.map +0 -1
@@ -1,7 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkX4YCRWXO_cjs = require('../chunk-X4YCRWXO.cjs');
3
+ var chunk2MP66EX3_cjs = require('../chunk-2MP66EX3.cjs');
4
+ var chunkOPMWK5SY_cjs = require('../chunk-OPMWK5SY.cjs');
4
5
  var chunkF2LXD7RI_cjs = require('../chunk-F2LXD7RI.cjs');
6
+ var chunkTSRDXJUG_cjs = require('../chunk-TSRDXJUG.cjs');
7
+ require('../chunk-3LBTW4A3.cjs');
8
+ require('../chunk-GSCW3WIQ.cjs');
5
9
  require('../chunk-QJOVCH5A.cjs');
6
10
  var Rollbar2 = require('rollbar');
7
11
  var react$1 = require('@rollbar/react');
@@ -12,6 +16,67 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
16
 
13
17
  var Rollbar2__default = /*#__PURE__*/_interopDefault(Rollbar2);
14
18
 
19
+ // src/observability/noise-filter.ts
20
+ var NETWORK_MESSAGES = [
21
+ "NetworkError when attempting to fetch resource.",
22
+ "Load failed"
23
+ ];
24
+ var VIEW_TRANSITION_CLASSES = [
25
+ "InvalidStateError",
26
+ "TimeoutError",
27
+ "AbortError"
28
+ ];
29
+ var EXTENSION_URL_PREFIXES = [
30
+ "chrome-extension://",
31
+ "moz-extension://",
32
+ "safari-extension://",
33
+ "safari-web-extension://"
34
+ ];
35
+ var EVENT_MESSAGES = [
36
+ "[object Event]",
37
+ "[object ErrorEvent]",
38
+ '{"isTrusted":true}'
39
+ ];
40
+ var asString = (value) => typeof value === "string" ? value : void 0;
41
+ var isPlainObject = (value) => {
42
+ if (typeof value !== "object" || value === null) return false;
43
+ const prototype = Object.getPrototypeOf(value);
44
+ return prototype === Object.prototype || prototype === null;
45
+ };
46
+ var isEvent = (value) => typeof Event !== "undefined" && value instanceof Event;
47
+ var isExtensionFrame = (frame) => {
48
+ const filename = frame?.filename;
49
+ return typeof filename === "string" && EXTENSION_URL_PREFIXES.some((prefix) => filename.startsWith(prefix));
50
+ };
51
+ var classify = (value, payload) => {
52
+ const body = payload?.body;
53
+ const trace = body?.trace ?? body?.trace_chain?.[0];
54
+ const raw = typeof value === "object" && value !== null ? value : void 0;
55
+ const errorClass = asString(raw?.name) ?? asString(trace?.exception?.class) ?? "";
56
+ const message = asString(raw?.message) ?? asString(trace?.exception?.message) ?? asString(body?.message?.body) ?? "";
57
+ const frames = trace?.frames ?? [];
58
+ if (errorClass === "TypeError" && (message.startsWith("Failed to fetch") || NETWORK_MESSAGES.includes(message)) || errorClass === "AbortError")
59
+ return "network";
60
+ if (VIEW_TRANSITION_CLASSES.includes(errorClass) && message.toLowerCase().includes("transition"))
61
+ return "view-transition";
62
+ if (frames.length > 0 && frames.every(isExtensionFrame)) return "extension";
63
+ if (errorClass === "Canceled" && message === "Canceled" || isPlainObject(value) && value.type === "cancelation")
64
+ return "cancelation";
65
+ if (message.startsWith(
66
+ "Failed to execute 'importScripts' on 'WorkerGlobalScope'"
67
+ ) || message === "Object.hasOwn is not a function" || isEvent(value) || EVENT_MESSAGES.includes(message))
68
+ return "stale-asset";
69
+ if (message.startsWith("reCAPTCHA Timeout")) return "recaptcha-timeout";
70
+ return null;
71
+ };
72
+ var classifyReportingNoise = (value, payload) => {
73
+ try {
74
+ return classify(value, payload);
75
+ } catch {
76
+ return null;
77
+ }
78
+ };
79
+ var isNetworkFailure = (error) => classifyReportingNoise(error) === "network";
15
80
  var DEFAULT_SCRUB_FIELDS = [
16
81
  "x-blocks-key",
17
82
  "X-Blocks-Key",
@@ -33,15 +98,19 @@ var DEFAULT_IGNORED_MESSAGES = [
33
98
  "Script error."
34
99
  ];
35
100
  var UNCONFIGURED_ACCESS_TOKEN = "rollbar-reporting-disabled";
101
+ var ignoreNoise = (isUncaught, args, payload) => classifyReportingNoise(
102
+ isUncaught ? args?.[1] ?? args?.[0] : args?.[0],
103
+ payload
104
+ ) !== null;
36
105
  var createRollbarConfig = (options) => {
37
- const accessToken = chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_ROLLBAR_CLIENT_TOKEN");
106
+ const accessToken = chunkTSRDXJUG_cjs.getRuntimeEnv("BLOCKS_ROLLBAR_CLIENT_TOKEN");
38
107
  return {
39
108
  accessToken: accessToken || UNCONFIGURED_ACCESS_TOKEN,
40
109
  // Reporting is opt-in on a seeded token. Unconfigured environments -- developer machines,
41
110
  // tests, any tier not yet seeded -- get an inert client rather than a broken one, so the error
42
111
  // boundary still behaves exactly as it does in production.
43
112
  enabled: accessToken.length > 0,
44
- environment: chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_ROLLBAR_ENV") || "unknown",
113
+ environment: chunkTSRDXJUG_cjs.getRuntimeEnv("BLOCKS_ROLLBAR_ENV") || "unknown",
45
114
  captureUncaught: true,
46
115
  captureUnhandledRejections: true,
47
116
  scrubFields: [...DEFAULT_SCRUB_FIELDS, ...options.extraScrubFields ?? []],
@@ -49,6 +118,7 @@ var createRollbarConfig = (options) => {
49
118
  ...DEFAULT_IGNORED_MESSAGES,
50
119
  ...options.extraIgnoredMessages ?? []
51
120
  ],
121
+ checkIgnore: ignoreNoise,
52
122
  payload: {
53
123
  // Under `custom`, not at the root of `data`. Rollbar recognises a fixed set of top-level
54
124
  // fields and gives unknown ones "no special handling" -- they are stored but not indexed as
@@ -77,8 +147,9 @@ var getRollbar = (options) => instance ??= new Rollbar2__default.default(createR
77
147
  // src/observability/report-query-errors.ts
78
148
  var attachQueryErrorReporting = (queryClient, rollbar) => {
79
149
  const report = (error, context) => {
80
- if (error instanceof chunkX4YCRWXO_cjs.HttpError) return;
150
+ if (error instanceof chunk2MP66EX3_cjs.HttpError) return;
81
151
  if (typeof error?.status === "number") return;
152
+ if (isNetworkFailure(error)) return;
82
153
  rollbar.error(error instanceof Error ? error : new Error(String(error)), {
83
154
  source: "react-query",
84
155
  ...context
@@ -103,27 +174,30 @@ var attachQueryErrorReporting = (queryClient, rollbar) => {
103
174
  unsubscribeMutations();
104
175
  };
105
176
  };
106
- var DefaultFallback = ({ resetError }) => /* @__PURE__ */ jsxRuntime.jsxs(
107
- "div",
108
- {
109
- className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
110
- role: "alert",
111
- children: [
112
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
113
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-semibold text-foreground", children: "Something went wrong" }),
114
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-medium-emphasis", children: "The error has been reported. Try again, or reload the page if it keeps happening." })
115
- ] }),
116
- /* @__PURE__ */ jsxRuntime.jsx(
117
- "button",
118
- {
119
- onClick: resetError,
120
- className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
121
- children: "Try again"
122
- }
123
- )
124
- ]
125
- }
126
- );
177
+ var DefaultFallback = ({ resetError }) => {
178
+ const { t } = chunkOPMWK5SY_cjs.useT("genesis.shared");
179
+ return /* @__PURE__ */ jsxRuntime.jsxs(
180
+ "div",
181
+ {
182
+ className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
183
+ role: "alert",
184
+ children: [
185
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
186
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-semibold text-foreground", children: t("ROLLBAR_FALLBACK.TITLE") }),
187
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-medium-emphasis", children: t("ROLLBAR_FALLBACK.MESSAGE") })
188
+ ] }),
189
+ /* @__PURE__ */ jsxRuntime.jsx(
190
+ "button",
191
+ {
192
+ onClick: resetError,
193
+ className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
194
+ children: t("ROLLBAR_FALLBACK.TRY_AGAIN")
195
+ }
196
+ )
197
+ ]
198
+ }
199
+ );
200
+ };
127
201
  var RollbarProvider = ({
128
202
  children,
129
203
  fallback = DefaultFallback,
@@ -144,6 +218,7 @@ var RollbarProvider = ({
144
218
  // src/observability/report-http-errors.ts
145
219
  var createHttpFailureReporter = (rollbar) => (failure) => {
146
220
  if (!failure.transport) return;
221
+ if (isNetworkFailure(failure.error)) return;
147
222
  const error = failure.error instanceof Error ? failure.error : new Error(String(failure.error));
148
223
  rollbar.error(error, {
149
224
  source: "http-client",
@@ -155,8 +230,10 @@ var createHttpFailureReporter = (rollbar) => (failure) => {
155
230
  exports.RollbarProvider = RollbarProvider;
156
231
  exports.UNCONFIGURED_ACCESS_TOKEN = UNCONFIGURED_ACCESS_TOKEN;
157
232
  exports.attachQueryErrorReporting = attachQueryErrorReporting;
233
+ exports.classifyReportingNoise = classifyReportingNoise;
158
234
  exports.createHttpFailureReporter = createHttpFailureReporter;
159
235
  exports.createRollbarConfig = createRollbarConfig;
160
236
  exports.getRollbar = getRollbar;
237
+ exports.isNetworkFailure = isNetworkFailure;
161
238
  //# sourceMappingURL=index.cjs.map
162
239
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/observability/rollbar.config.ts","../../src/observability/rollbar.instance.ts","../../src/observability/report-query-errors.ts","../../src/observability/rollbar.provider.tsx","../../src/observability/report-http-errors.ts"],"names":["getRuntimeEnv","Rollbar","HttpError","jsxs","jsx","useMemo","useEffect","getQueryClient","Provider","ErrorBoundary"],"mappings":";;;;;;;;;;;;;;AAUA,IAAM,oBAAA,GAAuB;AAAA,EAC3B,cAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,eAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,aAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA;AAMA,IAAM,wBAAA,GAA2B;AAAA,EAC/B,oCAAA;AAAA,EACA,8DAAA;AAAA,EACA;AACF,CAAA;AAaO,IAAM,yBAAA,GAA4B;AAsBlC,IAAM,mBAAA,GAAsB,CACjC,OAAA,KAC0B;AAC1B,EAAA,MAAM,WAAA,GAAcA,gCAAc,6BAA6B,CAAA;AAE/D,EAAA,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AA;AAAA,IACb,QAAQ,OAAA,CAAQ;AAAA,GACjB,CAAA;AACH","file":"index.cjs","sourcesContent":["import Rollbar from \"rollbar\";\nimport { getRuntimeEnv } from \"@/lib/runtime-env\";\n\n/**\n * Payload keys and header names that must never leave the browser.\n *\n * Rollbar scrubs a default set already; these are the platform-specific ones. Getting this wrong\n * ships a tenant's credentials to a third party, which is why it lives here rather than being\n * restated in every app.\n */\nconst DEFAULT_SCRUB_FIELDS = [\n \"x-blocks-key\",\n \"X-Blocks-Key\",\n \"Authorization\",\n \"authorization\",\n \"access_token\",\n \"refresh_token\",\n \"accessToken\",\n \"refreshToken\",\n \"password\",\n \"clientSecret\",\n \"client_secret\",\n \"connectionString\",\n \"secretValue\",\n];\n\n/**\n * Noise that reaches `window.onerror` but says nothing about the app: browser extensions,\n * cross-origin frames, and the ResizeObserver warning Chrome raises during ordinary layout.\n */\nconst DEFAULT_IGNORED_MESSAGES = [\n \"ResizeObserver loop limit exceeded\",\n \"ResizeObserver loop completed with undelivered notifications\",\n \"Script error.\",\n];\n\n/**\n * Stands in for a real token when none is seeded.\n *\n * `@rollbar/react`'s `Provider` rejects an instance whose `options.accessToken` is falsy -- it\n * throws \"`instance` must be a configured instance of Rollbar\" from its own constructor, which is\n * above the error boundary, so an unconfigured app renders nothing at all. Reporting is switched\n * off by `enabled`, not by the token: the notifier refuses to send before it reaches a transport\n * and telemetry instrumentation is never installed. A placeholder therefore costs nothing and\n * keeps reporting genuinely optional, which is the point -- no tier should go blank because a\n * secret has not been seeded yet.\n */\nexport const UNCONFIGURED_ACCESS_TOKEN = \"rollbar-reporting-disabled\";\n\nexport interface RollbarConfigOptions {\n /**\n * The app reporting, e.g. `\"blocks-os\"`. Pass the same name the app already gives\n * `BlocksAppLayout`, so items can be traced back to a service without a project-id lookup.\n */\n service: string;\n /** Appended to, not replacing, the platform scrub list. */\n extraScrubFields?: string[];\n /** Appended to, not replacing, the default ignore list. */\n extraIgnoredMessages?: string[];\n /** Identifies the build. Required for source-map deobfuscation once maps are uploaded. */\n codeVersion?: string;\n}\n\n/**\n * Builds the browser Rollbar configuration from runtime env.\n *\n * Separate from the provider so it can be asserted on directly: most of the risk in this module is\n * in the configuration -- scrubbing, and whether reporting is on at all -- not in Rollbar itself.\n */\nexport const createRollbarConfig = (\n options: RollbarConfigOptions,\n): Rollbar.Configuration => {\n const accessToken = getRuntimeEnv(\"BLOCKS_ROLLBAR_CLIENT_TOKEN\");\n\n return {\n accessToken: accessToken || UNCONFIGURED_ACCESS_TOKEN,\n // Reporting is opt-in on a seeded token. Unconfigured environments -- developer machines,\n // tests, any tier not yet seeded -- get an inert client rather than a broken one, so the error\n // boundary still behaves exactly as it does in production.\n enabled: accessToken.length > 0,\n environment: getRuntimeEnv(\"BLOCKS_ROLLBAR_ENV\") || \"unknown\",\n captureUncaught: true,\n captureUnhandledRejections: true,\n scrubFields: [...DEFAULT_SCRUB_FIELDS, ...(options.extraScrubFields ?? [])],\n ignoredMessages: [\n ...DEFAULT_IGNORED_MESSAGES,\n ...(options.extraIgnoredMessages ?? []),\n ],\n payload: {\n // Under `custom`, not at the root of `data`. Rollbar recognises a fixed set of top-level\n // fields and gives unknown ones \"no special handling\" -- they are stored but not indexed as\n // custom metadata, so a root-level `service` is neither queryable nor in the same place the\n // .NET side puts it. Here both sides land at `data.custom.*`, which is also where a webhook\n // receiver finds them: `data.item.last_occurrence.custom.service`.\n //\n // `service` identifies the app and `component` which half of it, as two fields rather than\n // one `blocks-os-client` string, so either can be filtered on without parsing.\n custom: {\n service: options.service,\n component: \"client\",\n },\n client: {\n javascript: {\n source_map_enabled: Boolean(options.codeVersion),\n code_version: options.codeVersion,\n },\n },\n },\n };\n};\n","import Rollbar from \"rollbar\";\nimport {\n createRollbarConfig,\n type RollbarConfigOptions,\n} from \"./rollbar.config\";\n\nlet instance: Rollbar | undefined;\n\n/**\n * The one Rollbar instance for the app.\n *\n * Memoised on first call so that code outside the React tree -- an `HttpClient` built at module\n * scope, for instance -- reports through the same client the provider renders. A second instance\n * would install a second set of window handlers and split the telemetry buffer in two.\n *\n * First call wins: later calls return the existing instance and ignore their options. In practice\n * every call site passes the same service, and load order between a module-scope client and the\n * provider is not something an app should have to reason about.\n *\n * Created lazily, so merely importing this module installs nothing.\n */\nexport const getRollbar = (options: RollbarConfigOptions): Rollbar =>\n (instance ??= new Rollbar(createRollbarConfig(options)));\n","import type { QueryClient } from \"@tanstack/react-query\";\nimport type Rollbar from \"rollbar\";\nimport { HttpError } from \"@/lib/http/error\";\n\n/**\n * Reports errors thrown inside query and mutation functions that are not request failures.\n *\n * Narrow on purpose. Every failure from `HttpClient` arrives as an `HttpError` and is skipped here:\n * transport failures are already handled by `createHttpFailureReporter`, and HTTP statuses are\n * either business outcomes or faults the server reported itself. What remains is a genuine bug in a\n * query function -- a bad mapping, a null dereference on a response -- which React Query catches\n * and stores as query state, so it never reaches `window.onerror` and would otherwise be invisible.\n *\n * Returns an unsubscribe function.\n */\nexport const attachQueryErrorReporting = (\n queryClient: QueryClient,\n rollbar: Rollbar,\n): (() => void) => {\n const report = (error: unknown, context: Record<string, unknown>) => {\n if (error instanceof HttpError) return;\n // Belt and braces: an HttpError that crossed a module boundary may fail `instanceof`.\n if (typeof (error as { status?: unknown })?.status === \"number\") return;\n\n rollbar.error(error instanceof Error ? error : new Error(String(error)), {\n source: \"react-query\",\n ...context,\n });\n };\n\n const unsubscribeQueries = queryClient.getQueryCache().subscribe((event) => {\n if (event.type !== \"updated\" || event.action.type !== \"error\") return;\n\n report(event.action.error, {\n kind: \"query\",\n queryHash: event.query.queryHash,\n });\n });\n\n const unsubscribeMutations = queryClient\n .getMutationCache()\n .subscribe((event) => {\n if (event.type !== \"updated\" || event.action.type !== \"error\") return;\n\n report(event.action.error, {\n kind: \"mutation\",\n mutationKey: event.mutation.options.mutationKey,\n });\n });\n\n return () => {\n unsubscribeQueries();\n unsubscribeMutations();\n };\n};\n","import { ErrorBoundary, Provider } from \"@rollbar/react\";\nimport { useEffect, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport { getQueryClient } from \"@/providers/query-client\";\nimport { attachQueryErrorReporting } from \"./report-query-errors\";\nimport { type RollbarConfigOptions } from \"./rollbar.config\";\nimport { getRollbar } from \"./rollbar.instance\";\n\nexport interface RollbarFallbackProps {\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Shown instead of a blank page when a render throws. Deliberately plain: it has to render when the\n * app's own state is already known-bad, so it depends on nothing but theme tokens.\n */\nconst DefaultFallback = ({ resetError }: RollbarFallbackProps) => (\n <div\n className=\"flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center\"\n role=\"alert\"\n >\n <div className=\"space-y-1\">\n <p className=\"text-lg font-semibold text-foreground\">\n Something went wrong\n </p>\n <p className=\"text-sm text-medium-emphasis\">\n The error has been reported. Try again, or reload the page if it keeps\n happening.\n </p>\n </div>\n <button\n onClick={resetError}\n className=\"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground\"\n >\n Try again\n </button>\n </div>\n);\n\nexport interface RollbarProviderProps extends RollbarConfigOptions {\n children: ReactNode;\n /** Replaces the built-in crash screen. */\n fallback?: ComponentType<RollbarFallbackProps>;\n}\n\n/**\n * Puts Rollbar in front of the whole tree.\n *\n * Mount this outermost -- above the query, theme and router providers -- so a throw during their\n * own setup is still caught and reported rather than blanking the page.\n *\n * Reporting is inert until a client token is seeded (see `createRollbarConfig`), but the boundary is\n * always live, so the crash screen behaves identically in local development and in production.\n *\n * Covers uncaught errors, unhandled rejections, render crashes, and bugs thrown inside query\n * functions. Request failures are not covered here: pass `createHttpFailureReporter` to your\n * `HttpClient` as `onError` for those.\n */\nexport const RollbarProvider = ({\n children,\n fallback = DefaultFallback,\n ...configOptions\n}: RollbarProviderProps) => {\n // Shared with anything reporting from outside the tree, and stable for the life of the app:\n // reconstructing it on re-render would reinstall the window handlers and drop Rollbar's own\n // telemetry buffer.\n const rollbar = useMemo(\n () => getRollbar(configOptions),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useEffect(\n () => attachQueryErrorReporting(getQueryClient(), rollbar),\n [rollbar],\n );\n\n return (\n <Provider instance={rollbar}>\n <ErrorBoundary fallbackUI={fallback} level=\"critical\">\n {children}\n </ErrorBoundary>\n </Provider>\n );\n};\n","import type Rollbar from \"rollbar\";\nimport type { HttpRequestFailure } from \"@/lib/http/types\";\n\n/**\n * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures.\n *\n * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the\n * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,\n * so reporting it again from the browser only buries the better item. What is left -- the API\n * unreachable, DNS, CORS, TLS, offline -- the server cannot report by definition, because it never\n * received the request.\n *\n * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so\n * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out\n * cannot tell the two apart.\n */\nexport const createHttpFailureReporter =\n (rollbar: Rollbar) =>\n (failure: HttpRequestFailure): void => {\n if (!failure.transport) return;\n\n const error =\n failure.error instanceof Error\n ? failure.error\n : new Error(String(failure.error));\n\n rollbar.error(error, {\n source: \"http-client\",\n url: failure.url,\n method: failure.method,\n });\n };\n"]}
1
+ {"version":3,"sources":["../../src/observability/noise-filter.ts","../../src/observability/rollbar.config.ts","../../src/observability/rollbar.instance.ts","../../src/observability/report-query-errors.ts","../../src/observability/rollbar.provider.tsx","../../src/observability/report-http-errors.ts"],"names":["getRuntimeEnv","Rollbar","HttpError","useT","jsxs","jsx","useMemo","useEffect","getQueryClient","Provider","ErrorBoundary"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,IAAM,gBAAA,GAAmB;AAAA,EACvB,iDAAA;AAAA,EACA;AACF,CAAA;AAIA,IAAM,uBAAA,GAA0B;AAAA,EAC9B,mBAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,sBAAA,GAAyB;AAAA,EAC7B,qBAAA;AAAA,EACA,kBAAA;AAAA,EACA,qBAAA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BO,IAAM,kBAAkB,CAAC;AAAA,EAC9B,QAAA;AAAA,EACA,QAAA,GAAW,eAAA;AAAA,EACX,GAAG;AACL,CAAA,KAA4B;AAI1B,EAAA,MAAM,OAAA,GAAUC,aAAA;AAAA,IACd,MAAM,WAAW,aAAa,CAAA;AAAA;AAAA,IAE9B;AAAC,GACH;AAEA,EAAAC,eAAA;AAAA,IACE,MAAM,yBAAA,CAA0BC,gCAAA,EAAe,EAAG,OAAO,CAAA;AAAA,IACzD,CAAC,OAAO;AAAA,GACV;AAEA,EAAA,uBACEH,cAAA,CAACI,gBAAA,EAAA,EAAS,QAAA,EAAU,OAAA,EAClB,QAAA,kBAAAJ,cAAA,CAACK,qBAAA,EAAA,EAAc,UAAA,EAAY,QAAA,EAAU,KAAA,EAAM,UAAA,EACxC,QAAA,EACH,CAAA,EACF,CAAA;AAEJ;;;AClEO,IAAM,yBAAA,GACX,CAAC,OAAA,KACD,CAAC,OAAA,KAAsC;AACrC,EAAA,IAAI,CAAC,QAAQ,SAAA,EAAW;AACxB,EAAA,IAAI,gBAAA,CAAiB,OAAA,CAAQ,KAAK,CAAA,EAAG;AAErC,EAAA,MAAM,KAAA,GACJ,OAAA,CAAQ,KAAA,YAAiB,KAAA,GACrB,OAAA,CAAQ,KAAA,GACR,IAAI,KAAA,CAAM,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAC,CAAA;AAErC,EAAA,OAAA,CAAQ,MAAM,KAAA,EAAO;AAAA,IACnB,MAAA,EAAQ,aAAA;AAAA,IACR,KAAK,OAAA,CAAQ,GAAA;AAAA,IACb,QAAQ,OAAA,CAAQ;AAAA,GACjB,CAAA;AACH","file":"index.cjs","sourcesContent":["/**\n * Errors the browser raises that say nothing about a Blocks fault, and that Rollbar should therefore\n * never receive.\n *\n * Each rule matches one exact signature seen in production. A broad rule would hide real bugs, so a\n * `TypeError` is noise only with a known network message, and an `InvalidStateError` only when it is\n * about a view transition.\n */\nexport type NoiseRule =\n | \"network\"\n | \"view-transition\"\n | \"extension\"\n | \"cancelation\"\n | \"stale-asset\"\n | \"recaptcha-timeout\";\n\ninterface RollbarTraceLike {\n frames?: unknown[] | null;\n exception?: { class?: unknown; message?: unknown } | null;\n}\n\n/** The parts of a Rollbar item (`item.data`) the rules read. */\nexport interface RollbarPayloadLike {\n body?: {\n trace?: RollbarTraceLike | null;\n trace_chain?: (RollbarTraceLike | null)[] | null;\n message?: { body?: unknown } | null;\n } | null;\n}\n\nconst NETWORK_MESSAGES = [\n \"NetworkError when attempting to fetch resource.\",\n \"Load failed\",\n];\n\n// `AbortError` is listed as the spec lists it, though the network rule, checked first, already\n// drops every `AbortError`.\nconst VIEW_TRANSITION_CLASSES = [\n \"InvalidStateError\",\n \"TimeoutError\",\n \"AbortError\",\n];\n\nconst EXTENSION_URL_PREFIXES = [\n \"chrome-extension://\",\n \"moz-extension://\",\n \"safari-extension://\",\n \"safari-web-extension://\",\n];\n\n// What a bare `Event` turns into once it has been stringified, by Rollbar or by the app.\nconst EVENT_MESSAGES = [\n \"[object Event]\",\n \"[object ErrorEvent]\",\n '{\"isTrusted\":true}',\n];\n\nconst asString = (value: unknown): string | undefined =>\n typeof value === \"string\" ? value : undefined;\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) return false;\n const prototype: unknown = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n};\n\nconst isEvent = (value: unknown): boolean =>\n typeof Event !== \"undefined\" && value instanceof Event;\n\nconst isExtensionFrame = (frame: unknown): boolean => {\n const filename = (frame as { filename?: unknown } | null)?.filename;\n return (\n typeof filename === \"string\" &&\n EXTENSION_URL_PREFIXES.some((prefix) => filename.startsWith(prefix))\n );\n};\n\nconst classify = (\n value: unknown,\n payload: RollbarPayloadLike | undefined,\n): NoiseRule | null => {\n const body = payload?.body;\n const trace = body?.trace ?? body?.trace_chain?.[0];\n const raw =\n typeof value === \"object\" && value !== null\n ? (value as { name?: unknown; message?: unknown })\n : undefined;\n\n const errorClass =\n asString(raw?.name) ?? asString(trace?.exception?.class) ?? \"\";\n const message =\n asString(raw?.message) ??\n asString(trace?.exception?.message) ??\n asString(body?.message?.body) ??\n \"\";\n const frames = trace?.frames ?? [];\n\n if (\n (errorClass === \"TypeError\" &&\n (message.startsWith(\"Failed to fetch\") ||\n NETWORK_MESSAGES.includes(message))) ||\n errorClass === \"AbortError\"\n )\n return \"network\";\n\n if (\n VIEW_TRANSITION_CLASSES.includes(errorClass) &&\n message.toLowerCase().includes(\"transition\")\n )\n return \"view-transition\";\n\n // Every frame, not any: an extension frame on top of app frames is still the app's stack.\n if (frames.length > 0 && frames.every(isExtensionFrame)) return \"extension\";\n\n if (\n (errorClass === \"Canceled\" && message === \"Canceled\") ||\n (isPlainObject(value) && value.type === \"cancelation\")\n )\n return \"cancelation\";\n\n if (\n message.startsWith(\n \"Failed to execute 'importScripts' on 'WorkerGlobalScope'\",\n ) ||\n message === \"Object.hasOwn is not a function\" ||\n isEvent(value) ||\n EVENT_MESSAGES.includes(message)\n )\n return \"stale-asset\";\n\n if (message.startsWith(\"reCAPTCHA Timeout\")) return \"recaptcha-timeout\";\n\n return null;\n};\n\n/**\n * Names the noise rule `value` matches, or `null` when it should be reported.\n *\n * `value` is the raw thrown value (an `Error`, a `DOMException`, an `Event`, a plain object). The\n * Rollbar payload, when given, fills in the class, message and stack frames the value does not\n * carry. Fails open: if reading either one throws, the item is reported.\n */\nexport const classifyReportingNoise = (\n value: unknown,\n payload?: RollbarPayloadLike,\n): NoiseRule | null => {\n try {\n return classify(value, payload);\n } catch {\n return null;\n }\n};\n\n/** True for a browser network failure or an aborted request: nothing the app can fix. */\nexport const isNetworkFailure = (error: unknown): boolean =>\n classifyReportingNoise(error) === \"network\";\n","import Rollbar from \"rollbar\";\nimport { getRuntimeEnv } from \"@/lib/runtime-env\";\nimport { classifyReportingNoise } from \"./noise-filter\";\n\n/**\n * Payload keys and header names that must never leave the browser.\n *\n * Rollbar scrubs a default set already; these are the platform-specific ones. Getting this wrong\n * ships a tenant's credentials to a third party, which is why it lives here rather than being\n * restated in every app.\n */\nconst DEFAULT_SCRUB_FIELDS = [\n \"x-blocks-key\",\n \"X-Blocks-Key\",\n \"Authorization\",\n \"authorization\",\n \"access_token\",\n \"refresh_token\",\n \"accessToken\",\n \"refreshToken\",\n \"password\",\n \"clientSecret\",\n \"client_secret\",\n \"connectionString\",\n \"secretValue\",\n];\n\n/**\n * Noise that reaches `window.onerror` but says nothing about the app: browser extensions,\n * cross-origin frames, and the ResizeObserver warning Chrome raises during ordinary layout.\n */\nconst DEFAULT_IGNORED_MESSAGES = [\n \"ResizeObserver loop limit exceeded\",\n \"ResizeObserver loop completed with undelivered notifications\",\n \"Script error.\",\n];\n\n/**\n * Stands in for a real token when none is seeded.\n *\n * `@rollbar/react`'s `Provider` rejects an instance whose `options.accessToken` is falsy -- it\n * throws \"`instance` must be a configured instance of Rollbar\" from its own constructor, which is\n * above the error boundary, so an unconfigured app renders nothing at all. Reporting is switched\n * off by `enabled`, not by the token: the notifier refuses to send before it reaches a transport\n * and telemetry instrumentation is never installed. A placeholder therefore costs nothing and\n * keeps reporting genuinely optional, which is the point -- no tier should go blank because a\n * secret has not been seeded yet.\n */\nexport const UNCONFIGURED_ACCESS_TOKEN = \"rollbar-reporting-disabled\";\n\n/**\n * Rollbar's `checkIgnore`: drops browser noise before it is sent (see `noise-filter.ts`).\n *\n * For uncaught errors and unhandled rejections Rollbar passes `[message, error, ...]`, so the raw\n * value is `args[1]`; for `rollbar.error(err, ...)` it is `args[0]`. Kept a single expression:\n * Rollbar copies the function's source into every item it does send.\n */\nconst ignoreNoise: NonNullable<Rollbar.Configuration[\"checkIgnore\"]> = (\n isUncaught,\n args,\n payload,\n) =>\n classifyReportingNoise(\n isUncaught ? (args?.[1] ?? args?.[0]) : args?.[0],\n payload,\n ) !== null;\n\nexport interface RollbarConfigOptions {\n /**\n * The app reporting, e.g. `\"blocks-os\"`. Pass the same name the app already gives\n * `BlocksAppLayout`, so items can be traced back to a service without a project-id lookup.\n */\n service: string;\n /** Appended to, not replacing, the platform scrub list. */\n extraScrubFields?: string[];\n /** Appended to, not replacing, the default ignore list. */\n extraIgnoredMessages?: string[];\n /** Identifies the build. Required for source-map deobfuscation once maps are uploaded. */\n codeVersion?: string;\n}\n\n/**\n * Builds the browser Rollbar configuration from runtime env.\n *\n * Separate from the provider so it can be asserted on directly: most of the risk in this module is\n * in the configuration -- scrubbing, and whether reporting is on at all -- not in Rollbar itself.\n */\nexport const createRollbarConfig = (\n options: RollbarConfigOptions,\n): Rollbar.Configuration => {\n const accessToken = getRuntimeEnv(\"BLOCKS_ROLLBAR_CLIENT_TOKEN\");\n\n return {\n accessToken: accessToken || UNCONFIGURED_ACCESS_TOKEN,\n // Reporting is opt-in on a seeded token. Unconfigured environments -- developer machines,\n // tests, any tier not yet seeded -- get an inert client rather than a broken one, so the error\n // boundary still behaves exactly as it does in production.\n enabled: accessToken.length > 0,\n environment: getRuntimeEnv(\"BLOCKS_ROLLBAR_ENV\") || \"unknown\",\n captureUncaught: true,\n captureUnhandledRejections: true,\n scrubFields: [...DEFAULT_SCRUB_FIELDS, ...(options.extraScrubFields ?? [])],\n ignoredMessages: [\n ...DEFAULT_IGNORED_MESSAGES,\n ...(options.extraIgnoredMessages ?? []),\n ],\n checkIgnore: ignoreNoise,\n payload: {\n // Under `custom`, not at the root of `data`. Rollbar recognises a fixed set of top-level\n // fields and gives unknown ones \"no special handling\" -- they are stored but not indexed as\n // custom metadata, so a root-level `service` is neither queryable nor in the same place the\n // .NET side puts it. Here both sides land at `data.custom.*`, which is also where a webhook\n // receiver finds them: `data.item.last_occurrence.custom.service`.\n //\n // `service` identifies the app and `component` which half of it, as two fields rather than\n // one `blocks-os-client` string, so either can be filtered on without parsing.\n custom: {\n service: options.service,\n component: \"client\",\n },\n client: {\n javascript: {\n source_map_enabled: Boolean(options.codeVersion),\n code_version: options.codeVersion,\n },\n },\n },\n };\n};\n","import Rollbar from \"rollbar\";\nimport {\n createRollbarConfig,\n type RollbarConfigOptions,\n} from \"./rollbar.config\";\n\nlet instance: Rollbar | undefined;\n\n/**\n * The one Rollbar instance for the app.\n *\n * Memoised on first call so that code outside the React tree -- an `HttpClient` built at module\n * scope, for instance -- reports through the same client the provider renders. A second instance\n * would install a second set of window handlers and split the telemetry buffer in two.\n *\n * First call wins: later calls return the existing instance and ignore their options. In practice\n * every call site passes the same service, and load order between a module-scope client and the\n * provider is not something an app should have to reason about.\n *\n * Created lazily, so merely importing this module installs nothing.\n */\nexport const getRollbar = (options: RollbarConfigOptions): Rollbar =>\n (instance ??= new Rollbar(createRollbarConfig(options)));\n","import type { QueryClient } from \"@tanstack/react-query\";\nimport type Rollbar from \"rollbar\";\nimport { HttpError } from \"@/lib/http/error\";\nimport { isNetworkFailure } from \"./noise-filter\";\n\n/**\n * Reports errors thrown inside query and mutation functions that are not request failures.\n *\n * Narrow on purpose. Every failure from `HttpClient` arrives as an `HttpError` and is skipped here:\n * transport failures are already handled by `createHttpFailureReporter`, and HTTP statuses are\n * either business outcomes or faults the server reported itself. What remains is a genuine bug in a\n * query function -- a bad mapping, a null dereference on a response -- which React Query catches\n * and stores as query state, so it never reaches `window.onerror` and would otherwise be invisible.\n *\n * Returns an unsubscribe function.\n */\nexport const attachQueryErrorReporting = (\n queryClient: QueryClient,\n rollbar: Rollbar,\n): (() => void) => {\n const report = (error: unknown, context: Record<string, unknown>) => {\n if (error instanceof HttpError) return;\n // Belt and braces: an HttpError that crossed a module boundary may fail `instanceof`.\n if (typeof (error as { status?: unknown })?.status === \"number\") return;\n // A raw `fetch` in a query function rejects with the browser's own network error.\n if (isNetworkFailure(error)) return;\n\n rollbar.error(error instanceof Error ? error : new Error(String(error)), {\n source: \"react-query\",\n ...context,\n });\n };\n\n const unsubscribeQueries = queryClient.getQueryCache().subscribe((event) => {\n if (event.type !== \"updated\" || event.action.type !== \"error\") return;\n\n report(event.action.error, {\n kind: \"query\",\n queryHash: event.query.queryHash,\n });\n });\n\n const unsubscribeMutations = queryClient\n .getMutationCache()\n .subscribe((event) => {\n if (event.type !== \"updated\" || event.action.type !== \"error\") return;\n\n report(event.action.error, {\n kind: \"mutation\",\n mutationKey: event.mutation.options.mutationKey,\n });\n });\n\n return () => {\n unsubscribeQueries();\n unsubscribeMutations();\n };\n};\n","import { ErrorBoundary, Provider } from \"@rollbar/react\";\nimport { useEffect, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport { getQueryClient } from \"@/providers/query-client\";\nimport { attachQueryErrorReporting } from \"./report-query-errors\";\nimport { type RollbarConfigOptions } from \"./rollbar.config\";\nimport { getRollbar } from \"./rollbar.instance\";\nimport { useT } from \"@/i18n/use-t\";\n\nexport interface RollbarFallbackProps {\n error: Error | null;\n resetError: () => void;\n}\n\n/**\n * Shown instead of a blank page when a render throws. Deliberately plain: it has to render when the\n * app's own state is already known-bad, so it depends only on theme tokens and its i18n keys, which\n * fall back to the bundled English when nothing else loads.\n */\nconst DefaultFallback = ({ resetError }: RollbarFallbackProps) => {\n const { t } = useT(\"genesis.shared\");\n return (\n <div\n className=\"flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center\"\n role=\"alert\"\n >\n <div className=\"space-y-1\">\n <p className=\"text-lg font-semibold text-foreground\">\n {t(\"ROLLBAR_FALLBACK.TITLE\")}\n </p>\n <p className=\"text-sm text-medium-emphasis\">\n {t(\"ROLLBAR_FALLBACK.MESSAGE\")}\n </p>\n </div>\n <button\n onClick={resetError}\n className=\"rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground\"\n >\n {t(\"ROLLBAR_FALLBACK.TRY_AGAIN\")}\n </button>\n </div>\n );\n};\n\nexport interface RollbarProviderProps extends RollbarConfigOptions {\n children: ReactNode;\n /** Replaces the built-in crash screen. */\n fallback?: ComponentType<RollbarFallbackProps>;\n}\n\n/**\n * Puts Rollbar in front of the whole tree.\n *\n * Mount this outermost -- above the query, theme and router providers -- so a throw during their\n * own setup is still caught and reported rather than blanking the page.\n *\n * Reporting is inert until a client token is seeded (see `createRollbarConfig`), but the boundary is\n * always live, so the crash screen behaves identically in local development and in production.\n *\n * Covers uncaught errors, unhandled rejections, render crashes, and bugs thrown inside query\n * functions. Request failures are not covered here: pass `createHttpFailureReporter` to your\n * `HttpClient` as `onError` for those.\n */\nexport const RollbarProvider = ({\n children,\n fallback = DefaultFallback,\n ...configOptions\n}: RollbarProviderProps) => {\n // Shared with anything reporting from outside the tree, and stable for the life of the app:\n // reconstructing it on re-render would reinstall the window handlers and drop Rollbar's own\n // telemetry buffer.\n const rollbar = useMemo(\n () => getRollbar(configOptions),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\n );\n\n useEffect(\n () => attachQueryErrorReporting(getQueryClient(), rollbar),\n [rollbar],\n );\n\n return (\n <Provider instance={rollbar}>\n <ErrorBoundary fallbackUI={fallback} level=\"critical\">\n {children}\n </ErrorBoundary>\n </Provider>\n );\n};\n","import type Rollbar from \"rollbar\";\nimport type { HttpRequestFailure } from \"@/lib/http/types\";\nimport { isNetworkFailure } from \"./noise-filter\";\n\n/**\n * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures that are\n * not browser network failures.\n *\n * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the\n * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,\n * so reporting it again from the browser only buries the better item.\n *\n * Browser network failures are skipped too (`isNetworkFailure`: offline, DNS, CORS, TLS and aborted\n * requests all surface as `TypeError: Failed to fetch` and its Firefox/Safari equivalents, or as an\n * `AbortError`). They come from the user's connection rather than from Blocks, and an outage shows\n * up in server-side 5xx items and uptime monitoring instead. What is left -- a body that fails to\n * parse, a throw inside the client itself -- is a client fault the server cannot see.\n *\n * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so\n * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out\n * cannot tell the two apart.\n */\nexport const createHttpFailureReporter =\n (rollbar: Rollbar) =>\n (failure: HttpRequestFailure): void => {\n if (!failure.transport) return;\n if (isNetworkFailure(failure.error)) return;\n\n const error =\n failure.error instanceof Error\n ? failure.error\n : new Error(String(failure.error));\n\n rollbar.error(error, {\n source: \"http-client\",\n url: failure.url,\n method: failure.method,\n });\n };\n"]}
@@ -7,6 +7,43 @@ import '../auth.model-BHLqtZG5.cjs';
7
7
  import '../user.model-D-yeFp-2.cjs';
8
8
  import '../base.types-XgGxHPNY.cjs';
9
9
 
10
+ /**
11
+ * Errors the browser raises that say nothing about a Blocks fault, and that Rollbar should therefore
12
+ * never receive.
13
+ *
14
+ * Each rule matches one exact signature seen in production. A broad rule would hide real bugs, so a
15
+ * `TypeError` is noise only with a known network message, and an `InvalidStateError` only when it is
16
+ * about a view transition.
17
+ */
18
+ type NoiseRule = "network" | "view-transition" | "extension" | "cancelation" | "stale-asset" | "recaptcha-timeout";
19
+ interface RollbarTraceLike {
20
+ frames?: unknown[] | null;
21
+ exception?: {
22
+ class?: unknown;
23
+ message?: unknown;
24
+ } | null;
25
+ }
26
+ /** The parts of a Rollbar item (`item.data`) the rules read. */
27
+ interface RollbarPayloadLike {
28
+ body?: {
29
+ trace?: RollbarTraceLike | null;
30
+ trace_chain?: (RollbarTraceLike | null)[] | null;
31
+ message?: {
32
+ body?: unknown;
33
+ } | null;
34
+ } | null;
35
+ }
36
+ /**
37
+ * Names the noise rule `value` matches, or `null` when it should be reported.
38
+ *
39
+ * `value` is the raw thrown value (an `Error`, a `DOMException`, an `Event`, a plain object). The
40
+ * Rollbar payload, when given, fills in the class, message and stack frames the value does not
41
+ * carry. Fails open: if reading either one throws, the item is reported.
42
+ */
43
+ declare const classifyReportingNoise: (value: unknown, payload?: RollbarPayloadLike) => NoiseRule | null;
44
+ /** True for a browser network failure or an aborted request: nothing the app can fix. */
45
+ declare const isNetworkFailure: (error: unknown) => boolean;
46
+
10
47
  /**
11
48
  * Stands in for a real token when none is seeded.
12
49
  *
@@ -80,13 +117,18 @@ interface RollbarProviderProps extends RollbarConfigOptions {
80
117
  declare const RollbarProvider: ({ children, fallback, ...configOptions }: RollbarProviderProps) => React.JSX.Element;
81
118
 
82
119
  /**
83
- * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures.
120
+ * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures that are
121
+ * not browser network failures.
84
122
  *
85
123
  * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the
86
124
  * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,
87
- * so reporting it again from the browser only buries the better item. What is left -- the API
88
- * unreachable, DNS, CORS, TLS, offline -- the server cannot report by definition, because it never
89
- * received the request.
125
+ * so reporting it again from the browser only buries the better item.
126
+ *
127
+ * Browser network failures are skipped too (`isNetworkFailure`: offline, DNS, CORS, TLS and aborted
128
+ * requests all surface as `TypeError: Failed to fetch` and its Firefox/Safari equivalents, or as an
129
+ * `AbortError`). They come from the user's connection rather than from Blocks, and an outage shows
130
+ * up in server-side 5xx items and uptime monitoring instead. What is left -- a body that fails to
131
+ * parse, a throw inside the client itself -- is a client fault the server cannot see.
90
132
  *
91
133
  * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so
92
134
  * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out
@@ -107,4 +149,4 @@ declare const createHttpFailureReporter: (rollbar: Rollbar) => (failure: HttpReq
107
149
  */
108
150
  declare const attachQueryErrorReporting: (queryClient: QueryClient, rollbar: Rollbar) => (() => void);
109
151
 
110
- export { type RollbarConfigOptions, type RollbarFallbackProps, RollbarProvider, type RollbarProviderProps, UNCONFIGURED_ACCESS_TOKEN, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig, getRollbar };
152
+ export { type NoiseRule, type RollbarConfigOptions, type RollbarFallbackProps, type RollbarPayloadLike, RollbarProvider, type RollbarProviderProps, UNCONFIGURED_ACCESS_TOKEN, attachQueryErrorReporting, classifyReportingNoise, createHttpFailureReporter, createRollbarConfig, getRollbar, isNetworkFailure };
@@ -7,6 +7,43 @@ import '../auth.model-6We_OkEZ.js';
7
7
  import '../user.model-jYC7Cd3G.js';
8
8
  import '../base.types-XgGxHPNY.js';
9
9
 
10
+ /**
11
+ * Errors the browser raises that say nothing about a Blocks fault, and that Rollbar should therefore
12
+ * never receive.
13
+ *
14
+ * Each rule matches one exact signature seen in production. A broad rule would hide real bugs, so a
15
+ * `TypeError` is noise only with a known network message, and an `InvalidStateError` only when it is
16
+ * about a view transition.
17
+ */
18
+ type NoiseRule = "network" | "view-transition" | "extension" | "cancelation" | "stale-asset" | "recaptcha-timeout";
19
+ interface RollbarTraceLike {
20
+ frames?: unknown[] | null;
21
+ exception?: {
22
+ class?: unknown;
23
+ message?: unknown;
24
+ } | null;
25
+ }
26
+ /** The parts of a Rollbar item (`item.data`) the rules read. */
27
+ interface RollbarPayloadLike {
28
+ body?: {
29
+ trace?: RollbarTraceLike | null;
30
+ trace_chain?: (RollbarTraceLike | null)[] | null;
31
+ message?: {
32
+ body?: unknown;
33
+ } | null;
34
+ } | null;
35
+ }
36
+ /**
37
+ * Names the noise rule `value` matches, or `null` when it should be reported.
38
+ *
39
+ * `value` is the raw thrown value (an `Error`, a `DOMException`, an `Event`, a plain object). The
40
+ * Rollbar payload, when given, fills in the class, message and stack frames the value does not
41
+ * carry. Fails open: if reading either one throws, the item is reported.
42
+ */
43
+ declare const classifyReportingNoise: (value: unknown, payload?: RollbarPayloadLike) => NoiseRule | null;
44
+ /** True for a browser network failure or an aborted request: nothing the app can fix. */
45
+ declare const isNetworkFailure: (error: unknown) => boolean;
46
+
10
47
  /**
11
48
  * Stands in for a real token when none is seeded.
12
49
  *
@@ -80,13 +117,18 @@ interface RollbarProviderProps extends RollbarConfigOptions {
80
117
  declare const RollbarProvider: ({ children, fallback, ...configOptions }: RollbarProviderProps) => React.JSX.Element;
81
118
 
82
119
  /**
83
- * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures.
120
+ * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures that are
121
+ * not browser network failures.
84
122
  *
85
123
  * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the
86
124
  * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,
87
- * so reporting it again from the browser only buries the better item. What is left -- the API
88
- * unreachable, DNS, CORS, TLS, offline -- the server cannot report by definition, because it never
89
- * received the request.
125
+ * so reporting it again from the browser only buries the better item.
126
+ *
127
+ * Browser network failures are skipped too (`isNetworkFailure`: offline, DNS, CORS, TLS and aborted
128
+ * requests all surface as `TypeError: Failed to fetch` and its Firefox/Safari equivalents, or as an
129
+ * `AbortError`). They come from the user's connection rather than from Blocks, and an outage shows
130
+ * up in server-side 5xx items and uptime monitoring instead. What is left -- a body that fails to
131
+ * parse, a throw inside the client itself -- is a client fault the server cannot see.
90
132
  *
91
133
  * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so
92
134
  * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out
@@ -107,4 +149,4 @@ declare const createHttpFailureReporter: (rollbar: Rollbar) => (failure: HttpReq
107
149
  */
108
150
  declare const attachQueryErrorReporting: (queryClient: QueryClient, rollbar: Rollbar) => (() => void);
109
151
 
110
- export { type RollbarConfigOptions, type RollbarFallbackProps, RollbarProvider, type RollbarProviderProps, UNCONFIGURED_ACCESS_TOKEN, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig, getRollbar };
152
+ export { type NoiseRule, type RollbarConfigOptions, type RollbarFallbackProps, type RollbarPayloadLike, RollbarProvider, type RollbarProviderProps, UNCONFIGURED_ACCESS_TOKEN, attachQueryErrorReporting, classifyReportingNoise, createHttpFailureReporter, createRollbarConfig, getRollbar, isNetworkFailure };
@@ -1,11 +1,76 @@
1
- import { getRuntimeEnv, HttpError } from '../chunk-JUVLHPQI.js';
1
+ import { HttpError } from '../chunk-7ZZ3KLZD.js';
2
+ import { useT } from '../chunk-XYPSBVXL.js';
2
3
  import { getQueryClient } from '../chunk-BRHE44FE.js';
4
+ import { getRuntimeEnv } from '../chunk-POJIHGRY.js';
5
+ import '../chunk-SQG7DJNY.js';
6
+ import '../chunk-3V7O45KN.js';
3
7
  import '../chunk-PL4HS6R6.js';
4
8
  import Rollbar2 from 'rollbar';
5
9
  import { Provider, ErrorBoundary } from '@rollbar/react';
6
10
  import { useMemo, useEffect } from 'react';
7
11
  import { jsx, jsxs } from 'react/jsx-runtime';
8
12
 
13
+ // src/observability/noise-filter.ts
14
+ var NETWORK_MESSAGES = [
15
+ "NetworkError when attempting to fetch resource.",
16
+ "Load failed"
17
+ ];
18
+ var VIEW_TRANSITION_CLASSES = [
19
+ "InvalidStateError",
20
+ "TimeoutError",
21
+ "AbortError"
22
+ ];
23
+ var EXTENSION_URL_PREFIXES = [
24
+ "chrome-extension://",
25
+ "moz-extension://",
26
+ "safari-extension://",
27
+ "safari-web-extension://"
28
+ ];
29
+ var EVENT_MESSAGES = [
30
+ "[object Event]",
31
+ "[object ErrorEvent]",
32
+ '{"isTrusted":true}'
33
+ ];
34
+ var asString = (value) => typeof value === "string" ? value : void 0;
35
+ var isPlainObject = (value) => {
36
+ if (typeof value !== "object" || value === null) return false;
37
+ const prototype = Object.getPrototypeOf(value);
38
+ return prototype === Object.prototype || prototype === null;
39
+ };
40
+ var isEvent = (value) => typeof Event !== "undefined" && value instanceof Event;
41
+ var isExtensionFrame = (frame) => {
42
+ const filename = frame?.filename;
43
+ return typeof filename === "string" && EXTENSION_URL_PREFIXES.some((prefix) => filename.startsWith(prefix));
44
+ };
45
+ var classify = (value, payload) => {
46
+ const body = payload?.body;
47
+ const trace = body?.trace ?? body?.trace_chain?.[0];
48
+ const raw = typeof value === "object" && value !== null ? value : void 0;
49
+ const errorClass = asString(raw?.name) ?? asString(trace?.exception?.class) ?? "";
50
+ const message = asString(raw?.message) ?? asString(trace?.exception?.message) ?? asString(body?.message?.body) ?? "";
51
+ const frames = trace?.frames ?? [];
52
+ if (errorClass === "TypeError" && (message.startsWith("Failed to fetch") || NETWORK_MESSAGES.includes(message)) || errorClass === "AbortError")
53
+ return "network";
54
+ if (VIEW_TRANSITION_CLASSES.includes(errorClass) && message.toLowerCase().includes("transition"))
55
+ return "view-transition";
56
+ if (frames.length > 0 && frames.every(isExtensionFrame)) return "extension";
57
+ if (errorClass === "Canceled" && message === "Canceled" || isPlainObject(value) && value.type === "cancelation")
58
+ return "cancelation";
59
+ if (message.startsWith(
60
+ "Failed to execute 'importScripts' on 'WorkerGlobalScope'"
61
+ ) || message === "Object.hasOwn is not a function" || isEvent(value) || EVENT_MESSAGES.includes(message))
62
+ return "stale-asset";
63
+ if (message.startsWith("reCAPTCHA Timeout")) return "recaptcha-timeout";
64
+ return null;
65
+ };
66
+ var classifyReportingNoise = (value, payload) => {
67
+ try {
68
+ return classify(value, payload);
69
+ } catch {
70
+ return null;
71
+ }
72
+ };
73
+ var isNetworkFailure = (error) => classifyReportingNoise(error) === "network";
9
74
  var DEFAULT_SCRUB_FIELDS = [
10
75
  "x-blocks-key",
11
76
  "X-Blocks-Key",
@@ -27,6 +92,10 @@ var DEFAULT_IGNORED_MESSAGES = [
27
92
  "Script error."
28
93
  ];
29
94
  var UNCONFIGURED_ACCESS_TOKEN = "rollbar-reporting-disabled";
95
+ var ignoreNoise = (isUncaught, args, payload) => classifyReportingNoise(
96
+ isUncaught ? args?.[1] ?? args?.[0] : args?.[0],
97
+ payload
98
+ ) !== null;
30
99
  var createRollbarConfig = (options) => {
31
100
  const accessToken = getRuntimeEnv("BLOCKS_ROLLBAR_CLIENT_TOKEN");
32
101
  return {
@@ -43,6 +112,7 @@ var createRollbarConfig = (options) => {
43
112
  ...DEFAULT_IGNORED_MESSAGES,
44
113
  ...options.extraIgnoredMessages ?? []
45
114
  ],
115
+ checkIgnore: ignoreNoise,
46
116
  payload: {
47
117
  // Under `custom`, not at the root of `data`. Rollbar recognises a fixed set of top-level
48
118
  // fields and gives unknown ones "no special handling" -- they are stored but not indexed as
@@ -73,6 +143,7 @@ var attachQueryErrorReporting = (queryClient, rollbar) => {
73
143
  const report = (error, context) => {
74
144
  if (error instanceof HttpError) return;
75
145
  if (typeof error?.status === "number") return;
146
+ if (isNetworkFailure(error)) return;
76
147
  rollbar.error(error instanceof Error ? error : new Error(String(error)), {
77
148
  source: "react-query",
78
149
  ...context
@@ -97,27 +168,30 @@ var attachQueryErrorReporting = (queryClient, rollbar) => {
97
168
  unsubscribeMutations();
98
169
  };
99
170
  };
100
- var DefaultFallback = ({ resetError }) => /* @__PURE__ */ jsxs(
101
- "div",
102
- {
103
- className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
104
- role: "alert",
105
- children: [
106
- /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
107
- /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold text-foreground", children: "Something went wrong" }),
108
- /* @__PURE__ */ jsx("p", { className: "text-sm text-medium-emphasis", children: "The error has been reported. Try again, or reload the page if it keeps happening." })
109
- ] }),
110
- /* @__PURE__ */ jsx(
111
- "button",
112
- {
113
- onClick: resetError,
114
- className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
115
- children: "Try again"
116
- }
117
- )
118
- ]
119
- }
120
- );
171
+ var DefaultFallback = ({ resetError }) => {
172
+ const { t } = useT("genesis.shared");
173
+ return /* @__PURE__ */ jsxs(
174
+ "div",
175
+ {
176
+ className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
177
+ role: "alert",
178
+ children: [
179
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
180
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold text-foreground", children: t("ROLLBAR_FALLBACK.TITLE") }),
181
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-medium-emphasis", children: t("ROLLBAR_FALLBACK.MESSAGE") })
182
+ ] }),
183
+ /* @__PURE__ */ jsx(
184
+ "button",
185
+ {
186
+ onClick: resetError,
187
+ className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
188
+ children: t("ROLLBAR_FALLBACK.TRY_AGAIN")
189
+ }
190
+ )
191
+ ]
192
+ }
193
+ );
194
+ };
121
195
  var RollbarProvider = ({
122
196
  children,
123
197
  fallback = DefaultFallback,
@@ -138,6 +212,7 @@ var RollbarProvider = ({
138
212
  // src/observability/report-http-errors.ts
139
213
  var createHttpFailureReporter = (rollbar) => (failure) => {
140
214
  if (!failure.transport) return;
215
+ if (isNetworkFailure(failure.error)) return;
141
216
  const error = failure.error instanceof Error ? failure.error : new Error(String(failure.error));
142
217
  rollbar.error(error, {
143
218
  source: "http-client",
@@ -146,6 +221,6 @@ var createHttpFailureReporter = (rollbar) => (failure) => {
146
221
  });
147
222
  };
148
223
 
149
- export { RollbarProvider, UNCONFIGURED_ACCESS_TOKEN, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig, getRollbar };
224
+ export { RollbarProvider, UNCONFIGURED_ACCESS_TOKEN, attachQueryErrorReporting, classifyReportingNoise, createHttpFailureReporter, createRollbarConfig, getRollbar, isNetworkFailure };
150
225
  //# sourceMappingURL=index.js.map
151
226
  //# sourceMappingURL=index.js.map