@seliseblocks/genesis-os 4.2.6 → 4.2.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 (120) 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-GDMLW2TT.js → chunk-5D4AQMX5.js} +11 -9
  12. package/dist/chunk-5D4AQMX5.js.map +1 -0
  13. package/dist/{chunk-QKZZDZ4S.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-CZPJCY4W.cjs → chunk-J7P4N4JM.cjs} +404 -402
  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-3Y2K7E6P.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 +1 -1
  57. package/dist/components/index.d.ts +1 -1
  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 +3 -3
  63. package/dist/hooks/index.d.ts +3 -3
  64. package/dist/hooks/index.js +6 -4
  65. package/dist/index.cjs +561 -559
  66. package/dist/index.d.cts +5 -4
  67. package/dist/index.d.ts +5 -4
  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 +152 -0
  80. package/dist/observability/index.cjs.map +1 -0
  81. package/dist/observability/index.d.cts +98 -0
  82. package/dist/observability/index.d.ts +98 -0
  83. package/dist/observability/index.js +142 -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/utils/index.cjs +73 -71
  100. package/dist/utils/index.d.cts +1 -1
  101. package/dist/utils/index.d.ts +1 -1
  102. package/dist/utils/index.js +5 -3
  103. package/package.json +8 -1
  104. package/dist/all-D22OCWSN.cjs.map +0 -1
  105. package/dist/all-TUOS2F7K.js.map +0 -1
  106. package/dist/chunk-3Y2K7E6P.js.map +0 -1
  107. package/dist/chunk-575VJQ2U.js.map +0 -1
  108. package/dist/chunk-7EFD3LDX.js.map +0 -1
  109. package/dist/chunk-CZPJCY4W.cjs.map +0 -1
  110. package/dist/chunk-GDMLW2TT.js.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-QKZZDZ4S.cjs.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-SDWR3F3Y.cjs.map +0 -1
  118. package/dist/chunk-U3WXD3OX.cjs.map +0 -1
  119. package/dist/chunk-WPTHBDJO.js.map +0 -1
  120. package/dist/javadoc-ZLZVKQJ6.cjs +0 -14
@@ -0,0 +1,152 @@
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
+ var instance;
66
+ var getRollbar = (options) => instance ??= new Rollbar2__default.default(createRollbarConfig(options));
67
+
68
+ // src/observability/report-query-errors.ts
69
+ var attachQueryErrorReporting = (queryClient, rollbar) => {
70
+ const report = (error, context) => {
71
+ if (error instanceof chunkX4YCRWXO_cjs.HttpError) return;
72
+ if (typeof error?.status === "number") return;
73
+ rollbar.error(error instanceof Error ? error : new Error(String(error)), {
74
+ source: "react-query",
75
+ ...context
76
+ });
77
+ };
78
+ const unsubscribeQueries = queryClient.getQueryCache().subscribe((event) => {
79
+ if (event.type !== "updated" || event.action.type !== "error") return;
80
+ report(event.action.error, {
81
+ kind: "query",
82
+ queryHash: event.query.queryHash
83
+ });
84
+ });
85
+ const unsubscribeMutations = queryClient.getMutationCache().subscribe((event) => {
86
+ if (event.type !== "updated" || event.action.type !== "error") return;
87
+ report(event.action.error, {
88
+ kind: "mutation",
89
+ mutationKey: event.mutation.options.mutationKey
90
+ });
91
+ });
92
+ return () => {
93
+ unsubscribeQueries();
94
+ unsubscribeMutations();
95
+ };
96
+ };
97
+ var DefaultFallback = ({ resetError }) => /* @__PURE__ */ jsxRuntime.jsxs(
98
+ "div",
99
+ {
100
+ className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
101
+ role: "alert",
102
+ children: [
103
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
104
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-semibold text-foreground", children: "Something went wrong" }),
105
+ /* @__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." })
106
+ ] }),
107
+ /* @__PURE__ */ jsxRuntime.jsx(
108
+ "button",
109
+ {
110
+ onClick: resetError,
111
+ className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
112
+ children: "Try again"
113
+ }
114
+ )
115
+ ]
116
+ }
117
+ );
118
+ var RollbarProvider = ({
119
+ children,
120
+ fallback = DefaultFallback,
121
+ ...configOptions
122
+ }) => {
123
+ const rollbar = react.useMemo(
124
+ () => getRollbar(configOptions),
125
+ // eslint-disable-next-line react-hooks/exhaustive-deps
126
+ []
127
+ );
128
+ react.useEffect(
129
+ () => attachQueryErrorReporting(chunkF2LXD7RI_cjs.getQueryClient(), rollbar),
130
+ [rollbar]
131
+ );
132
+ return /* @__PURE__ */ jsxRuntime.jsx(react$1.Provider, { instance: rollbar, children: /* @__PURE__ */ jsxRuntime.jsx(react$1.ErrorBoundary, { fallbackUI: fallback, level: "critical", children }) });
133
+ };
134
+
135
+ // src/observability/report-http-errors.ts
136
+ var createHttpFailureReporter = (rollbar) => (failure) => {
137
+ if (!failure.transport) return;
138
+ const error = failure.error instanceof Error ? failure.error : new Error(String(failure.error));
139
+ rollbar.error(error, {
140
+ source: "http-client",
141
+ url: failure.url,
142
+ method: failure.method
143
+ });
144
+ };
145
+
146
+ exports.RollbarProvider = RollbarProvider;
147
+ exports.attachQueryErrorReporting = attachQueryErrorReporting;
148
+ exports.createHttpFailureReporter = createHttpFailureReporter;
149
+ exports.createRollbarConfig = createRollbarConfig;
150
+ exports.getRollbar = getRollbar;
151
+ //# sourceMappingURL=index.cjs.map
152
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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"],"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AAA,EACF,CAAA;AAEJ;;;ACpEO,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 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"]}
@@ -0,0 +1,98 @@
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
+ /**
32
+ * The one Rollbar instance for the app.
33
+ *
34
+ * Memoised on first call so that code outside the React tree -- an `HttpClient` built at module
35
+ * scope, for instance -- reports through the same client the provider renders. A second instance
36
+ * would install a second set of window handlers and split the telemetry buffer in two.
37
+ *
38
+ * First call wins: later calls return the existing instance and ignore their options. In practice
39
+ * every call site passes the same service, and load order between a module-scope client and the
40
+ * provider is not something an app should have to reason about.
41
+ *
42
+ * Created lazily, so merely importing this module installs nothing.
43
+ */
44
+ declare const getRollbar: (options: RollbarConfigOptions) => Rollbar;
45
+
46
+ interface RollbarFallbackProps {
47
+ error: Error | null;
48
+ resetError: () => void;
49
+ }
50
+ interface RollbarProviderProps extends RollbarConfigOptions {
51
+ children: ReactNode;
52
+ /** Replaces the built-in crash screen. */
53
+ fallback?: ComponentType<RollbarFallbackProps>;
54
+ }
55
+ /**
56
+ * Puts Rollbar in front of the whole tree.
57
+ *
58
+ * Mount this outermost -- above the query, theme and router providers -- so a throw during their
59
+ * own setup is still caught and reported rather than blanking the page.
60
+ *
61
+ * Reporting is inert until a client token is seeded (see `createRollbarConfig`), but the boundary is
62
+ * always live, so the crash screen behaves identically in local development and in production.
63
+ *
64
+ * Covers uncaught errors, unhandled rejections, render crashes, and bugs thrown inside query
65
+ * functions. Request failures are not covered here: pass `createHttpFailureReporter` to your
66
+ * `HttpClient` as `onError` for those.
67
+ */
68
+ declare const RollbarProvider: ({ children, fallback, ...configOptions }: RollbarProviderProps) => React.JSX.Element;
69
+
70
+ /**
71
+ * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures.
72
+ *
73
+ * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the
74
+ * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,
75
+ * so reporting it again from the browser only buries the better item. What is left -- the API
76
+ * unreachable, DNS, CORS, TLS, offline -- the server cannot report by definition, because it never
77
+ * received the request.
78
+ *
79
+ * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so
80
+ * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out
81
+ * cannot tell the two apart.
82
+ */
83
+ declare const createHttpFailureReporter: (rollbar: Rollbar) => (failure: HttpRequestFailure) => void;
84
+
85
+ /**
86
+ * Reports errors thrown inside query and mutation functions that are not request failures.
87
+ *
88
+ * Narrow on purpose. Every failure from `HttpClient` arrives as an `HttpError` and is skipped here:
89
+ * transport failures are already handled by `createHttpFailureReporter`, and HTTP statuses are
90
+ * either business outcomes or faults the server reported itself. What remains is a genuine bug in a
91
+ * query function -- a bad mapping, a null dereference on a response -- which React Query catches
92
+ * and stores as query state, so it never reaches `window.onerror` and would otherwise be invisible.
93
+ *
94
+ * Returns an unsubscribe function.
95
+ */
96
+ declare const attachQueryErrorReporting: (queryClient: QueryClient, rollbar: Rollbar) => (() => void);
97
+
98
+ export { type RollbarConfigOptions, type RollbarFallbackProps, RollbarProvider, type RollbarProviderProps, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig, getRollbar };
@@ -0,0 +1,98 @@
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
+ /**
32
+ * The one Rollbar instance for the app.
33
+ *
34
+ * Memoised on first call so that code outside the React tree -- an `HttpClient` built at module
35
+ * scope, for instance -- reports through the same client the provider renders. A second instance
36
+ * would install a second set of window handlers and split the telemetry buffer in two.
37
+ *
38
+ * First call wins: later calls return the existing instance and ignore their options. In practice
39
+ * every call site passes the same service, and load order between a module-scope client and the
40
+ * provider is not something an app should have to reason about.
41
+ *
42
+ * Created lazily, so merely importing this module installs nothing.
43
+ */
44
+ declare const getRollbar: (options: RollbarConfigOptions) => Rollbar;
45
+
46
+ interface RollbarFallbackProps {
47
+ error: Error | null;
48
+ resetError: () => void;
49
+ }
50
+ interface RollbarProviderProps extends RollbarConfigOptions {
51
+ children: ReactNode;
52
+ /** Replaces the built-in crash screen. */
53
+ fallback?: ComponentType<RollbarFallbackProps>;
54
+ }
55
+ /**
56
+ * Puts Rollbar in front of the whole tree.
57
+ *
58
+ * Mount this outermost -- above the query, theme and router providers -- so a throw during their
59
+ * own setup is still caught and reported rather than blanking the page.
60
+ *
61
+ * Reporting is inert until a client token is seeded (see `createRollbarConfig`), but the boundary is
62
+ * always live, so the crash screen behaves identically in local development and in production.
63
+ *
64
+ * Covers uncaught errors, unhandled rejections, render crashes, and bugs thrown inside query
65
+ * functions. Request failures are not covered here: pass `createHttpFailureReporter` to your
66
+ * `HttpClient` as `onError` for those.
67
+ */
68
+ declare const RollbarProvider: ({ children, fallback, ...configOptions }: RollbarProviderProps) => React.JSX.Element;
69
+
70
+ /**
71
+ * Builds an `onError` handler for `HttpClientConfig` that reports only transport failures.
72
+ *
73
+ * Failures that produced an HTTP response are skipped deliberately: a 4xx is a business outcome the
74
+ * UI already surfaces, and a 5xx has already been reported by the server with a real stack trace,
75
+ * so reporting it again from the browser only buries the better item. What is left -- the API
76
+ * unreachable, DNS, CORS, TLS, offline -- the server cannot report by definition, because it never
77
+ * received the request.
78
+ *
79
+ * `HttpClient` normalises every failure to an `HttpError` with status 500 before callers see it, so
80
+ * this distinction only exists inside the `onError` hook. Reporting from a `catch` further out
81
+ * cannot tell the two apart.
82
+ */
83
+ declare const createHttpFailureReporter: (rollbar: Rollbar) => (failure: HttpRequestFailure) => void;
84
+
85
+ /**
86
+ * Reports errors thrown inside query and mutation functions that are not request failures.
87
+ *
88
+ * Narrow on purpose. Every failure from `HttpClient` arrives as an `HttpError` and is skipped here:
89
+ * transport failures are already handled by `createHttpFailureReporter`, and HTTP statuses are
90
+ * either business outcomes or faults the server reported itself. What remains is a genuine bug in a
91
+ * query function -- a bad mapping, a null dereference on a response -- which React Query catches
92
+ * and stores as query state, so it never reaches `window.onerror` and would otherwise be invisible.
93
+ *
94
+ * Returns an unsubscribe function.
95
+ */
96
+ declare const attachQueryErrorReporting: (queryClient: QueryClient, rollbar: Rollbar) => (() => void);
97
+
98
+ export { type RollbarConfigOptions, type RollbarFallbackProps, RollbarProvider, type RollbarProviderProps, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig, getRollbar };
@@ -0,0 +1,142 @@
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
+ var instance;
60
+ var getRollbar = (options) => instance ??= new Rollbar2(createRollbarConfig(options));
61
+
62
+ // src/observability/report-query-errors.ts
63
+ var attachQueryErrorReporting = (queryClient, rollbar) => {
64
+ const report = (error, context) => {
65
+ if (error instanceof HttpError) return;
66
+ if (typeof error?.status === "number") return;
67
+ rollbar.error(error instanceof Error ? error : new Error(String(error)), {
68
+ source: "react-query",
69
+ ...context
70
+ });
71
+ };
72
+ const unsubscribeQueries = queryClient.getQueryCache().subscribe((event) => {
73
+ if (event.type !== "updated" || event.action.type !== "error") return;
74
+ report(event.action.error, {
75
+ kind: "query",
76
+ queryHash: event.query.queryHash
77
+ });
78
+ });
79
+ const unsubscribeMutations = queryClient.getMutationCache().subscribe((event) => {
80
+ if (event.type !== "updated" || event.action.type !== "error") return;
81
+ report(event.action.error, {
82
+ kind: "mutation",
83
+ mutationKey: event.mutation.options.mutationKey
84
+ });
85
+ });
86
+ return () => {
87
+ unsubscribeQueries();
88
+ unsubscribeMutations();
89
+ };
90
+ };
91
+ var DefaultFallback = ({ resetError }) => /* @__PURE__ */ jsxs(
92
+ "div",
93
+ {
94
+ className: "flex min-h-screen flex-col items-center justify-center gap-4 bg-background px-6 text-center",
95
+ role: "alert",
96
+ children: [
97
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
98
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold text-foreground", children: "Something went wrong" }),
99
+ /* @__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." })
100
+ ] }),
101
+ /* @__PURE__ */ jsx(
102
+ "button",
103
+ {
104
+ onClick: resetError,
105
+ className: "rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground",
106
+ children: "Try again"
107
+ }
108
+ )
109
+ ]
110
+ }
111
+ );
112
+ var RollbarProvider = ({
113
+ children,
114
+ fallback = DefaultFallback,
115
+ ...configOptions
116
+ }) => {
117
+ const rollbar = useMemo(
118
+ () => getRollbar(configOptions),
119
+ // eslint-disable-next-line react-hooks/exhaustive-deps
120
+ []
121
+ );
122
+ useEffect(
123
+ () => attachQueryErrorReporting(getQueryClient(), rollbar),
124
+ [rollbar]
125
+ );
126
+ return /* @__PURE__ */ jsx(Provider, { instance: rollbar, children: /* @__PURE__ */ jsx(ErrorBoundary, { fallbackUI: fallback, level: "critical", children }) });
127
+ };
128
+
129
+ // src/observability/report-http-errors.ts
130
+ var createHttpFailureReporter = (rollbar) => (failure) => {
131
+ if (!failure.transport) return;
132
+ const error = failure.error instanceof Error ? failure.error : new Error(String(failure.error));
133
+ rollbar.error(error, {
134
+ source: "http-client",
135
+ url: failure.url,
136
+ method: failure.method
137
+ });
138
+ };
139
+
140
+ export { RollbarProvider, attachQueryErrorReporting, createHttpFailureReporter, createRollbarConfig, getRollbar };
141
+ //# sourceMappingURL=index.js.map
142
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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":["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;AAAA,IACA,OAAA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,GACH;AAEA,EAAA,SAAA;AAAA,IACE,MAAM,yBAAA,CAA0B,cAAA,EAAe,EAAG,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;;;ACpEO,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 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"]}