@atelic-action/ui 7.2.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +439 -132
  2. package/bin/atelic-check-sentry.ts +5 -0
  3. package/dist/gate/middleware.js +15 -1
  4. package/dist/monitoring/server.d.ts +72 -0
  5. package/dist/monitoring/server.js +201 -0
  6. package/dist/vite/index.d.ts +1 -1
  7. package/dist/vite/index.js +1 -1
  8. package/dist/vite/marketing-config.d.ts +28 -1
  9. package/dist/vite/marketing-config.js +62 -0
  10. package/package.json +23 -11
  11. package/src/app/ErrorFallback.tsx +6 -2
  12. package/src/app/context/AppContext.tsx +10 -1
  13. package/src/app/index.ts +0 -1
  14. package/src/app/layout/AppPage.tsx +36 -7
  15. package/src/app/layout/DesktopRail.tsx +15 -6
  16. package/src/app/layout/MobileMenu.tsx +14 -5
  17. package/src/app/layout/MobileTabBar.tsx +3 -2
  18. package/src/app/layout/PageError.tsx +7 -4
  19. package/src/app/layout/PageSkeleton.tsx +33 -26
  20. package/src/app/layout/SectionCards.tsx +7 -2
  21. package/src/app/layout/UserMenu.tsx +13 -7
  22. package/src/app/ui/alert.tsx +42 -12
  23. package/src/app/ui/badge.tsx +1 -1
  24. package/src/app/ui/button.tsx +2 -1
  25. package/src/app/ui/command.tsx +86 -21
  26. package/src/app/ui/country-dropdown.tsx +26 -47
  27. package/src/app/ui/form.tsx +48 -9
  28. package/src/app/ui/pagination.tsx +1 -1
  29. package/src/app/ui/progress.tsx +26 -12
  30. package/src/app/ui/search-input.tsx +16 -3
  31. package/src/app/ui/select.tsx +8 -3
  32. package/src/app/ui/slider.tsx +62 -15
  33. package/src/artifact/AppErrorBoundary.tsx +12 -7
  34. package/src/artifact/ArtifactShell.tsx +5 -1
  35. package/src/artifact/ErrorFallback.tsx +8 -1
  36. package/src/artifact/artifactConfig.ts +1 -1
  37. package/src/chrome/BrandLockup.tsx +102 -17
  38. package/src/chrome/ClosingBar.tsx +5 -3
  39. package/src/chrome/ContactDock.tsx +361 -0
  40. package/src/chrome/Footer.tsx +126 -31
  41. package/src/chrome/NavBadge.tsx +8 -0
  42. package/src/chrome/NavMegaPanel.tsx +399 -0
  43. package/src/chrome/SiteHeader.tsx +268 -23
  44. package/src/chrome/SiteMenu.tsx +200 -19
  45. package/src/chrome/SiteShell.tsx +151 -14
  46. package/src/chrome/StickyCTABar.tsx +60 -2
  47. package/src/chrome/brandMark.ts +56 -0
  48. package/src/chrome/icons.ts +58 -0
  49. package/src/chrome/index.ts +16 -0
  50. package/src/chrome/navSections.ts +55 -0
  51. package/src/components/ColumnChart.tsx +27 -2
  52. package/src/components/DataTable.tsx +104 -85
  53. package/src/components/Disclosure.tsx +3 -1
  54. package/src/components/Hint.tsx +3 -24
  55. package/src/components/NotFound.tsx +7 -3
  56. package/src/components/StarRating.tsx +45 -19
  57. package/src/components/ThresholdScale.tsx +36 -26
  58. package/src/email/atoms.tsx +13 -57
  59. package/src/email/frame.tsx +4 -6
  60. package/src/email/index.ts +4 -10
  61. package/src/email/scoreboard.tsx +107 -186
  62. package/src/email/text.ts +30 -0
  63. package/src/email/theme.tsx +76 -9
  64. package/src/gate/middleware.ts +15 -1
  65. package/src/hooks/useDismiss.ts +39 -0
  66. package/src/lib/emailText.tsx +26 -0
  67. package/src/lib/phoneText.tsx +40 -0
  68. package/src/lib/useScrollsSideways.ts +26 -0
  69. package/src/monitoring/ErrorCatcherScript.tsx +15 -0
  70. package/src/monitoring/catcher.ts +118 -0
  71. package/src/monitoring/index.ts +25 -0
  72. package/src/monitoring/sdk.ts +112 -0
  73. package/src/monitoring/server.ts +244 -0
  74. package/src/monitoring/start.ts +118 -0
  75. package/src/primitives/Button.tsx +5 -1
  76. package/src/primitives/Eyebrow.tsx +6 -2
  77. package/src/primitives/ProseBlocks.tsx +6 -1
  78. package/src/primitives/SectionHeading.tsx +3 -1
  79. package/src/primitives/StarRow.tsx +23 -8
  80. package/src/routing/index.ts +1 -0
  81. package/src/routing/miss.ts +32 -0
  82. package/src/scripts/check-sentry.ts +77 -0
  83. package/src/sections/BlogIndex.tsx +17 -3
  84. package/src/sections/BlogPost.tsx +10 -1
  85. package/src/sections/CTASection.tsx +2 -2
  86. package/src/sections/CalloutPanel.tsx +34 -0
  87. package/src/sections/ComparisonTable.tsx +23 -2
  88. package/src/sections/ContactForm.tsx +61 -17
  89. package/src/sections/FAQBrowser.tsx +11 -2
  90. package/src/sections/FeatureGrid.tsx +6 -2
  91. package/src/sections/FullBleedVideo.tsx +167 -0
  92. package/src/sections/Gallery.tsx +6 -4
  93. package/src/sections/Hero.tsx +70 -39
  94. package/src/sections/JumpRail.tsx +7 -0
  95. package/src/sections/LegalPage.tsx +10 -2
  96. package/src/sections/LinkColumns.tsx +80 -0
  97. package/src/sections/LocationSection.tsx +28 -5
  98. package/src/sections/Locations.tsx +18 -5
  99. package/src/sections/LogoMarquee.tsx +43 -11
  100. package/src/sections/MapEmbed.tsx +13 -9
  101. package/src/sections/PageHero.tsx +16 -2
  102. package/src/sections/ProcessSteps.tsx +27 -4
  103. package/src/sections/ProfileCards.tsx +12 -2
  104. package/src/sections/ProofStrip.tsx +44 -0
  105. package/src/sections/RevealSlider.tsx +28 -7
  106. package/src/sections/ReviewCarousel.tsx +17 -4
  107. package/src/sections/ReviewWall.tsx +2 -2
  108. package/src/sections/SplitSection.tsx +2 -1
  109. package/src/sections/index.ts +15 -6
  110. package/src/sections/siteConfig.ts +101 -8
  111. package/src/styles/app.css +33 -2
  112. package/src/styles/artifact.css +20 -8
  113. package/src/styles/base.css +68 -13
  114. package/src/styles/chrome.css +1134 -56
  115. package/src/styles/components.css +104 -65
  116. package/src/styles/defaults.css +140 -0
  117. package/src/styles/gate.css +21 -10
  118. package/src/styles/primitives.css +108 -39
  119. package/src/styles/sections.css +500 -437
  120. package/src/styles/star-rating.css +1 -4
  121. package/src/tokens/palettes.ts +24 -4
  122. package/src/types.ts +220 -3
  123. package/src/vite/index.ts +4 -0
  124. package/src/vite/marketing-config.ts +81 -1
  125. package/src/app/CardErrorBoundary.tsx +0 -39
  126. package/src/sections/CTABanner.tsx +0 -93
  127. package/src/sections/DeviceShowcase.tsx +0 -39
  128. package/src/sections/MediaBand.tsx +0 -20
  129. package/src/sections/MenuList.tsx +0 -44
  130. package/src/sections/PressQuotes.tsx +0 -51
  131. package/src/sections/SocialStrip.tsx +0 -83
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bun
2
+ // atelic-check-sentry: fails a production build that would ship without a Sentry DSN.
3
+ import { main } from "../src/scripts/check-sentry";
4
+
5
+ main();
@@ -29,6 +29,7 @@
29
29
  * open file of its own passes `open`; one whose matcher already leaves its
30
30
  * open paths out may still pass its own `needsSession`, which wins over both.
31
31
  */
32
+ import { reportServerError } from "../monitoring/server.js";
32
33
  import { isAllowed } from "./config.js";
33
34
  import { verifyToken } from "./tokens.js";
34
35
  import { createNeedsSession } from "./wall.js";
@@ -45,7 +46,7 @@ function readCookie(header, name) {
45
46
  }
46
47
  export function createMiddleware(options = {}) {
47
48
  const needsSession = options.needsSession ?? createNeedsSession(options.open);
48
- return async function middleware(request) {
49
+ async function decide(request) {
49
50
  const secret = process.env.GATE_SESSION_SECRET;
50
51
  if (!secret)
51
52
  return; // gate off, let everything through
@@ -60,6 +61,19 @@ export function createMiddleware(options = {}) {
60
61
  const login = new URL("/login", url.origin);
61
62
  login.searchParams.set("next", url.pathname + url.search);
62
63
  return Response.redirect(login.toString(), 302);
64
+ }
65
+ // A throw is reported to Sentry (when a DSN is set) and thrown again, so
66
+ // the request fails exactly as it did; a pass and a block are untouched.
67
+ // The expected misses (a malformed cookie, a token that fails to verify)
68
+ // are answers, not errors, and stay quiet.
69
+ return async function middleware(request) {
70
+ try {
71
+ return await decide(request);
72
+ }
73
+ catch (error) {
74
+ await reportServerError(error, { request, tags: { source: "middleware" } });
75
+ throw error;
76
+ }
63
77
  };
64
78
  }
65
79
  export default createMiddleware();
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Error reporting on the server: a dependency free Sentry reporter for a
3
+ * Vercel function or middleware. Built to dist/ with the gate (CLAUDE.md,
4
+ * the built corner), since Vercel runs a function's package imports as
5
+ * shipped, so this file imports nothing and touches only what a function and
6
+ * the middleware runtime both have (fetch, `AbortController`, `crypto`).
7
+ *
8
+ * import { reportServerError, withErrorReporting } from "@atelic-action/ui/monitoring/server";
9
+ *
10
+ * Privacy: a report carries the request's method and path, and its user
11
+ * agent, never its body, its query string, or any other header. A contact
12
+ * form's request holds a person's name, address, and message.
13
+ */
14
+ /** The parts of a DSN a report is sent with. */
15
+ export interface ParsedDSN {
16
+ /** The public key, sent as `sentry_key`. */
17
+ key: string;
18
+ projectId: string;
19
+ /** Where the envelope is posted. */
20
+ envelopeURL: string;
21
+ }
22
+ export interface ServerReportOptions {
23
+ /** Defaults to `SENTRY_DSN`, then `VITE_SENTRY_DSN`, from the environment. */
24
+ dsn?: string;
25
+ /** The request being handled; only its method, path, and user agent are read. */
26
+ request?: Request;
27
+ /** Tags beside the runtime's, e.g. `{ route: "contact" }`. */
28
+ tags?: Record<string, string>;
29
+ /** Defaults to `VERCEL_GIT_COMMIT_SHA`. */
30
+ release?: string;
31
+ /** Defaults to `VERCEL_ENV`. */
32
+ environment?: string;
33
+ /** How long the send may take, in milliseconds. Defaults to 2000. */
34
+ timeoutMs?: number;
35
+ }
36
+ /** One stack frame in Sentry's exception format. */
37
+ export interface SentryFrame {
38
+ function?: string;
39
+ filename?: string;
40
+ lineno?: number;
41
+ colno?: number;
42
+ in_app: boolean;
43
+ }
44
+ /**
45
+ * Reads a DSN (`https://<key>@<host>[/<path>]/<project>`) into the URL its
46
+ * envelopes are posted to. Undefined for anything that is not one.
47
+ */
48
+ export declare function parseDSN(dsn: string | undefined): ParsedDSN | undefined;
49
+ /**
50
+ * The frames of a V8 stack (`at fn (file:line:col)`, `at file:line:col`),
51
+ * oldest call first, as Sentry lists them. A frame inside `node_modules` is
52
+ * not the site's own code.
53
+ */
54
+ export declare function parseStack(stack: string | undefined): SentryFrame[];
55
+ /**
56
+ * The envelope a report is sent as: the envelope header, the item header,
57
+ * and the event, one JSON document to a line. Exported for the tests.
58
+ */
59
+ export declare function buildEnvelope(error: unknown, dsn: string, options?: Omit<ServerReportOptions, "dsn" | "timeoutMs">, now?: Date): string;
60
+ /**
61
+ * Reports an error to Sentry from a function or the middleware. Resolves
62
+ * true when Sentry took it and false otherwise (no DSN, a bad DSN, a failed
63
+ * or slow send), and never throws, so a report can never become a second
64
+ * failure. With no DSN it sends nothing.
65
+ */
66
+ export declare function reportServerError(error: unknown, options?: ServerReportOptions): Promise<boolean>;
67
+ /**
68
+ * Wraps a function's handler so a throw is reported, then thrown again: the
69
+ * platform still answers the request as it would have, and Sentry hears of
70
+ * it first. `export const POST = withErrorReporting(async (request) => ...)`.
71
+ */
72
+ export declare function withErrorReporting<Args extends [Request, ...unknown[]], Result>(handler: (...args: Args) => Result | Promise<Result>, options?: Omit<ServerReportOptions, "request">): (...args: Args) => Promise<Result>;
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Error reporting on the server: a dependency free Sentry reporter for a
3
+ * Vercel function or middleware. Built to dist/ with the gate (CLAUDE.md,
4
+ * the built corner), since Vercel runs a function's package imports as
5
+ * shipped, so this file imports nothing and touches only what a function and
6
+ * the middleware runtime both have (fetch, `AbortController`, `crypto`).
7
+ *
8
+ * import { reportServerError, withErrorReporting } from "@atelic-action/ui/monitoring/server";
9
+ *
10
+ * Privacy: a report carries the request's method and path, and its user
11
+ * agent, never its body, its query string, or any other header. A contact
12
+ * form's request holds a person's name, address, and message.
13
+ */
14
+ const SDK = { name: "atelic.server", version: "1" };
15
+ function environmentValue(name) {
16
+ const env = globalThis.process
17
+ ?.env;
18
+ const value = env?.[name];
19
+ return value === "" ? undefined : value;
20
+ }
21
+ /**
22
+ * Reads a DSN (`https://<key>@<host>[/<path>]/<project>`) into the URL its
23
+ * envelopes are posted to. Undefined for anything that is not one.
24
+ */
25
+ export function parseDSN(dsn) {
26
+ if (!dsn)
27
+ return undefined;
28
+ let url;
29
+ try {
30
+ url = new URL(dsn);
31
+ }
32
+ catch {
33
+ return undefined;
34
+ }
35
+ const key = url.username;
36
+ const parts = url.pathname.split("/").filter(Boolean);
37
+ const projectId = parts.pop();
38
+ if (!key || !projectId || !/^\d+$/.test(projectId))
39
+ return undefined;
40
+ const prefix = parts.length ? `/${parts.join("/")}` : "";
41
+ const envelopeURL = `${url.protocol}//${url.host}${prefix}/api/${projectId}/envelope/?sentry_key=${encodeURIComponent(key)}&sentry_version=7`;
42
+ return { key, projectId, envelopeURL };
43
+ }
44
+ /**
45
+ * The frames of a V8 stack (`at fn (file:line:col)`, `at file:line:col`),
46
+ * oldest call first, as Sentry lists them. A frame inside `node_modules` is
47
+ * not the site's own code.
48
+ */
49
+ export function parseStack(stack) {
50
+ if (!stack)
51
+ return [];
52
+ const frames = [];
53
+ for (const line of stack.split("\n")) {
54
+ const match = line.match(/^\s*at (?:(.+?) \()?(.+?):(\d+):(\d+)\)?\s*$/);
55
+ if (!match)
56
+ continue;
57
+ const [, fn, filename, lineno, colno] = match;
58
+ frames.push({
59
+ ...(fn ? { function: fn } : {}),
60
+ filename,
61
+ lineno: Number(lineno),
62
+ colno: Number(colno),
63
+ in_app: !filename.includes("node_modules"),
64
+ });
65
+ }
66
+ return frames.reverse();
67
+ }
68
+ /** The runtime a report came from: Vercel's edge, Node, or neither. */
69
+ function runtime() {
70
+ if (typeof globalThis.EdgeRuntime !== "undefined")
71
+ return "edge";
72
+ const node = globalThis.process?.versions
73
+ ?.node;
74
+ return node ? "node" : "unknown";
75
+ }
76
+ function eventID() {
77
+ const random = globalThis.crypto?.randomUUID;
78
+ if (random)
79
+ return random.call(globalThis.crypto).replaceAll("-", "");
80
+ let id = "";
81
+ for (let i = 0; i < 32; i++)
82
+ id += Math.floor(Math.random() * 16).toString(16);
83
+ return id;
84
+ }
85
+ /** The thrown value as Sentry's exception: its type, message, and frames. */
86
+ function exceptionOf(error) {
87
+ if (error instanceof Error) {
88
+ const frames = parseStack(error.stack);
89
+ return {
90
+ type: error.name || "Error",
91
+ value: error.message,
92
+ ...(frames.length ? { stacktrace: { frames } } : {}),
93
+ };
94
+ }
95
+ let value;
96
+ try {
97
+ value = typeof error === "string" ? error : JSON.stringify(error);
98
+ }
99
+ catch {
100
+ value = String(error);
101
+ }
102
+ return { type: "Error", value: value ?? String(error) };
103
+ }
104
+ /**
105
+ * The request as a report may carry it: the method, the URL with no query
106
+ * string or fragment, and the user agent. Never the body, never another
107
+ * header.
108
+ */
109
+ function requestOf(request) {
110
+ if (!request)
111
+ return undefined;
112
+ let url;
113
+ try {
114
+ const parsed = new URL(request.url);
115
+ url = `${parsed.origin}${parsed.pathname}`;
116
+ }
117
+ catch {
118
+ url = undefined;
119
+ }
120
+ const agent = request.headers?.get?.("user-agent");
121
+ return {
122
+ method: request.method,
123
+ ...(url ? { url } : {}),
124
+ ...(agent ? { headers: { "User-Agent": agent } } : {}),
125
+ };
126
+ }
127
+ /**
128
+ * The envelope a report is sent as: the envelope header, the item header,
129
+ * and the event, one JSON document to a line. Exported for the tests.
130
+ */
131
+ export function buildEnvelope(error, dsn, options = {}, now = new Date()) {
132
+ const id = eventID();
133
+ const release = options.release ?? environmentValue("VERCEL_GIT_COMMIT_SHA");
134
+ const environment = options.environment ?? environmentValue("VERCEL_ENV");
135
+ const request = requestOf(options.request);
136
+ const event = {
137
+ event_id: id,
138
+ timestamp: now.getTime() / 1000,
139
+ platform: "javascript",
140
+ level: "error",
141
+ sdk: SDK,
142
+ ...(release ? { release } : {}),
143
+ ...(environment ? { environment } : {}),
144
+ tags: { runtime: runtime(), ...options.tags },
145
+ ...(request ? { request } : {}),
146
+ exception: { values: [exceptionOf(error)] },
147
+ };
148
+ const header = { event_id: id, sent_at: now.toISOString(), dsn, sdk: SDK };
149
+ return [JSON.stringify(header), JSON.stringify({ type: "event" }), JSON.stringify(event)].join("\n");
150
+ }
151
+ /**
152
+ * Reports an error to Sentry from a function or the middleware. Resolves
153
+ * true when Sentry took it and false otherwise (no DSN, a bad DSN, a failed
154
+ * or slow send), and never throws, so a report can never become a second
155
+ * failure. With no DSN it sends nothing.
156
+ */
157
+ export async function reportServerError(error, options = {}) {
158
+ try {
159
+ const dsn = options.dsn ?? environmentValue("SENTRY_DSN") ?? environmentValue("VITE_SENTRY_DSN");
160
+ const parsed = parseDSN(dsn);
161
+ if (!dsn || !parsed)
162
+ return false;
163
+ const body = buildEnvelope(error, dsn, options);
164
+ const controller = new AbortController();
165
+ const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? 2000);
166
+ try {
167
+ const response = await fetch(parsed.envelopeURL, {
168
+ method: "POST",
169
+ headers: { "Content-Type": "application/x-sentry-envelope" },
170
+ body,
171
+ signal: controller.signal,
172
+ });
173
+ // The answer's body is never read, so it is let go at once rather
174
+ // than held open until the runtime collects it.
175
+ await response.body?.cancel().catch(() => { });
176
+ return response.ok;
177
+ }
178
+ finally {
179
+ clearTimeout(timer);
180
+ }
181
+ }
182
+ catch {
183
+ return false;
184
+ }
185
+ }
186
+ /**
187
+ * Wraps a function's handler so a throw is reported, then thrown again: the
188
+ * platform still answers the request as it would have, and Sentry hears of
189
+ * it first. `export const POST = withErrorReporting(async (request) => ...)`.
190
+ */
191
+ export function withErrorReporting(handler, options = {}) {
192
+ return async (...args) => {
193
+ try {
194
+ return await handler(...args);
195
+ }
196
+ catch (error) {
197
+ await reportServerError(error, { ...options, request: args[0] });
198
+ throw error;
199
+ }
200
+ };
201
+ }
@@ -4,5 +4,5 @@
4
4
  * plugin inside the artifact one for a site that writes its own.
5
5
  */
6
6
  export { type ArtifactConfigOptions, type ArtifactPage, artifactConfig, artifactPages, } from "./artifact-config.js";
7
- export { type MarketingConfigOptions, type MarketingPage, marketingBasePath, marketingConfig, NOT_FOUND_PAGE, } from "./marketing-config.js";
7
+ export { buildRelease, environmentPlugin, type MarketingConfigOptions, type MarketingPage, marketingBasePath, marketingConfig, NOT_FOUND_PAGE, type SentryUpload, sentryUpload, } from "./marketing-config.js";
8
8
  export { DOC_DIR, isPrivateContent, privateChunks } from "./private-chunks.js";
@@ -4,5 +4,5 @@
4
4
  * plugin inside the artifact one for a site that writes its own.
5
5
  */
6
6
  export { artifactConfig, artifactPages, } from "./artifact-config.js";
7
- export { marketingBasePath, marketingConfig, NOT_FOUND_PAGE, } from "./marketing-config.js";
7
+ export { buildRelease, environmentPlugin, marketingBasePath, marketingConfig, NOT_FOUND_PAGE, sentryUpload, } from "./marketing-config.js";
8
8
  export { DOC_DIR, isPrivateContent, privateChunks } from "./private-chunks.js";
@@ -1,4 +1,4 @@
1
- import { type UserConfig } from "vite";
1
+ import { type Plugin, type UserConfig } from "vite";
2
2
  /** One entry of the prerender list, as TanStack Start takes it. */
3
3
  export interface MarketingPage {
4
4
  path: string;
@@ -35,6 +35,33 @@ export interface MarketingConfigOptions {
35
35
  /** The environment to read `VITE_BASE_PATH` from; a test passes its own. */
36
36
  env?: Record<string, string | undefined>;
37
37
  }
38
+ /**
39
+ * The commit a build is filed under in Sentry: Vercel's commit, else the CI's.
40
+ * The same value names the release the Sentry plugin creates and the release
41
+ * the browser reports under, so a stack trace meets its source maps.
42
+ */
43
+ export declare function buildRelease(env?: Record<string, string | undefined>): string | undefined;
44
+ /** What the Sentry plugin is given, when it runs at all. */
45
+ export interface SentryUpload {
46
+ org: string;
47
+ project: string;
48
+ authToken: string;
49
+ release: string;
50
+ }
51
+ /**
52
+ * The source map upload, on only when `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, and
53
+ * `SENTRY_PROJECT` are all set and the build knows its commit. Off, the
54
+ * build is exactly what it was: no plugin, no source maps.
55
+ */
56
+ export declare function sentryUpload(env?: Record<string, string | undefined>): SentryUpload | undefined;
57
+ /**
58
+ * The environment the browser files its errors under, as
59
+ * `import.meta.env.VITE_ENVIRONMENT`: Vercel's (production, preview,
60
+ * development) when the build runs there, else the build's mode. A Vite
61
+ * production build's mode is production on every deploy, a preview's
62
+ * included, so the mode alone filed every error as production.
63
+ */
64
+ export declare function environmentPlugin(env?: Record<string, string | undefined>): Plugin;
38
65
  /** The 404 page, prerendered and copied to 404.html by the build, never in the sitemap. */
39
66
  export declare const NOT_FOUND_PAGE: MarketingPage;
40
67
  /**
@@ -17,6 +17,58 @@ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
17
17
  import react from "@vitejs/plugin-react";
18
18
  import { mergeConfig } from "vite";
19
19
  import { normalizeBasePath } from "../routing/basePath.js";
20
+ /**
21
+ * The commit a build is filed under in Sentry: Vercel's commit, else the CI's.
22
+ * The same value names the release the Sentry plugin creates and the release
23
+ * the browser reports under, so a stack trace meets its source maps.
24
+ */
25
+ export function buildRelease(env = process.env) {
26
+ return env.VERCEL_GIT_COMMIT_SHA || env.GITHUB_SHA || undefined;
27
+ }
28
+ /**
29
+ * The source map upload, on only when `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, and
30
+ * `SENTRY_PROJECT` are all set and the build knows its commit. Off, the
31
+ * build is exactly what it was: no plugin, no source maps.
32
+ */
33
+ export function sentryUpload(env = process.env) {
34
+ const { SENTRY_AUTH_TOKEN: authToken, SENTRY_ORG: org, SENTRY_PROJECT: project } = env;
35
+ const release = buildRelease(env);
36
+ if (!authToken || !org || !project || !release)
37
+ return undefined;
38
+ return { org, project, authToken, release };
39
+ }
40
+ /**
41
+ * The Sentry Vite plugin, loaded only when it runs: it creates the release
42
+ * named by the commit, uploads the build's hidden source maps, and deletes
43
+ * every map file from the output afterwards, so none is ever served.
44
+ */
45
+ function sentryPlugin(upload) {
46
+ return import("@sentry/vite-plugin").then(({ sentryVitePlugin }) => sentryVitePlugin({
47
+ org: upload.org,
48
+ project: upload.project,
49
+ authToken: upload.authToken,
50
+ release: { name: upload.release, inject: false },
51
+ sourcemaps: { filesToDeleteAfterUpload: ["./dist/**/*.map"] },
52
+ telemetry: false,
53
+ }));
54
+ }
55
+ /**
56
+ * The environment the browser files its errors under, as
57
+ * `import.meta.env.VITE_ENVIRONMENT`: Vercel's (production, preview,
58
+ * development) when the build runs there, else the build's mode. A Vite
59
+ * production build's mode is production on every deploy, a preview's
60
+ * included, so the mode alone filed every error as production.
61
+ */
62
+ export function environmentPlugin(env = process.env) {
63
+ return {
64
+ name: "atelic-build-environment",
65
+ config: (_config, { mode }) => ({
66
+ define: {
67
+ "import.meta.env.VITE_ENVIRONMENT": JSON.stringify(env.VERCEL_ENV || mode),
68
+ },
69
+ }),
70
+ };
71
+ }
20
72
  /** The 404 page, prerendered and copied to 404.html by the build, never in the sitemap. */
21
73
  export const NOT_FOUND_PAGE = {
22
74
  path: "/404",
@@ -39,6 +91,8 @@ export function marketingBasePath(site, env = process.env) {
39
91
  }
40
92
  export function marketingConfig({ site, pages = [], sitemapHost, extend, env = process.env, }) {
41
93
  const basePath = marketingBasePath(site, env);
94
+ const release = buildRelease(env);
95
+ const upload = sentryUpload(env);
42
96
  const listed = pages.filter((page) => page.path !== NOT_FOUND_PAGE.path);
43
97
  const config = {
44
98
  // The base becomes Vite's `base`, so every built asset URL and every
@@ -65,7 +119,15 @@ export function marketingConfig({ site, pages = [], sitemapHost, extend, env = p
65
119
  },
66
120
  }),
67
121
  react(),
122
+ environmentPlugin(env),
123
+ ...(upload ? [sentryPlugin(upload)] : []),
68
124
  ],
125
+ // The commit, for the browser to report under (`startErrorReporting`'s
126
+ // `release`), read as `import.meta.env.VITE_RELEASE`.
127
+ ...(release ? { define: { "import.meta.env.VITE_RELEASE": JSON.stringify(release) } } : {}),
128
+ // Maps only for Sentry, and hidden: the bundles carry no comment
129
+ // pointing at one, and the plugin deletes them once uploaded.
130
+ ...(upload ? { build: { sourcemap: "hidden" } } : {}),
69
131
  resolve: {
70
132
  alias: {
71
133
  // The site's src, from the directory Vite is run in: this file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atelic-action/ui",
3
- "version": "7.2.0",
3
+ "version": "8.1.0",
4
4
  "description": "Shared UI for the Atelic templates: site chrome, base styles, the component library, the access gate, and the app shell they install",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -21,6 +21,7 @@
21
21
  "atelic-check-base-path": "./bin/atelic-check-base-path.ts",
22
22
  "atelic-check-images": "./bin/atelic-check-images.ts",
23
23
  "atelic-check-links": "./bin/atelic-check-links.ts",
24
+ "atelic-check-sentry": "./bin/atelic-check-sentry.ts",
24
25
  "atelic-check-wall": "./bin/atelic-check-wall.ts",
25
26
  "atelic-clean-sitemap": "./bin/atelic-clean-sitemap.ts",
26
27
  "atelic-contact-canary": "./bin/atelic-contact-canary.ts",
@@ -46,6 +47,11 @@
46
47
  "./email": "./src/email/index.ts",
47
48
  "./email/render": "./src/email/render.tsx",
48
49
  "./hooks": "./src/hooks/index.ts",
50
+ "./monitoring": "./src/monitoring/index.ts",
51
+ "./monitoring/server": {
52
+ "types": "./dist/monitoring/server.d.ts",
53
+ "default": "./dist/monitoring/server.js"
54
+ },
49
55
  "./primitives": "./src/primitives/index.ts",
50
56
  "./routing": "./src/routing/index.ts",
51
57
  "./routing/base-path": {
@@ -91,17 +97,20 @@
91
97
  },
92
98
  "scripts": {
93
99
  "build": "rm -rf dist && tsc -p tsconfig.server.json",
94
- "build:smoke": "node --input-type=module -e \"for (const entry of ['gate', 'gate/middleware', 'gate/request-link', 'gate/verify', 'vite', 'vite/private-chunks', 'artifact/readers', 'routing/base-path']) await import('@atelic-action/ui/' + entry)\"",
100
+ "build:smoke": "node --input-type=module -e \"for (const entry of ['gate', 'gate/middleware', 'gate/request-link', 'gate/verify', 'vite', 'vite/private-chunks', 'artifact/readers', 'routing/base-path', 'monitoring/server']) await import('@atelic-action/ui/' + entry)\"",
95
101
  "prepack": "bun run build",
96
102
  "lint": "biome check .",
97
103
  "lint:fix": "biome check . --write",
98
- "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.server.json && tsc --noEmit -p gallery",
99
- "test:run": "vitest run",
100
- "gallery:dev": "vite gallery",
101
- "gallery:build": "vite build gallery"
104
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.server.json && tsc --noEmit -p stories",
105
+ "test:run": "vitest run --project=unit",
106
+ "test:stories": "vitest run --project=storybook",
107
+ "storybook": "storybook dev --port 6006",
108
+ "storybook:build": "storybook build --output-dir storybook-static"
102
109
  },
103
110
  "dependencies": {
104
111
  "@radix-ui/react-tabs": "^1.2.1",
112
+ "@sentry/browser": "^11.16.0",
113
+ "@sentry/vite-plugin": "^11.16.0",
105
114
  "jose": "^6.2.12"
106
115
  },
107
116
  "peerDependencies": {
@@ -130,7 +139,6 @@
130
139
  "country-data-list": "^1.6.0",
131
140
  "lucide-react": "^1.23.0",
132
141
  "react": "^19.0.0",
133
- "react-circle-flags": "^0.0.25",
134
142
  "react-dom": "^19.0.0",
135
143
  "react-hook-form": "^7.71.1",
136
144
  "sonner": "^2.0.7",
@@ -210,9 +218,6 @@
210
218
  "country-data-list": {
211
219
  "optional": true
212
220
  },
213
- "react-circle-flags": {
214
- "optional": true
215
- },
216
221
  "react-hook-form": {
217
222
  "optional": true
218
223
  },
@@ -252,6 +257,10 @@
252
257
  "@radix-ui/react-slot": "^1.2.4",
253
258
  "@radix-ui/react-switch": "^1.2.6",
254
259
  "@radix-ui/react-tooltip": "^1.2.8",
260
+ "@storybook/addon-a11y": "^10.6.8",
261
+ "@storybook/addon-docs": "^10.6.8",
262
+ "@storybook/addon-vitest": "^10.6.8",
263
+ "@storybook/react-vite": "^10.6.8",
255
264
  "@tailwindcss/vite": "^4.1.17",
256
265
  "@tanstack/react-query": "^5.59.0",
257
266
  "@tanstack/react-router": "^1.81.4",
@@ -264,17 +273,20 @@
264
273
  "@types/react": "^19.0.0",
265
274
  "@types/react-dom": "^19.0.0",
266
275
  "@vitejs/plugin-react": "^6.1.1",
276
+ "@vitest/browser": "^4.1.11",
277
+ "@vitest/browser-playwright": "^4.1.11",
267
278
  "class-variance-authority": "^0.7.0",
268
279
  "clsx": "^2.1.1",
269
280
  "cmdk": "^1.1.1",
270
281
  "country-data-list": "^1.6.0",
271
282
  "jsdom": "^25.0.1",
272
283
  "lucide-react": "^1.23.0",
284
+ "playwright": "^1.65.1",
273
285
  "react": "^19.0.0",
274
- "react-circle-flags": "^0.0.25",
275
286
  "react-dom": "^19.0.0",
276
287
  "react-hook-form": "^7.71.1",
277
288
  "sonner": "^2.0.7",
289
+ "storybook": "^10.6.8",
278
290
  "tailwind-merge": "^3.0.0",
279
291
  "tailwindcss": "^4.1.17",
280
292
  "tailwindcss-animate": "^1.0.7",
@@ -20,13 +20,17 @@ export function ErrorFallback({ error, resetError, showDetails = false }: ErrorF
20
20
 
21
21
  return (
22
22
  <div className="flex min-h-screen items-center justify-center bg-background p-4">
23
- <div className="max-w-md text-center">
23
+ <div className="w-full min-w-0 max-w-md text-center">
24
24
  <h1 className="text-2xl font-semibold text-foreground">Something went wrong</h1>
25
25
  <p className="mt-2 text-sm text-muted-foreground">
26
26
  An unexpected error occurred. Please try again.
27
27
  </p>
28
28
  {showDetails && (
29
- <pre className="mt-4 max-h-40 overflow-auto rounded bg-muted p-3 text-left text-xs text-muted-foreground">
29
+ <pre
30
+ // biome-ignore lint/a11y/noNoninteractiveTabindex: a box that scrolls takes focus, so a keyboard can scroll it
31
+ tabIndex={0}
32
+ className="mt-4 max-h-40 overflow-auto rounded bg-muted p-3 text-left text-xs text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
33
+ >
30
34
  {errorMessage}
31
35
  </pre>
32
36
  )}
@@ -1,5 +1,5 @@
1
1
  import { createContext, type ReactNode, useContext, useMemo, useRef } from "react";
2
- import { type AppConfig, getAppConfig } from "../config";
2
+ import { type AppConfig, getAppConfig, peekAppConfig } from "../config";
3
3
  import { configureApp } from "../configure";
4
4
  import type { NavItem } from "../layout/nav";
5
5
 
@@ -42,6 +42,15 @@ export function useAppConfig(): AppConfig {
42
42
  return useContext(AppContext)?.config ?? getAppConfig();
43
43
  }
44
44
 
45
+ /**
46
+ * The app's config when there is one, or null: for a kit component that also
47
+ * renders outside the shell (a story, a page with no provider), which falls
48
+ * back to its own default rather than throwing.
49
+ */
50
+ export function useOptionalAppConfig(): AppConfig | null {
51
+ return useContext(AppContext)?.config ?? peekAppConfig();
52
+ }
53
+
45
54
  /** The app's nav items. Throws outside an `AppProvider` or `AppConfigProvider`. */
46
55
  export function useNav(): NavItem[] {
47
56
  const context = useContext(AppContext);
package/src/app/index.ts CHANGED
@@ -8,7 +8,6 @@
8
8
  // The provider, the config, and the frame
9
9
  export { AppProvider, type AppProviderProps } from "./AppProvider";
10
10
  export { AuthGuard } from "./AuthGuard";
11
- export { CardErrorBoundary } from "./CardErrorBoundary";
12
11
  export { type AppConfig, getAppConfig } from "./config";
13
12
  export { configureApp } from "./configure";
14
13
  export {