@atelic-action/ui 8.0.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -22
- package/bin/atelic-check-sentry.ts +5 -0
- package/dist/gate/middleware.js +15 -1
- package/dist/monitoring/server.d.ts +122 -0
- package/dist/monitoring/server.js +302 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/vite/marketing-config.d.ts +28 -1
- package/dist/vite/marketing-config.js +62 -0
- package/package.json +10 -2
- package/src/app/layout/DesktopRail.tsx +6 -4
- package/src/app/layout/MobileMenu.tsx +10 -5
- package/src/app/layout/MobileTabBar.tsx +3 -2
- package/src/app/layout/PageError.tsx +2 -2
- package/src/app/layout/SectionCards.tsx +7 -2
- package/src/app/layout/UserMenu.tsx +1 -1
- package/src/app/ui/alert.tsx +1 -1
- package/src/app/ui/form.tsx +2 -2
- package/src/artifact/AppErrorBoundary.tsx +12 -7
- package/src/chrome/BrandLockup.tsx +46 -7
- package/src/chrome/ContactDock.tsx +59 -13
- package/src/chrome/Footer.tsx +97 -28
- package/src/chrome/NavMegaPanel.tsx +11 -6
- package/src/chrome/SiteHeader.tsx +68 -18
- package/src/chrome/SiteMenu.tsx +207 -72
- package/src/chrome/SiteShell.tsx +25 -3
- package/src/chrome/StickyCTABar.tsx +24 -8
- package/src/chrome/index.ts +2 -0
- package/src/components/NotFound.tsx +3 -2
- package/src/gate/middleware.ts +15 -1
- package/src/lib/emailText.tsx +26 -0
- package/src/lib/phoneText.tsx +49 -0
- package/src/monitoring/ErrorCatcherScript.tsx +26 -0
- package/src/monitoring/catcher.ts +118 -0
- package/src/monitoring/index.ts +25 -0
- package/src/monitoring/sdk.ts +112 -0
- package/src/monitoring/server.ts +368 -0
- package/src/monitoring/start.ts +118 -0
- package/src/primitives/Button.tsx +3 -1
- package/src/primitives/Eyebrow.tsx +6 -2
- package/src/routing/index.ts +11 -32
- package/src/routing/miss.ts +32 -0
- package/src/routing/routerErrors.tsx +57 -0
- package/src/routing/staticNotFound.tsx +64 -0
- package/src/scripts/check-sentry.ts +98 -0
- package/src/sections/CalloutPanel.tsx +4 -1
- package/src/sections/ContactInfoCard.tsx +1 -1
- package/src/sections/FullBleedVideo.tsx +13 -4
- package/src/sections/Hero.tsx +10 -3
- package/src/sections/LinkColumns.tsx +30 -14
- package/src/sections/Locations.tsx +1 -1
- package/src/sections/LogoMarquee.tsx +1 -1
- package/src/sections/PricingBand.tsx +1 -1
- package/src/sections/ProcessSteps.tsx +1 -1
- package/src/sections/siteConfig.ts +67 -5
- package/src/styles/app.css +9 -0
- package/src/styles/base.css +34 -2
- package/src/styles/chrome.css +449 -41
- package/src/styles/defaults.css +61 -2
- package/src/styles/primitives.css +20 -7
- package/src/styles/sections.css +52 -9
- package/src/types.ts +40 -2
- package/src/vite/index.ts +4 -0
- package/src/vite/marketing-config.ts +81 -1
|
@@ -0,0 +1,302 @@
|
|
|
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, reportServerErrorLater, 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
|
+
* The platform's own `waitUntil`, read the way `@vercel/functions` reads it,
|
|
188
|
+
* from the request context Vercel keeps on a global symbol, so this file
|
|
189
|
+
* needs no dependency for it. Undefined anywhere else.
|
|
190
|
+
*/
|
|
191
|
+
function platformWaitUntil() {
|
|
192
|
+
try {
|
|
193
|
+
const store = globalThis[Symbol.for("@vercel/request-context")];
|
|
194
|
+
const context = store?.get?.();
|
|
195
|
+
const waitUntil = context?.waitUntil;
|
|
196
|
+
return typeof waitUntil === "function" ? waitUntil.bind(context) : undefined;
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Reports an error without making the caller wait for it. The send starts
|
|
204
|
+
* at once and is handed to the platform's `waitUntil` (the `context` given,
|
|
205
|
+
* else Vercel's request context), which keeps the function alive until it
|
|
206
|
+
* finishes after the answer has gone. With neither, the send still runs,
|
|
207
|
+
* never blocking the answer, and may be cut short if the runtime freezes
|
|
208
|
+
* once the answer is out. Never throws, and returns nothing to wait on.
|
|
209
|
+
*
|
|
210
|
+
* Use `reportServerError`, awaited, where the report must land before the
|
|
211
|
+
* handler goes on (before a throw, in a handler that already waits); use
|
|
212
|
+
* this one where the answer should leave at once (a refusal the person is
|
|
213
|
+
* waiting to read).
|
|
214
|
+
*/
|
|
215
|
+
export function reportServerErrorLater(error, options = {}) {
|
|
216
|
+
const { context, ...report } = options;
|
|
217
|
+
const sending = reportServerError(error, report);
|
|
218
|
+
// The context's own waitUntil first, then the platform's; a context with
|
|
219
|
+
// none that can be called, or one that throws, falls through to the
|
|
220
|
+
// next, and with neither the send runs on its own, never blocking.
|
|
221
|
+
const own = context?.waitUntil;
|
|
222
|
+
const fromContext = typeof own === "function"
|
|
223
|
+
? (promise) => own.call(context, promise)
|
|
224
|
+
: undefined;
|
|
225
|
+
for (const find of [() => fromContext, platformWaitUntil]) {
|
|
226
|
+
try {
|
|
227
|
+
const hold = find();
|
|
228
|
+
if (!hold)
|
|
229
|
+
continue;
|
|
230
|
+
hold(sending);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
// This one could not hold the send; the next is tried.
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/** Anything shaped like an email address, which a refusal may quote (the recipient, the sender). */
|
|
239
|
+
const ADDRESS = /[^\s@<>()[\]"',;:]+@[^\s@<>()[\]"',;:]+\.[^\s@<>()[\]"',;:]+/g;
|
|
240
|
+
/** The longest a refusal's field is kept, so a report never carries a page of text. */
|
|
241
|
+
const REFUSAL_FIELD_MAX = 300;
|
|
242
|
+
/**
|
|
243
|
+
* A refused upstream answer as an error a report may carry: the service's
|
|
244
|
+
* name, the status, and the error body's `name` and `message` fields alone,
|
|
245
|
+
* each with anything shaped like an email address replaced by `[address]`
|
|
246
|
+
* and cut to 300 characters. Nothing else of the body is read, and a body
|
|
247
|
+
* that is not JSON leaves the status alone. Never throws.
|
|
248
|
+
*
|
|
249
|
+
* await refusalError(response, "Resend") // Error("Resend answered 422: validation_error: ...")
|
|
250
|
+
*/
|
|
251
|
+
export async function refusalError(response, service = "The upstream service") {
|
|
252
|
+
let body = {};
|
|
253
|
+
try {
|
|
254
|
+
const parsed = await response.json();
|
|
255
|
+
if (parsed && typeof parsed === "object")
|
|
256
|
+
body = parsed;
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
// Not JSON, or already read: the status says what there is to say.
|
|
260
|
+
}
|
|
261
|
+
const parts = [body.name, body.message]
|
|
262
|
+
.filter((part) => typeof part === "string" && part.trim() !== "")
|
|
263
|
+
.map((part) => part.replace(ADDRESS, "[address]").slice(0, REFUSAL_FIELD_MAX));
|
|
264
|
+
return new Error(`${service} answered ${response.status}${parts.length ? `: ${parts.join(": ")}` : ""}`);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Reports a refused upstream answer (a send the mail service would not
|
|
268
|
+
* take) without holding the caller's own answer: the error is built by
|
|
269
|
+
* `refusalError`, so no address in the refusal survives, and sent by
|
|
270
|
+
* `reportServerErrorLater`. Resolves once the refusal's body is read, never
|
|
271
|
+
* waiting on the send, and never throws.
|
|
272
|
+
*
|
|
273
|
+
* if (!response.ok) {
|
|
274
|
+
* await reportRefusedResponse(response, { service: "Resend", request, tags: { route: "contact" } });
|
|
275
|
+
* return json(502, { ok: false, error: "Sending failed. Please try again in a moment." });
|
|
276
|
+
* }
|
|
277
|
+
*/
|
|
278
|
+
export async function reportRefusedResponse(response, options = {}) {
|
|
279
|
+
const { service, ...report } = options;
|
|
280
|
+
try {
|
|
281
|
+
reportServerErrorLater(await refusalError(response, service), report);
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// A report never becomes a second failure.
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Wraps a function's handler so a throw is reported, then thrown again: the
|
|
289
|
+
* platform still answers the request as it would have, and Sentry hears of
|
|
290
|
+
* it first. `export const POST = withErrorReporting(async (request) => ...)`.
|
|
291
|
+
*/
|
|
292
|
+
export function withErrorReporting(handler, options = {}) {
|
|
293
|
+
return async (...args) => {
|
|
294
|
+
try {
|
|
295
|
+
return await handler(...args);
|
|
296
|
+
}
|
|
297
|
+
catch (error) {
|
|
298
|
+
await reportServerError(error, { ...options, request: args[0] });
|
|
299
|
+
throw error;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -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";
|
package/dist/vite/index.js
CHANGED
|
@@ -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": "8.
|
|
3
|
+
"version": "8.2.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,7 +97,7 @@
|
|
|
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",
|
|
@@ -103,6 +109,8 @@
|
|
|
103
109
|
},
|
|
104
110
|
"dependencies": {
|
|
105
111
|
"@radix-ui/react-tabs": "^1.2.1",
|
|
112
|
+
"@sentry/browser": "^11.16.0",
|
|
113
|
+
"@sentry/vite-plugin": "^11.16.0",
|
|
106
114
|
"jose": "^6.2.12"
|
|
107
115
|
},
|
|
108
116
|
"peerDependencies": {
|
|
@@ -131,19 +131,21 @@ export function DesktopRail({ pathname, collapsed, onToggle, user, onLogout }: D
|
|
|
131
131
|
<nav className="flex-1 space-y-1 px-4 py-6" aria-label="Primary navigation">
|
|
132
132
|
{navItems
|
|
133
133
|
.filter((item) => !item.mobileOnly)
|
|
134
|
-
.map((item) => {
|
|
134
|
+
.map((item, at) => {
|
|
135
135
|
const active = isActiveSection(pathname, item);
|
|
136
136
|
const showChildren = active && !collapsed && item.children?.length;
|
|
137
137
|
return (
|
|
138
|
-
|
|
138
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
139
|
+
<div key={at}>
|
|
139
140
|
<RailLink item={item} active={active} collapsed={collapsed} />
|
|
140
141
|
{showChildren ? (
|
|
141
142
|
<ul className="mt-1 space-y-0.5 pb-1" aria-label={`${item.label} pages`}>
|
|
142
|
-
{item.children?.map((child) => {
|
|
143
|
+
{item.children?.map((child, childAt) => {
|
|
143
144
|
const childActive = isActivePath(pathname, child.href);
|
|
144
145
|
const ChildIcon = child.icon;
|
|
145
146
|
return (
|
|
146
|
-
|
|
147
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
148
|
+
<li key={childAt}>
|
|
147
149
|
<Link
|
|
148
150
|
to={child.href}
|
|
149
151
|
className={cn(
|
|
@@ -72,14 +72,15 @@ export function MobileMenu({ pathname, user, onLogout }: MobileMenuProps) {
|
|
|
72
72
|
|
|
73
73
|
<nav className="flex-1 overflow-y-auto px-2 py-3" aria-label="Menu">
|
|
74
74
|
<ul className="space-y-0.5">
|
|
75
|
-
{navItems.map((item) => {
|
|
75
|
+
{navItems.map((item, at) => {
|
|
76
76
|
const Icon = item.icon;
|
|
77
77
|
const active = isActiveSection(pathname, item);
|
|
78
78
|
// A section with sub pages lights its row only on its own landing
|
|
79
79
|
// page; deeper in, the sub page row carries the highlight.
|
|
80
80
|
const exact = pathname === item.href;
|
|
81
81
|
return (
|
|
82
|
-
|
|
82
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
83
|
+
<li key={at}>
|
|
83
84
|
<Link
|
|
84
85
|
onClick={() => setOpen(false)}
|
|
85
86
|
to={item.href}
|
|
@@ -98,11 +99,12 @@ export function MobileMenu({ pathname, user, onLogout }: MobileMenuProps) {
|
|
|
98
99
|
</Link>
|
|
99
100
|
{item.children ? (
|
|
100
101
|
<ul className="mb-1 mt-0.5 space-y-0.5" aria-label={`${item.label} pages`}>
|
|
101
|
-
{item.children.map((child) => {
|
|
102
|
+
{item.children.map((child, childAt) => {
|
|
102
103
|
const ChildIcon = child.icon;
|
|
103
104
|
const childActive = isActivePath(pathname, child.href);
|
|
104
105
|
return (
|
|
105
|
-
|
|
106
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
107
|
+
<li key={childAt}>
|
|
106
108
|
<Link
|
|
107
109
|
onClick={() => setOpen(false)}
|
|
108
110
|
to={child.href}
|
|
@@ -148,7 +150,10 @@ export function MobileMenu({ pathname, user, onLogout }: MobileMenuProps) {
|
|
|
148
150
|
<button
|
|
149
151
|
type="button"
|
|
150
152
|
onClick={onLogout}
|
|
151
|
-
className={cn(
|
|
153
|
+
className={cn(
|
|
154
|
+
ROW,
|
|
155
|
+
"w-full text-destructive-ink active:text-destructive-hover dark:active:text-destructive-ink",
|
|
156
|
+
)}
|
|
152
157
|
>
|
|
153
158
|
<LogOut className="h-5 w-5 flex-shrink-0" />
|
|
154
159
|
<span>Log out</span>
|
|
@@ -18,12 +18,13 @@ export function MobileTabBar({ pathname }: { pathname: string }) {
|
|
|
18
18
|
<div className="flex h-16 items-center justify-around">
|
|
19
19
|
{navItems
|
|
20
20
|
.filter((item) => !item.desktopOnly)
|
|
21
|
-
.map((item) => {
|
|
21
|
+
.map((item, at) => {
|
|
22
22
|
const Icon = item.icon;
|
|
23
23
|
const active = isActiveSection(pathname, item);
|
|
24
24
|
return (
|
|
25
25
|
<Link
|
|
26
|
-
key
|
|
26
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
27
|
+
key={at}
|
|
27
28
|
to={item.href}
|
|
28
29
|
className={cn(
|
|
29
30
|
"flex h-full flex-1 flex-col items-center justify-center py-2 transition-colors duration-150 active:bg-accent",
|
|
@@ -22,9 +22,9 @@ export function PageError({ message, title = "Error", className }: PageErrorProp
|
|
|
22
22
|
return (
|
|
23
23
|
<Card role="alert" className={cn("border-destructive/50", className)}>
|
|
24
24
|
<CardContent className="flex items-center gap-3 py-6">
|
|
25
|
-
<AlertCircle className="h-5 w-5 flex-shrink-0 text-destructive" aria-hidden="true" />
|
|
25
|
+
<AlertCircle className="h-5 w-5 flex-shrink-0 text-destructive-ink" aria-hidden="true" />
|
|
26
26
|
<div>
|
|
27
|
-
<p className="font-medium text-destructive">{title}</p>
|
|
27
|
+
<p className="font-medium text-destructive-ink">{title}</p>
|
|
28
28
|
<p className="text-sm text-muted-foreground">{message}</p>
|
|
29
29
|
</div>
|
|
30
30
|
</CardContent>
|
|
@@ -14,10 +14,15 @@ export function SectionCards({ section }: { section: string }) {
|
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
16
|
<nav className="ap-sections" aria-label={`${item.label} pages`}>
|
|
17
|
-
{item.children.map((child) => {
|
|
17
|
+
{item.children.map((child, at) => {
|
|
18
18
|
const Icon = child.icon;
|
|
19
19
|
return (
|
|
20
|
-
<Link
|
|
20
|
+
<Link
|
|
21
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: two entries may share a link, so the place keeps the key unique; the nav never reorders
|
|
22
|
+
key={at}
|
|
23
|
+
to={child.href}
|
|
24
|
+
className="ap-section-card"
|
|
25
|
+
>
|
|
21
26
|
<span className="ic">
|
|
22
27
|
<Icon size={20} />
|
|
23
28
|
</span>
|
|
@@ -100,7 +100,7 @@ export function UserMenu({ user, onLogout, collapsed = false }: UserMenuProps) {
|
|
|
100
100
|
</Link>
|
|
101
101
|
</DropdownMenuItem>
|
|
102
102
|
<DropdownMenuSeparator />
|
|
103
|
-
<DropdownMenuItem onClick={onLogout} className="cursor-pointer text-destructive">
|
|
103
|
+
<DropdownMenuItem onClick={onLogout} className="cursor-pointer text-destructive-ink">
|
|
104
104
|
<LogOut className="mr-2 h-4 w-4" />
|
|
105
105
|
<span>Log out</span>
|
|
106
106
|
</DropdownMenuItem>
|
package/src/app/ui/alert.tsx
CHANGED
|
@@ -10,7 +10,7 @@ const alertVariants = cva(
|
|
|
10
10
|
variant: {
|
|
11
11
|
default: "bg-background text-foreground",
|
|
12
12
|
destructive:
|
|
13
|
-
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
|
13
|
+
"border-destructive/50 text-destructive-ink dark:border-destructive [&>svg]:text-destructive-ink",
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
defaultVariants: {
|
package/src/app/ui/form.tsx
CHANGED
|
@@ -125,7 +125,7 @@ const FormLabel = React.forwardRef<
|
|
|
125
125
|
return (
|
|
126
126
|
<Label
|
|
127
127
|
ref={ref}
|
|
128
|
-
className={cn(error && "text-destructive", className)}
|
|
128
|
+
className={cn(error && "text-destructive-ink", className)}
|
|
129
129
|
htmlFor={formItemId}
|
|
130
130
|
{...props}
|
|
131
131
|
/>
|
|
@@ -190,7 +190,7 @@ const FormMessage = React.forwardRef<
|
|
|
190
190
|
<p
|
|
191
191
|
ref={ref}
|
|
192
192
|
id={formMessageId}
|
|
193
|
-
className={cn("text-sm font-medium text-destructive", className)}
|
|
193
|
+
className={cn("text-sm font-medium text-destructive-ink", className)}
|
|
194
194
|
{...props}
|
|
195
195
|
>
|
|
196
196
|
{body}
|