@seliseblocks/genesis-os 4.2.5 → 4.2.7

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 (122) hide show
  1. package/dist/{all-D22OCWSN.cjs → all-2UHIE3HU.cjs} +41 -41
  2. package/dist/all-2UHIE3HU.cjs.map +1 -0
  3. package/dist/{all-TUOS2F7K.js → all-OJ5YSNAN.js} +41 -41
  4. package/dist/all-OJ5YSNAN.js.map +1 -0
  5. package/dist/{blocks-app-layout.provider-C831nKua.d.cts → blocks-app-layout.provider-CIxfHM6W.d.cts} +1 -1
  6. package/dist/{blocks-app-layout.provider-CDK1FNn8.d.ts → blocks-app-layout.provider-CaAVR6ae.d.ts} +1 -1
  7. package/dist/{chunk-7EFD3LDX.js → chunk-25L7I5C7.js} +5 -4
  8. package/dist/chunk-25L7I5C7.js.map +1 -0
  9. package/dist/chunk-3MLPBMH2.js +10 -0
  10. package/dist/chunk-3MLPBMH2.js.map +1 -0
  11. package/dist/{chunk-PRSVTYXS.js → chunk-5D4AQMX5.js} +12 -10
  12. package/dist/chunk-5D4AQMX5.js.map +1 -0
  13. package/dist/{chunk-FJ4KYZYG.cjs → chunk-6TMMJJRJ.cjs} +19 -18
  14. package/dist/chunk-6TMMJJRJ.cjs.map +1 -0
  15. package/dist/{chunk-MWEREW2W.js → chunk-BRHE44FE.js} +3 -8
  16. package/dist/chunk-BRHE44FE.js.map +1 -0
  17. package/dist/{chunk-SDWR3F3Y.cjs → chunk-F2LXD7RI.cjs} +2 -8
  18. package/dist/chunk-F2LXD7RI.cjs.map +1 -0
  19. package/dist/{chunk-6UG66Z5P.cjs → chunk-FG2BVNOH.cjs} +3 -3
  20. package/dist/{chunk-6UG66Z5P.cjs.map → chunk-FG2BVNOH.cjs.map} +1 -1
  21. package/dist/{chunk-HF24SZFI.cjs → chunk-FKFBYT22.cjs} +66 -68
  22. package/dist/chunk-FKFBYT22.cjs.map +1 -0
  23. package/dist/{chunk-5CSA5Y7I.js → chunk-HQNDGZ3F.js} +3 -3
  24. package/dist/{chunk-5CSA5Y7I.js.map → chunk-HQNDGZ3F.js.map} +1 -1
  25. package/dist/{chunk-QYN3AEU5.cjs → chunk-HS6F65WY.cjs} +12 -11
  26. package/dist/chunk-HS6F65WY.cjs.map +1 -0
  27. package/dist/{chunk-WPTHBDJO.js → chunk-IICIA5RV.js} +4 -3
  28. package/dist/chunk-IICIA5RV.js.map +1 -0
  29. package/dist/{chunk-T2NGZE5W.cjs → chunk-J7P4N4JM.cjs} +405 -403
  30. package/dist/chunk-J7P4N4JM.cjs.map +1 -0
  31. package/dist/{chunk-UHMCEC7M.cjs → chunk-JQ4U53QV.cjs} +41 -41
  32. package/dist/{chunk-UHMCEC7M.cjs.map → chunk-JQ4U53QV.cjs.map} +1 -1
  33. package/dist/chunk-JUVLHPQI.js +32 -0
  34. package/dist/chunk-JUVLHPQI.js.map +1 -0
  35. package/dist/{chunk-RZ3F7SL3.js → chunk-LONMDMML.js} +4 -3
  36. package/dist/chunk-LONMDMML.js.map +1 -0
  37. package/dist/{chunk-M4AKVWL4.js → chunk-TE3SKUL4.js} +3 -3
  38. package/dist/{chunk-M4AKVWL4.js.map → chunk-TE3SKUL4.js.map} +1 -1
  39. package/dist/{chunk-U3WXD3OX.cjs → chunk-UVMFL4UV.cjs} +22 -21
  40. package/dist/chunk-UVMFL4UV.cjs.map +1 -0
  41. package/dist/{chunk-Z6N3Y5AQ.cjs → chunk-VTOD5ZQU.cjs} +4 -4
  42. package/dist/{chunk-Z6N3Y5AQ.cjs.map → chunk-VTOD5ZQU.cjs.map} +1 -1
  43. package/dist/{chunk-GWZQFBJ5.js → chunk-WBSWAHS6.js} +54 -53
  44. package/dist/chunk-WBSWAHS6.js.map +1 -0
  45. package/dist/{chunk-575VJQ2U.js → chunk-WIY77276.js} +5 -5
  46. package/dist/chunk-WIY77276.js.map +1 -0
  47. package/dist/{chunk-WSUY6GPC.js → chunk-WL6LTNZN.js} +40 -40
  48. package/dist/{chunk-WSUY6GPC.js.map → chunk-WL6LTNZN.js.map} +1 -1
  49. package/dist/chunk-X4YCRWXO.cjs +36 -0
  50. package/dist/chunk-X4YCRWXO.cjs.map +1 -0
  51. package/dist/chunk-YAF2X7W5.cjs +12 -0
  52. package/dist/chunk-YAF2X7W5.cjs.map +1 -0
  53. package/dist/{chunk-ROV7S3SC.cjs → chunk-ZVGCCTNK.cjs} +12 -12
  54. package/dist/chunk-ZVGCCTNK.cjs.map +1 -0
  55. package/dist/components/index.cjs +395 -393
  56. package/dist/components/index.d.cts +4 -4
  57. package/dist/components/index.d.ts +4 -4
  58. package/dist/components/index.js +49 -47
  59. package/dist/guards/index.cjs +12 -10
  60. package/dist/guards/index.js +6 -4
  61. package/dist/hooks/index.cjs +56 -54
  62. package/dist/hooks/index.d.cts +4 -4
  63. package/dist/hooks/index.d.ts +4 -4
  64. package/dist/hooks/index.js +6 -4
  65. package/dist/index.cjs +561 -559
  66. package/dist/index.d.cts +6 -5
  67. package/dist/index.d.ts +6 -5
  68. package/dist/index.js +49 -47
  69. package/dist/javadoc-OGFNQ57B.cjs +14 -0
  70. package/dist/{javadoc-ZLZVKQJ6.cjs.map → javadoc-OGFNQ57B.cjs.map} +1 -1
  71. package/dist/{javadoc-KISXL6ZJ.js → javadoc-QPVMWNCP.js} +4 -4
  72. package/dist/{javadoc-KISXL6ZJ.js.map → javadoc-QPVMWNCP.js.map} +1 -1
  73. package/dist/layouts/index.cjs +56 -54
  74. package/dist/layouts/index.js +49 -47
  75. package/dist/lib/index.cjs +29 -27
  76. package/dist/lib/index.d.cts +17 -50
  77. package/dist/lib/index.d.ts +17 -50
  78. package/dist/lib/index.js +4 -2
  79. package/dist/observability/index.cjs +149 -0
  80. package/dist/observability/index.cjs.map +1 -0
  81. package/dist/observability/index.d.cts +83 -0
  82. package/dist/observability/index.d.ts +83 -0
  83. package/dist/observability/index.js +140 -0
  84. package/dist/observability/index.js.map +1 -0
  85. package/dist/pages/index.cjs +54 -52
  86. package/dist/pages/index.js +49 -47
  87. package/dist/providers/index.cjs +8 -7
  88. package/dist/providers/index.d.cts +2 -2
  89. package/dist/providers/index.d.ts +2 -2
  90. package/dist/providers/index.js +3 -2
  91. package/dist/{runtime-env-BdtgvU0N.d.cts → runtime-env-BDeaC4ay.d.cts} +1 -1
  92. package/dist/{runtime-env-ByALSfkR.d.ts → runtime-env-S2YD-RGu.d.ts} +1 -1
  93. package/dist/{runtime.types-DfALkK5X.d.cts → runtime.types-CVQo3owj.d.cts} +1 -1
  94. package/dist/{runtime.types-DfALkK5X.d.ts → runtime.types-CVQo3owj.d.ts} +1 -1
  95. package/dist/types/index.d.cts +1 -1
  96. package/dist/types/index.d.ts +1 -1
  97. package/dist/types-CxmwyESB.d.cts +73 -0
  98. package/dist/types-R-boAdbM.d.ts +73 -0
  99. package/dist/{use-keyboard-shortcut-BJCssC78.d.cts → use-keyboard-shortcut-C491xr01.d.cts} +1 -1
  100. package/dist/{use-keyboard-shortcut-BJCssC78.d.ts → use-keyboard-shortcut-C491xr01.d.ts} +1 -1
  101. package/dist/utils/index.cjs +73 -71
  102. package/dist/utils/index.d.cts +1 -1
  103. package/dist/utils/index.d.ts +1 -1
  104. package/dist/utils/index.js +5 -3
  105. package/package.json +8 -1
  106. package/dist/all-D22OCWSN.cjs.map +0 -1
  107. package/dist/all-TUOS2F7K.js.map +0 -1
  108. package/dist/chunk-575VJQ2U.js.map +0 -1
  109. package/dist/chunk-7EFD3LDX.js.map +0 -1
  110. package/dist/chunk-FJ4KYZYG.cjs.map +0 -1
  111. package/dist/chunk-GWZQFBJ5.js.map +0 -1
  112. package/dist/chunk-HF24SZFI.cjs.map +0 -1
  113. package/dist/chunk-MWEREW2W.js.map +0 -1
  114. package/dist/chunk-PRSVTYXS.js.map +0 -1
  115. package/dist/chunk-QYN3AEU5.cjs.map +0 -1
  116. package/dist/chunk-ROV7S3SC.cjs.map +0 -1
  117. package/dist/chunk-RZ3F7SL3.js.map +0 -1
  118. package/dist/chunk-SDWR3F3Y.cjs.map +0 -1
  119. package/dist/chunk-T2NGZE5W.cjs.map +0 -1
  120. package/dist/chunk-U3WXD3OX.cjs.map +0 -1
  121. package/dist/chunk-WPTHBDJO.js.map +0 -1
  122. package/dist/javadoc-ZLZVKQJ6.cjs +0 -14
@@ -0,0 +1,149 @@
1
+ 'use strict';
2
+
3
+ var chunkX4YCRWXO_cjs = require('../chunk-X4YCRWXO.cjs');
4
+ var chunkF2LXD7RI_cjs = require('../chunk-F2LXD7RI.cjs');
5
+ require('../chunk-QJOVCH5A.cjs');
6
+ var Rollbar2 = require('rollbar');
7
+ var react$1 = require('@rollbar/react');
8
+ var react = require('react');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var Rollbar2__default = /*#__PURE__*/_interopDefault(Rollbar2);
14
+
15
+ var DEFAULT_SCRUB_FIELDS = [
16
+ "x-blocks-key",
17
+ "X-Blocks-Key",
18
+ "Authorization",
19
+ "authorization",
20
+ "access_token",
21
+ "refresh_token",
22
+ "accessToken",
23
+ "refreshToken",
24
+ "password",
25
+ "clientSecret",
26
+ "client_secret",
27
+ "connectionString",
28
+ "secretValue"
29
+ ];
30
+ var DEFAULT_IGNORED_MESSAGES = [
31
+ "ResizeObserver loop limit exceeded",
32
+ "ResizeObserver loop completed with undelivered notifications",
33
+ "Script error."
34
+ ];
35
+ var createRollbarConfig = (options) => {
36
+ const accessToken = chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_ROLLBAR_CLIENT_TOKEN");
37
+ return {
38
+ accessToken,
39
+ // Reporting is opt-in on a seeded token. Unconfigured environments -- developer machines,
40
+ // tests, any tier not yet seeded -- get an inert client rather than a broken one, so the error
41
+ // boundary still behaves exactly as it does in production.
42
+ enabled: accessToken.length > 0,
43
+ environment: chunkX4YCRWXO_cjs.getRuntimeEnv("BLOCKS_ROLLBAR_ENV") || "unknown",
44
+ captureUncaught: true,
45
+ captureUnhandledRejections: true,
46
+ scrubFields: [...DEFAULT_SCRUB_FIELDS, ...options.extraScrubFields ?? []],
47
+ ignoredMessages: [
48
+ ...DEFAULT_IGNORED_MESSAGES,
49
+ ...options.extraIgnoredMessages ?? []
50
+ ],
51
+ payload: {
52
+ // `service` identifies the app, `component` which half of it. Two fields rather than one
53
+ // `blocks-os-client` string, so either can be filtered on without parsing.
54
+ service: options.service,
55
+ component: "client",
56
+ client: {
57
+ javascript: {
58
+ source_map_enabled: Boolean(options.codeVersion),
59
+ code_version: options.codeVersion
60
+ }
61
+ }
62
+ }
63
+ };
64
+ };
65
+
66
+ // src/observability/report-query-errors.ts
67
+ var attachQueryErrorReporting = (queryClient, rollbar) => {
68
+ const report = (error, context) => {
69
+ if (error instanceof chunkX4YCRWXO_cjs.HttpError) return;
70
+ if (typeof error?.status === "number") return;
71
+ rollbar.error(error instanceof Error ? error : new Error(String(error)), {
72
+ source: "react-query",
73
+ ...context
74
+ });
75
+ };
76
+ const unsubscribeQueries = queryClient.getQueryCache().subscribe((event) => {
77
+ if (event.type !== "updated" || event.action.type !== "error") return;
78
+ report(event.action.error, {
79
+ kind: "query",
80
+ queryHash: event.query.queryHash
81
+ });
82
+ });
83
+ const unsubscribeMutations = queryClient.getMutationCache().subscribe((event) => {
84
+ if (event.type !== "updated" || event.action.type !== "error") return;
85
+ report(event.action.error, {
86
+ kind: "mutation",
87
+ mutationKey: event.mutation.options.mutationKey
88
+ });
89
+ });
90
+ return () => {
91
+ unsubscribeQueries();
92
+ unsubscribeMutations();
93
+ };
94
+ };
95
+ var DefaultFallback = ({ resetError }) => /* @__PURE__ */ jsxRuntime.jsxs(
96
+ "div",
97
+ {
98
+ className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
99
+ role: "alert",
100
+ children: [
101
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
102
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-semibold text-foreground", children: "Something went wrong" }),
103
+ /* @__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." })
104
+ ] }),
105
+ /* @__PURE__ */ jsxRuntime.jsx(
106
+ "button",
107
+ {
108
+ onClick: resetError,
109
+ className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
110
+ children: "Try again"
111
+ }
112
+ )
113
+ ]
114
+ }
115
+ );
116
+ var RollbarProvider = ({
117
+ children,
118
+ fallback = DefaultFallback,
119
+ ...configOptions
120
+ }) => {
121
+ const rollbar = react.useMemo(
122
+ () => new Rollbar2__default.default(createRollbarConfig(configOptions)),
123
+ // eslint-disable-next-line react-hooks/exhaustive-deps
124
+ []
125
+ );
126
+ react.useEffect(
127
+ () => attachQueryErrorReporting(chunkF2LXD7RI_cjs.getQueryClient(), rollbar),
128
+ [rollbar]
129
+ );
130
+ return /* @__PURE__ */ jsxRuntime.jsx(react$1.Provider, { instance: rollbar, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.ErrorBoundary, { fallbackUI: fallback, level: "critical", children }) });
131
+ };
132
+
133
+ // src/observability/report-http-errors.ts
134
+ var createHttpFailureReporter = (rollbar) => (failure) => {
135
+ if (!failure.transport) return;
136
+ const error = failure.error instanceof Error ? failure.error : new Error(String(failure.error));
137
+ rollbar.error(error, {
138
+ source: "http-client",
139
+ url: failure.url,
140
+ method: failure.method
141
+ });
142
+ };
143
+
144
+ exports.RollbarProvider = RollbarProvider;
145
+ exports.attachQueryErrorReporting = attachQueryErrorReporting;
146
+ exports.createHttpFailureReporter = createHttpFailureReporter;
147
+ exports.createRollbarConfig = createRollbarConfig;
148
+ //# sourceMappingURL=index.cjs.map
149
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/observability/rollbar.config.ts","../../src/observability/report-query-errors.ts","../../src/observability/rollbar.provider.tsx","../../src/observability/report-http-errors.ts"],"names":["getRuntimeEnv","Http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ACtEO,IAAM,yBAAA,GACX,CAAC,OAAA,KACD,CAAC,OAAA,KAAsC;AACrC,EAAA,IAAI,CAAC,QAAQ,SAAA,EAAW;AAExB,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":["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\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,\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 // `service` identifies the app, `component` which half of it. Two fields rather than one\n // `blocks-os-client` string, so either can be filtered on without parsing.\n service: options.service,\n component: \"client\",\n client: {\n javascript: {\n source_map_enabled: Boolean(options.codeVersion),\n code_version: options.codeVersion,\n },\n },\n },\n };\n};\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 Rollbar from \"rollbar\";\nimport { useEffect, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport { getQueryClient } from \"@/providers/query-client\";\nimport { attachQueryErrorReporting } from \"./report-query-errors\";\nimport {\n createRollbarConfig,\n type RollbarConfigOptions,\n} from \"./rollbar.config\";\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 // One instance for the life of the app. Reconstructing it on re-render would reinstall the\n // window handlers and lose Rollbar's own telemetry buffer.\n const rollbar = useMemo(\n () => new Rollbar(createRollbarConfig(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"]}
@@ -0,0 +1,83 @@
1
+ import Rollbar from 'rollbar';
2
+ import * as React from 'react';
3
+ import { ReactNode, ComponentType } from 'react';
4
+ import { d as HttpRequestFailure } from '../types-CxmwyESB.cjs';
5
+ import { QueryClient } from '@tanstack/react-query';
6
+ import '../auth.model-BHLqtZG5.cjs';
7
+ import '../user.model-D-yeFp-2.cjs';
8
+ import '../base.types-XgGxHPNY.cjs';
9
+
10
+ interface RollbarConfigOptions {
11
+ /**
12
+ * The app reporting, e.g. `"blocks-os"`. Pass the same name the app already gives
13
+ * `BlocksAppLayout`, so items can be traced back to a service without a project-id lookup.
14
+ */
15
+ service: string;
16
+ /** Appended to, not replacing, the platform scrub list. */
17
+ extraScrubFields?: string[];
18
+ /** Appended to, not replacing, the default ignore list. */
19
+ extraIgnoredMessages?: string[];
20
+ /** Identifies the build. Required for source-map deobfuscation once maps are uploaded. */
21
+ codeVersion?: string;
22
+ }
23
+ /**
24
+ * Builds the browser Rollbar configuration from runtime env.
25
+ *
26
+ * Separate from the provider so it can be asserted on directly: most of the risk in this module is
27
+ * in the configuration -- scrubbing, and whether reporting is on at all -- not in Rollbar itself.
28
+ */
29
+ declare const createRollbarConfig: (options: RollbarConfigOptions) => Rollbar.Configuration;
30
+
31
+ interface RollbarFallbackProps {
32
+ error: Error | null;
33
+ resetError: () => void;
34
+ }
35
+ interface RollbarProviderProps extends RollbarConfigOptions {
36
+ children: ReactNode;
37
+ /** Replaces the built-in crash screen. */
38
+ fallback?: ComponentType<RollbarFallbackProps>;
39
+ }
40
+ /**
41
+ * Puts Rollbar in front of the whole tree.
42
+ *
43
+ * Mount this outermost -- above the query, theme and router providers -- so a throw during their
44
+ * own setup is still caught and reported rather than blanking the page.
45
+ *
46
+ * Reporting is inert until a client token is seeded (see `createRollbarConfig`), but the boundary is
47
+ * always live, so the crash screen behaves identically in local development and in production.
48
+ *
49
+ * Covers uncaught errors, unhandled rejections, render crashes, and bugs thrown inside query
50
+ * functions. Request failures are not covered here: pass `createHttpFailureReporter` to your
51
+ * `HttpClient` as `onError` for those.
52
+ */
53
+ declare const RollbarProvider: ({ children, fallback, ...configOptions }: RollbarProviderProps) => React.JSX.Element;
54
+
55
+ /**
56
+ * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures.
57
+ *
58
+ * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the
59
+ * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,
60
+ * so reporting it again from the browser only buries the better item. What is left -- the API
61
+ * unreachable, DNS, CORS, TLS, offline -- the server cannot report by definition, because it never
62
+ * received the request.
63
+ *
64
+ * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so
65
+ * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out
66
+ * cannot tell the two apart.
67
+ */
68
+ declare const createHttpFailureReporter: (rollbar: Rollbar) => (failure: HttpRequestFailure) => void;
69
+
70
+ /**
71
+ * Reports errors thrown inside query and mutation functions that are not request failures.
72
+ *
73
+ * Narrow on purpose. Every failure from `HttpClient` arrives as an `HttpError` and is skipped here:
74
+ * transport failures are already handled by `createHttpFailureReporter`, and HTTP statuses are
75
+ * either business outcomes or faults the server reported itself. What remains is a genuine bug in a
76
+ * query function -- a bad mapping, a null dereference on a response -- which React Query catches
77
+ * and stores as query state, so it never reaches `window.onerror` and would otherwise be invisible.
78
+ *
79
+ * Returns an unsubscribe function.
80
+ */
81
+ declare const attachQueryErrorReporting: (queryClient: QueryClient, rollbar: Rollbar) => (() => void);
82
+
83
+ export { type RollbarConfigOptions, type RollbarFallbackProps, RollbarProvider, type RollbarProviderProps, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig };
@@ -0,0 +1,83 @@
1
+ import Rollbar from 'rollbar';
2
+ import * as React from 'react';
3
+ import { ReactNode, ComponentType } from 'react';
4
+ import { d as HttpRequestFailure } from '../types-R-boAdbM.js';
5
+ import { QueryClient } from '@tanstack/react-query';
6
+ import '../auth.model-6We_OkEZ.js';
7
+ import '../user.model-jYC7Cd3G.js';
8
+ import '../base.types-XgGxHPNY.js';
9
+
10
+ interface RollbarConfigOptions {
11
+ /**
12
+ * The app reporting, e.g. `"blocks-os"`. Pass the same name the app already gives
13
+ * `BlocksAppLayout`, so items can be traced back to a service without a project-id lookup.
14
+ */
15
+ service: string;
16
+ /** Appended to, not replacing, the platform scrub list. */
17
+ extraScrubFields?: string[];
18
+ /** Appended to, not replacing, the default ignore list. */
19
+ extraIgnoredMessages?: string[];
20
+ /** Identifies the build. Required for source-map deobfuscation once maps are uploaded. */
21
+ codeVersion?: string;
22
+ }
23
+ /**
24
+ * Builds the browser Rollbar configuration from runtime env.
25
+ *
26
+ * Separate from the provider so it can be asserted on directly: most of the risk in this module is
27
+ * in the configuration -- scrubbing, and whether reporting is on at all -- not in Rollbar itself.
28
+ */
29
+ declare const createRollbarConfig: (options: RollbarConfigOptions) => Rollbar.Configuration;
30
+
31
+ interface RollbarFallbackProps {
32
+ error: Error | null;
33
+ resetError: () => void;
34
+ }
35
+ interface RollbarProviderProps extends RollbarConfigOptions {
36
+ children: ReactNode;
37
+ /** Replaces the built-in crash screen. */
38
+ fallback?: ComponentType<RollbarFallbackProps>;
39
+ }
40
+ /**
41
+ * Puts Rollbar in front of the whole tree.
42
+ *
43
+ * Mount this outermost -- above the query, theme and router providers -- so a throw during their
44
+ * own setup is still caught and reported rather than blanking the page.
45
+ *
46
+ * Reporting is inert until a client token is seeded (see `createRollbarConfig`), but the boundary is
47
+ * always live, so the crash screen behaves identically in local development and in production.
48
+ *
49
+ * Covers uncaught errors, unhandled rejections, render crashes, and bugs thrown inside query
50
+ * functions. Request failures are not covered here: pass `createHttpFailureReporter` to your
51
+ * `HttpClient` as `onError` for those.
52
+ */
53
+ declare const RollbarProvider: ({ children, fallback, ...configOptions }: RollbarProviderProps) => React.JSX.Element;
54
+
55
+ /**
56
+ * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures.
57
+ *
58
+ * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the
59
+ * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,
60
+ * so reporting it again from the browser only buries the better item. What is left -- the API
61
+ * unreachable, DNS, CORS, TLS, offline -- the server cannot report by definition, because it never
62
+ * received the request.
63
+ *
64
+ * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so
65
+ * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out
66
+ * cannot tell the two apart.
67
+ */
68
+ declare const createHttpFailureReporter: (rollbar: Rollbar) => (failure: HttpRequestFailure) => void;
69
+
70
+ /**
71
+ * Reports errors thrown inside query and mutation functions that are not request failures.
72
+ *
73
+ * Narrow on purpose. Every failure from `HttpClient` arrives as an `HttpError` and is skipped here:
74
+ * transport failures are already handled by `createHttpFailureReporter`, and HTTP statuses are
75
+ * either business outcomes or faults the server reported itself. What remains is a genuine bug in a
76
+ * query function -- a bad mapping, a null dereference on a response -- which React Query catches
77
+ * and stores as query state, so it never reaches `window.onerror` and would otherwise be invisible.
78
+ *
79
+ * Returns an unsubscribe function.
80
+ */
81
+ declare const attachQueryErrorReporting: (queryClient: QueryClient, rollbar: Rollbar) => (() => void);
82
+
83
+ export { type RollbarConfigOptions, type RollbarFallbackProps, RollbarProvider, type RollbarProviderProps, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig };
@@ -0,0 +1,140 @@
1
+ import { getRuntimeEnv, HttpError } from '../chunk-JUVLHPQI.js';
2
+ import { getQueryClient } from '../chunk-BRHE44FE.js';
3
+ import '../chunk-PL4HS6R6.js';
4
+ import Rollbar2 from 'rollbar';
5
+ import { Provider, ErrorBoundary } from '@rollbar/react';
6
+ import { useMemo, useEffect } from 'react';
7
+ import { jsx, jsxs } from 'react/jsx-runtime';
8
+
9
+ var DEFAULT_SCRUB_FIELDS = [
10
+ "x-blocks-key",
11
+ "X-Blocks-Key",
12
+ "Authorization",
13
+ "authorization",
14
+ "access_token",
15
+ "refresh_token",
16
+ "accessToken",
17
+ "refreshToken",
18
+ "password",
19
+ "clientSecret",
20
+ "client_secret",
21
+ "connectionString",
22
+ "secretValue"
23
+ ];
24
+ var DEFAULT_IGNORED_MESSAGES = [
25
+ "ResizeObserver loop limit exceeded",
26
+ "ResizeObserver loop completed with undelivered notifications",
27
+ "Script error."
28
+ ];
29
+ var createRollbarConfig = (options) => {
30
+ const accessToken = getRuntimeEnv("BLOCKS_ROLLBAR_CLIENT_TOKEN");
31
+ return {
32
+ accessToken,
33
+ // Reporting is opt-in on a seeded token. Unconfigured environments -- developer machines,
34
+ // tests, any tier not yet seeded -- get an inert client rather than a broken one, so the error
35
+ // boundary still behaves exactly as it does in production.
36
+ enabled: accessToken.length > 0,
37
+ environment: getRuntimeEnv("BLOCKS_ROLLBAR_ENV") || "unknown",
38
+ captureUncaught: true,
39
+ captureUnhandledRejections: true,
40
+ scrubFields: [...DEFAULT_SCRUB_FIELDS, ...options.extraScrubFields ?? []],
41
+ ignoredMessages: [
42
+ ...DEFAULT_IGNORED_MESSAGES,
43
+ ...options.extraIgnoredMessages ?? []
44
+ ],
45
+ payload: {
46
+ // `service` identifies the app, `component` which half of it. Two fields rather than one
47
+ // `blocks-os-client` string, so either can be filtered on without parsing.
48
+ service: options.service,
49
+ component: "client",
50
+ client: {
51
+ javascript: {
52
+ source_map_enabled: Boolean(options.codeVersion),
53
+ code_version: options.codeVersion
54
+ }
55
+ }
56
+ }
57
+ };
58
+ };
59
+
60
+ // src/observability/report-query-errors.ts
61
+ var attachQueryErrorReporting = (queryClient, rollbar) => {
62
+ const report = (error, context) => {
63
+ if (error instanceof HttpError) return;
64
+ if (typeof error?.status === "number") return;
65
+ rollbar.error(error instanceof Error ? error : new Error(String(error)), {
66
+ source: "react-query",
67
+ ...context
68
+ });
69
+ };
70
+ const unsubscribeQueries = queryClient.getQueryCache().subscribe((event) => {
71
+ if (event.type !== "updated" || event.action.type !== "error") return;
72
+ report(event.action.error, {
73
+ kind: "query",
74
+ queryHash: event.query.queryHash
75
+ });
76
+ });
77
+ const unsubscribeMutations = queryClient.getMutationCache().subscribe((event) => {
78
+ if (event.type !== "updated" || event.action.type !== "error") return;
79
+ report(event.action.error, {
80
+ kind: "mutation",
81
+ mutationKey: event.mutation.options.mutationKey
82
+ });
83
+ });
84
+ return () => {
85
+ unsubscribeQueries();
86
+ unsubscribeMutations();
87
+ };
88
+ };
89
+ var DefaultFallback = ({ resetError }) => /* @__PURE__ */ jsxs(
90
+ "div",
91
+ {
92
+ className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
93
+ role: "alert",
94
+ children: [
95
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
96
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold text-foreground", children: "Something went wrong" }),
97
+ /* @__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." })
98
+ ] }),
99
+ /* @__PURE__ */ jsx(
100
+ "button",
101
+ {
102
+ onClick: resetError,
103
+ className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
104
+ children: "Try again"
105
+ }
106
+ )
107
+ ]
108
+ }
109
+ );
110
+ var RollbarProvider = ({
111
+ children,
112
+ fallback = DefaultFallback,
113
+ ...configOptions
114
+ }) => {
115
+ const rollbar = useMemo(
116
+ () => new Rollbar2(createRollbarConfig(configOptions)),
117
+ // eslint-disable-next-line react-hooks/exhaustive-deps
118
+ []
119
+ );
120
+ useEffect(
121
+ () => attachQueryErrorReporting(getQueryClient(), rollbar),
122
+ [rollbar]
123
+ );
124
+ return /* @__PURE__ */ jsx(Provider, { instance: rollbar, children: /* @__PURE__ */ jsx(ErrorBoundary, { fallbackUI: fallback, level: "critical", children }) });
125
+ };
126
+
127
+ // src/observability/report-http-errors.ts
128
+ var createHttpFailureReporter = (rollbar) => (failure) => {
129
+ if (!failure.transport) return;
130
+ const error = failure.error instanceof Error ? failure.error : new Error(String(failure.error));
131
+ rollbar.error(error, {
132
+ source: "http-client",
133
+ url: failure.url,
134
+ method: failure.method
135
+ });
136
+ };
137
+
138
+ export { RollbarProvider, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig };
139
+ //# sourceMappingURL=index.js.map
140
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/observability/rollbar.config.ts","../../src/observability/report-query-errors.ts","../../src/observability/rollbar.provider.tsx","../../src/observability/report-http-errors.ts"],"names":["Rollbar"],"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;AAsBO,IAAM,mBAAA,GAAsB,CACjC,OAAA,KAC0B;AAC1B,EAAA,MAAM,WAAA,GAAc,cAAc,6BAA6B,CAAA;AAE/D,EAAA,OAAO;AAAA,IACL,WAAA;AAAA;AAAA;AAAA;AAAA,IAIA,OAAA,EAAS,YAAY,MAAA,GAAS,CAAA;AAAA,IAC9B,WAAA,EAAa,aAAA,CAAc,oBAAoB,CAAA,IAAK,SAAA;AAAA,IACpD,eAAA,EAAiB,IAAA;AAAA,IACjB,0BAAA,EAA4B,IAAA;AAAA,IAC5B,WAAA,EAAa,CAAC,GAAG,oBAAA,EAAsB,GAAI,OAAA,CAAQ,gBAAA,IAAoB,EAAG,CAAA;AAAA,IAC1E,eAAA,EAAiB;AAAA,MACf,GAAG,wBAAA;AAAA,MACH,GAAI,OAAA,CAAQ,oBAAA,IAAwB;AAAC,KACvC;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AAG,OAAO,CAAA;AAAA,IACzD,CAAC,OAAO;AAAA,GACV;AAEA,EAAA,uBACE,GAAA,CAAC,QAAA,EAAA,EAAS,QAAA,EAAU,OAAA,EAClB,QAAA,kBAAA,GAAA,CAAC,aAAA,EAAA,EAAc,UAAA,EAAY,QAAA,EAAU,KAAA,EAAM,UAAA,EACxC,QAAA,EACH,CAAA,EACF,CAAA;AAEJ;;;ACtEO,IAAM,yBAAA,GACX,CAAC,OAAA,KACD,CAAC,OAAA,KAAsC;AACrC,EAAA,IAAI,CAAC,QAAQ,SAAA,EAAW;AAExB,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.js","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\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,\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 // `service` identifies the app, `component` which half of it. Two fields rather than one\n // `blocks-os-client` string, so either can be filtered on without parsing.\n service: options.service,\n component: \"client\",\n client: {\n javascript: {\n source_map_enabled: Boolean(options.codeVersion),\n code_version: options.codeVersion,\n },\n },\n },\n };\n};\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 Rollbar from \"rollbar\";\nimport { useEffect, useMemo, type ComponentType, type ReactNode } from \"react\";\nimport { getQueryClient } from \"@/providers/query-client\";\nimport { attachQueryErrorReporting } from \"./report-query-errors\";\nimport {\n createRollbarConfig,\n type RollbarConfigOptions,\n} from \"./rollbar.config\";\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 // One instance for the life of the app. Reconstructing it on re-render would reinstall the\n // window handlers and lose Rollbar's own telemetry buffer.\n const rollbar = useMemo(\n () => new Rollbar(createRollbarConfig(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"]}