@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.
Files changed (64) hide show
  1. package/README.md +187 -22
  2. package/bin/atelic-check-sentry.ts +5 -0
  3. package/dist/gate/middleware.js +15 -1
  4. package/dist/monitoring/server.d.ts +122 -0
  5. package/dist/monitoring/server.js +302 -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 +10 -2
  11. package/src/app/layout/DesktopRail.tsx +6 -4
  12. package/src/app/layout/MobileMenu.tsx +10 -5
  13. package/src/app/layout/MobileTabBar.tsx +3 -2
  14. package/src/app/layout/PageError.tsx +2 -2
  15. package/src/app/layout/SectionCards.tsx +7 -2
  16. package/src/app/layout/UserMenu.tsx +1 -1
  17. package/src/app/ui/alert.tsx +1 -1
  18. package/src/app/ui/form.tsx +2 -2
  19. package/src/artifact/AppErrorBoundary.tsx +12 -7
  20. package/src/chrome/BrandLockup.tsx +46 -7
  21. package/src/chrome/ContactDock.tsx +59 -13
  22. package/src/chrome/Footer.tsx +97 -28
  23. package/src/chrome/NavMegaPanel.tsx +11 -6
  24. package/src/chrome/SiteHeader.tsx +68 -18
  25. package/src/chrome/SiteMenu.tsx +207 -72
  26. package/src/chrome/SiteShell.tsx +25 -3
  27. package/src/chrome/StickyCTABar.tsx +24 -8
  28. package/src/chrome/index.ts +2 -0
  29. package/src/components/NotFound.tsx +3 -2
  30. package/src/gate/middleware.ts +15 -1
  31. package/src/lib/emailText.tsx +26 -0
  32. package/src/lib/phoneText.tsx +49 -0
  33. package/src/monitoring/ErrorCatcherScript.tsx +26 -0
  34. package/src/monitoring/catcher.ts +118 -0
  35. package/src/monitoring/index.ts +25 -0
  36. package/src/monitoring/sdk.ts +112 -0
  37. package/src/monitoring/server.ts +368 -0
  38. package/src/monitoring/start.ts +118 -0
  39. package/src/primitives/Button.tsx +3 -1
  40. package/src/primitives/Eyebrow.tsx +6 -2
  41. package/src/routing/index.ts +11 -32
  42. package/src/routing/miss.ts +32 -0
  43. package/src/routing/routerErrors.tsx +57 -0
  44. package/src/routing/staticNotFound.tsx +64 -0
  45. package/src/scripts/check-sentry.ts +98 -0
  46. package/src/sections/CalloutPanel.tsx +4 -1
  47. package/src/sections/ContactInfoCard.tsx +1 -1
  48. package/src/sections/FullBleedVideo.tsx +13 -4
  49. package/src/sections/Hero.tsx +10 -3
  50. package/src/sections/LinkColumns.tsx +30 -14
  51. package/src/sections/Locations.tsx +1 -1
  52. package/src/sections/LogoMarquee.tsx +1 -1
  53. package/src/sections/PricingBand.tsx +1 -1
  54. package/src/sections/ProcessSteps.tsx +1 -1
  55. package/src/sections/siteConfig.ts +67 -5
  56. package/src/styles/app.css +9 -0
  57. package/src/styles/base.css +34 -2
  58. package/src/styles/chrome.css +449 -41
  59. package/src/styles/defaults.css +61 -2
  60. package/src/styles/primitives.css +20 -7
  61. package/src/styles/sections.css +52 -9
  62. package/src/types.ts +40 -2
  63. package/src/vite/index.ts +4 -0
  64. package/src/vite/marketing-config.ts +81 -1
@@ -99,6 +99,60 @@
99
99
  --section-space: clamp(56px, 9vw, 120px);
100
100
  --block-gap: 44px;
101
101
  --card-min: 240px;
102
+
103
+ /* The optional tokens a theme sets to restyle one piece, each at the
104
+ look the piece had before it was a token (README.md, Tokens): the
105
+ ones whose default is a literal value or a system keyword. A color
106
+ whose old look was the inherited one is currentColor, which as a
107
+ color is exactly the inherited value.
108
+
109
+ A default that names another token is never declared here: it stays
110
+ an inline fallback where it is read, as --primary-fill and
111
+ --primary-ink always have, so it resolves on the element that reads
112
+ it, below any band that restates the named token. Declared here it
113
+ would resolve once, on the root, and a band restating --primary
114
+ would no longer reach it. Those defaults, each read in place (a
115
+ chain read more than once is written once, as a private property
116
+ on the component's own root): --header-max (--max-width) and
117
+ --header-gutter (--gutter), on .nav; --nav-open-bg (--hover-tint);
118
+ --menu-card-bg (--primary-deep) and --menu-card-ink (--on-primary),
119
+ the ink on .nav-feature; --menu-badge-bg and --menu-cta-bg
120
+ (--primary-fill, then --primary) and --menu-badge-ink and
121
+ --menu-cta-ink (--on-primary), the call to action's on
122
+ .mobile-menu; --heading-weight (--weight-heavy); the hero's
123
+ --hero-kicker-weight, --hero-kicker-tracking, and
124
+ --hero-kicker-size (the eyebrow's own, on .eyebrow);
125
+ --proof-star-fill (--primary); --footer-link (--neutral-200),
126
+ --footer-link-hover (--on-dark), --closing-link (--neutral-300),
127
+ and --closing-link-hover (--surface mixed with --on-dark);
128
+ --menu-rule (--hairline), on the light sheet. --hero-stack-gap has
129
+ no default of its own: unset, each gap in the hero keeps the value
130
+ it always had, in place. */
131
+ /* The open group's pill's words on the bar. */
132
+ --nav-open-ink: currentColor;
133
+ /* The header phone pill's padding and its number's size. */
134
+ --nav-phone-pad: 6px 16px 6px 12px;
135
+ --nav-phone-size: 0.95rem;
136
+ /* The page and section headings (h1, h2), and the smaller ones (h3 at
137
+ the tracking, h4 at two thirds of it). */
138
+ --heading-transform: none;
139
+ --heading-tracking: -0.02em;
140
+ --heading-color: currentColor;
141
+ --subheading-tracking: -0.015em;
142
+ /* The hero's lead paragraph: its size and its measure. */
143
+ --hero-lead-size: clamp(1.05rem, 2.2vw, 1.35rem);
144
+ --hero-lead-measure: 52ch;
145
+ /* A FeatureGrid card's title. */
146
+ --card-title-color: currentColor;
147
+ /* A CalloutPanel title's case, and its subtitle's case and tracking. */
148
+ --callout-transform: none;
149
+ --callout-sub-transform: none;
150
+ --callout-sub-tracking: normal;
151
+ /* The least a LinkColumns column narrows to. */
152
+ --link-columns-min: 170px;
153
+ /* The footer lockup's mark, and the line its links take on hover. */
154
+ --footer-mark-height: 38px;
155
+ --footer-link-hover-decoration: none;
102
156
  }
103
157
 
104
158
  /* ---- Long words ----
@@ -122,8 +176,13 @@
122
176
  overflow-wrap: break-word;
123
177
  }
124
178
  /* A phone number is one thing to read and dial, so it never breaks, at
125
- its spaces or its hyphen, wherever it is set (Component Rules 17). */
126
- :where(.atelic-ui a[href^="tel:"]) {
179
+ its spaces or its hyphen, wherever it is set (Component Rules 17). The
180
+ rule holds the number, never a whole row that links to a call: a tel
181
+ link of words alone is the number, and so is one of an icon beside the
182
+ words (every element in it an svg), held with its icon; a tel link
183
+ with more in it (a dock row, a label over the number) marks the number
184
+ .tel-number, which every such link the package draws does. */
185
+ :where(.atelic-ui a[href^="tel:"]:not(:has(:not(svg, svg *))), .atelic-ui .tel-number) {
127
186
  white-space: nowrap;
128
187
  }
129
188
 
@@ -229,21 +229,28 @@
229
229
  right — the wordmark's signature, in the brand's primary. This fade is
230
230
  the only rendering; the old leading-dash mode is retired. */
231
231
  .atelic-ui .eyebrow {
232
+ /* The eyebrow's own size, weight, and tracking, named once so a
233
+ context that restyles it (the hero's kicker tokens) falls back to
234
+ them rather than copying the values. */
235
+ --_eyebrow-size: 0.74rem;
236
+ --_eyebrow-weight: var(--weight-medium);
237
+ --_eyebrow-tracking: 0.18em;
232
238
  font-family: var(--font-mono);
233
- font-size: 0.74rem;
234
- font-weight: var(--weight-medium);
235
- letter-spacing: 0.18em;
239
+ font-size: var(--_eyebrow-size);
240
+ font-weight: var(--_eyebrow-weight);
241
+ letter-spacing: var(--_eyebrow-tracking);
236
242
  text-transform: uppercase;
237
243
  color: var(--primary-ink, var(--primary));
238
- display: inline-flex;
239
- align-items: center;
240
- gap: 0.6em;
244
+ /* Inline, so the rule follows the last line of a kicker that wraps
245
+ (a phone's narrow hero) rather than standing apart beside the whole
246
+ block, as a flex row set it. */
247
+ display: inline-block;
241
248
  }
242
249
  .atelic-ui .eyebrow.on-dark {
243
250
  color: var(--primary-bright);
244
251
  }
245
252
  .atelic-ui .eyebrow.center {
246
- justify-content: center;
253
+ text-align: center;
247
254
  }
248
255
  /* On the primary field the primary colored kicker would vanish, and so
249
256
  would a serif accent in a heading. Words on the fill take --on-primary
@@ -256,11 +263,17 @@
256
263
  .atelic-ui .on-primary em.serif {
257
264
  color: var(--on-primary);
258
265
  }
266
+ /* An eyebrow drawn without its trailing rule (Eyebrow rule={false}). */
267
+ .atelic-ui .eyebrow.no-rule::after {
268
+ display: none;
269
+ }
259
270
  .atelic-ui .eyebrow::after {
260
271
  content: "";
261
272
  width: 40px;
262
273
  height: 2px;
263
274
  display: inline-block;
275
+ vertical-align: middle;
276
+ margin-left: 0.6em;
264
277
  /* Themes with a dedicated ruling accent (a brand color reserved for
265
278
  rules, never text) set --rule-accent; default stays the text color. */
266
279
  background: linear-gradient(90deg, var(--rule-accent, currentColor), transparent);
@@ -44,11 +44,17 @@
44
44
 
45
45
  /* A title fills the line before it wraps, where the base headings balance
46
46
  their lines; pretty still keeps a last word from standing alone. */
47
+ /* A card's title in a list: an h2 for the outline, but never the brand's
48
+ headline style, so it pins the look the heading tokens would set. */
47
49
  .atelic-ui .bi-title {
48
50
  margin: 0 0 10px;
49
51
  font-size: 1.4rem;
50
52
  line-height: 1.25;
51
53
  text-wrap: pretty;
54
+ text-transform: none;
55
+ font-weight: var(--weight-heavy);
56
+ letter-spacing: -0.02em;
57
+ color: inherit;
52
58
  }
53
59
 
54
60
  .atelic-ui .bi-excerpt {
@@ -928,6 +934,7 @@
928
934
  }
929
935
  .atelic-ui .feature-card h3 {
930
936
  margin: 14px 0 10px;
937
+ color: var(--card-title-color);
931
938
  }
932
939
  .atelic-ui .feature-card p {
933
940
  color: var(--ink-soft);
@@ -1066,14 +1073,26 @@
1066
1073
  padding-bottom: clamp(48px, 9vh, 110px);
1067
1074
  padding-top: calc(var(--nav-height) + 30px);
1068
1075
  }
1076
+ /* The room between the hero's kicker, headline, lead, and actions: each
1077
+ its own as it always was (18, 22, and 32px; 12, 22, and 26px on the
1078
+ split hero), or one --hero-stack-gap for all three when a theme sets
1079
+ it, so each read keeps its own default in place. */
1069
1080
  .atelic-ui .hero h1 {
1070
1081
  color: var(--on-dark);
1071
- margin: 18px 0 0;
1082
+ margin: var(--hero-stack-gap, 18px) 0 0;
1072
1083
  text-shadow: 0 2px 30px color-mix(in srgb, var(--shade) 25%, transparent);
1073
1084
  }
1074
1085
  .atelic-ui .hero h1 .serif {
1075
1086
  color: var(--primary-bright);
1076
1087
  }
1088
+ /* The hero's eyebrow line, at the eyebrow primitive's own look (its
1089
+ private properties, primitives.css) unless a theme sets the hero's
1090
+ kicker tokens. */
1091
+ .atelic-ui .hero .eyebrow {
1092
+ font-size: var(--hero-kicker-size, var(--_eyebrow-size));
1093
+ font-weight: var(--hero-kicker-weight, var(--_eyebrow-weight));
1094
+ letter-spacing: var(--hero-kicker-tracking, var(--_eyebrow-tracking));
1095
+ }
1077
1096
  /* On the split hero the headline sits on the primary field, where the
1078
1097
  bright primary all but vanishes (1.38 to 1 on the practice's palette):
1079
1098
  the accent keeps its italic and takes the field's own words. */
@@ -1082,9 +1101,9 @@
1082
1101
  color: var(--on-primary);
1083
1102
  }
1084
1103
  .atelic-ui .hero-sub {
1085
- font-size: clamp(1.05rem, 2.2vw, 1.35rem);
1086
- max-width: 52ch;
1087
- margin-top: 22px;
1104
+ font-size: var(--hero-lead-size);
1105
+ max-width: var(--hero-lead-measure);
1106
+ margin-top: var(--hero-stack-gap, 22px);
1088
1107
  color: color-mix(in srgb, var(--on-dark) 92%, transparent);
1089
1108
  line-height: 1.55;
1090
1109
  }
@@ -1142,6 +1161,14 @@
1142
1161
  display: inline-flex;
1143
1162
  }
1144
1163
  }
1164
+ /* The contact dock holds the screen's bottom right corner, where the cue
1165
+ sits, so on a page that wears the dock the cue moves to the middle of
1166
+ the hero's foot. A page without the dock keeps it at the right. */
1167
+ .atelic-ui:has(.contact-dock) .hero-scroll {
1168
+ right: auto;
1169
+ left: 50%;
1170
+ margin-left: -23px;
1171
+ }
1145
1172
 
1146
1173
  /* The split layout: the copy and its actions on the primary field on one
1147
1174
  side, the photo on the other, at the height the copy needs. The copy
@@ -1166,7 +1193,10 @@
1166
1193
  .atelic-ui .hero-split-inner {
1167
1194
  --hero-split-edge: max(var(--gutter), calc((100cqw - var(--max-width)) / 2 + var(--gutter)));
1168
1195
  width: 100%;
1169
- padding: var(--section-space) var(--hero-split-edge);
1196
+ /* --hero-split-pad sets the copy's sides outright, for a design that
1197
+ wants them tighter than the wrap's edge. Its default is the edge
1198
+ computed on this element, so it stays at the read. */
1199
+ padding: var(--section-space) var(--hero-split-pad, var(--hero-split-edge));
1170
1200
  }
1171
1201
  /* From 900px the copy sits beside the photo under the transparent header;
1172
1202
  below it the photo stacks first and takes the header, so the copy needs
@@ -1179,14 +1209,17 @@
1179
1209
  .atelic-ui .hero.is-split h1 {
1180
1210
  font-size: clamp(2.1rem, 4vw, 3.3rem);
1181
1211
  line-height: 1.05;
1182
- margin-top: 12px;
1212
+ margin-top: var(--hero-stack-gap, 12px);
1183
1213
  text-shadow: none;
1184
1214
  }
1185
1215
  .atelic-ui .hero.is-split .hero-sub {
1186
1216
  color: var(--on-primary);
1187
1217
  }
1218
+ .atelic-ui .hero .cta-row {
1219
+ margin-top: var(--hero-stack-gap, 32px);
1220
+ }
1188
1221
  .atelic-ui .hero.is-split .cta-row {
1189
- margin-top: 26px;
1222
+ margin-top: var(--hero-stack-gap, 26px);
1190
1223
  }
1191
1224
  .atelic-ui .hero-split-media {
1192
1225
  position: relative;
@@ -1243,6 +1276,10 @@
1243
1276
  font-size: 1.08rem;
1244
1277
  line-height: 1.25;
1245
1278
  }
1279
+ /* A star row in a proof value takes --proof-star-fill, else the primary it always read. */
1280
+ .atelic-ui .proof-strip-value .star-row {
1281
+ color: var(--proof-star-fill, var(--primary));
1282
+ }
1246
1283
  /* Classed, never a bare span: a value may hold a star row, whose own spans keep their color. */
1247
1284
  .atelic-ui .proof-strip-label {
1248
1285
  font-size: 0.86rem;
@@ -1673,7 +1710,7 @@
1673
1710
  aligned on its line in tabular numerals. */
1674
1711
  .atelic-ui .link-columns {
1675
1712
  display: grid;
1676
- grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
1713
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--link-columns-min)), 1fr));
1677
1714
  gap: 24px 28px;
1678
1715
  }
1679
1716
  .atelic-ui * + .link-columns {
@@ -1701,7 +1738,7 @@
1701
1738
  padding: 7px 0;
1702
1739
  color: var(--ink-soft);
1703
1740
  }
1704
- .atelic-ui .lc-link:hover {
1741
+ .atelic-ui a.lc-link:hover {
1705
1742
  color: var(--primary-ink, var(--primary));
1706
1743
  }
1707
1744
  .atelic-ui .lc-label {
@@ -1742,6 +1779,7 @@
1742
1779
  min-width: 0;
1743
1780
  }
1744
1781
  .atelic-ui .callout-panel-title {
1782
+ text-transform: var(--callout-transform);
1745
1783
  font-family: var(--font-condensed, var(--font-heading, var(--font-sans)));
1746
1784
  font-size: clamp(1.35rem, 2.15vw, 1.9rem);
1747
1785
  font-weight: var(--weight-heavy);
@@ -1750,6 +1788,11 @@
1750
1788
  text-wrap: balance;
1751
1789
  }
1752
1790
  .atelic-ui .callout-panel-sub {
1791
+ /* Inherited unless a theme sets it: no custom property can hold
1792
+ inherit as a default, so the fallback stays at the read. */
1793
+ font-family: var(--callout-sub-font, inherit);
1794
+ text-transform: var(--callout-sub-transform);
1795
+ letter-spacing: var(--callout-sub-tracking);
1753
1796
  font-size: clamp(0.85rem, 1.1vw, 1rem);
1754
1797
  line-height: 1.3;
1755
1798
  color: var(--on-primary);
package/src/types.ts CHANGED
@@ -22,7 +22,7 @@
22
22
  */
23
23
  export interface BrandLogo {
24
24
  src?: string;
25
- /** Alt text where the mark stands alone, as in the footer. */
25
+ /** Alt text where the mark stands alone: the footer's, when `wordmark` is false. */
26
26
  alt?: string;
27
27
  tile?: string;
28
28
  /** The live name beside the mark; `false` leaves it out. Defaults to the brand's name. */
@@ -97,6 +97,11 @@ export interface NavGroupLink extends NavGroupChildLink {
97
97
  description?: string;
98
98
  /** Links drawn indented under this one on a desktop and a phone alike. */
99
99
  children?: NavGroupChildLink[];
100
+ /**
101
+ * Sets the link in the panel's quieter words and regular weight, for a
102
+ * long list such as the towns under a region's heading. Off by default.
103
+ */
104
+ quiet?: boolean;
100
105
  }
101
106
 
102
107
  /**
@@ -200,8 +205,33 @@ export interface NavFeature {
200
205
 
201
206
  /** A number the header shows, with the words that say whose line it is. */
202
207
  export interface HeaderPhone extends Phone {
203
- /** Printed small over the number and read with it, e.g. "Mountain office". */
208
+ /**
209
+ * Printed small over the number in the desktop bar's phone pill and read
210
+ * with it, e.g. "Mountain office". The phone menu's line falls back to it.
211
+ */
204
212
  label?: string;
213
+ /**
214
+ * The phone menu's words for this number, when they should differ from
215
+ * the bar's `label`, e.g. "Call or text" for a line that answers texts.
216
+ * Defaults to `label`, then to "Call".
217
+ */
218
+ menuLabel?: string;
219
+ }
220
+
221
+ /**
222
+ * The phone menu's sheet: `dark`, the full screen sheet on the dark surface
223
+ * with large light links, or `light`, the page's own ground with the lockup
224
+ * and a round close button across the top, the entries as rows, and the call
225
+ * to action and the numbers in a foot on the alternate ground.
226
+ */
227
+ export type SiteMenuSurface = "dark" | "light";
228
+
229
+ /** How the burger that opens the phone menu is drawn. */
230
+ export interface MenuBurgerStyle {
231
+ /** Sets the three lines before the words (`menuLabel`) rather than after them. Off by default. */
232
+ labelAfter?: boolean;
233
+ /** Draws the burger inside an outlined pill. Off by default. */
234
+ outlined?: boolean;
205
235
  }
206
236
 
207
237
  /** A conversion action rendered as a button link. */
@@ -210,6 +240,14 @@ export interface CallToAction {
210
240
  href: string;
211
241
  /** Opens in a new tab, except on mailto, tel, and sms links. */
212
242
  external?: boolean;
243
+ /** The header's button carries the arrow a hero's primary button shows. Off by default. */
244
+ arrow?: boolean;
245
+ /**
246
+ * The phone menu's words for the action, when they should differ from
247
+ * `label` (a fuller "Order ahead for Saturday" where the bar says "Order
248
+ * ahead"). Defaults to `label`.
249
+ */
250
+ menuLabel?: string;
213
251
  }
214
252
 
215
253
  /** A footer or legal link that may open in a new tab. */
package/src/vite/index.ts CHANGED
@@ -10,10 +10,14 @@ export {
10
10
  artifactPages,
11
11
  } from "./artifact-config.js";
12
12
  export {
13
+ buildRelease,
14
+ environmentPlugin,
13
15
  type MarketingConfigOptions,
14
16
  type MarketingPage,
15
17
  marketingBasePath,
16
18
  marketingConfig,
17
19
  NOT_FOUND_PAGE,
20
+ type SentryUpload,
21
+ sentryUpload,
18
22
  } from "./marketing-config.js";
19
23
  export { DOC_DIR, isPrivateContent, privateChunks } from "./private-chunks.js";
@@ -15,7 +15,7 @@
15
15
  import { resolve } from "node:path";
16
16
  import { tanstackStart } from "@tanstack/react-start/plugin/vite";
17
17
  import react from "@vitejs/plugin-react";
18
- import { mergeConfig, type UserConfig } from "vite";
18
+ import { mergeConfig, type Plugin, type PluginOption, type UserConfig } from "vite";
19
19
  import { normalizeBasePath } from "../routing/basePath.js";
20
20
 
21
21
  /** One entry of the prerender list, as TanStack Start takes it. */
@@ -49,6 +49,76 @@ export interface MarketingConfigOptions {
49
49
  env?: Record<string, string | undefined>;
50
50
  }
51
51
 
52
+ /**
53
+ * The commit a build is filed under in Sentry: Vercel's commit, else the CI's.
54
+ * The same value names the release the Sentry plugin creates and the release
55
+ * the browser reports under, so a stack trace meets its source maps.
56
+ */
57
+ export function buildRelease(
58
+ env: Record<string, string | undefined> = process.env,
59
+ ): string | undefined {
60
+ return env.VERCEL_GIT_COMMIT_SHA || env.GITHUB_SHA || undefined;
61
+ }
62
+
63
+ /** What the Sentry plugin is given, when it runs at all. */
64
+ export interface SentryUpload {
65
+ org: string;
66
+ project: string;
67
+ authToken: string;
68
+ release: string;
69
+ }
70
+
71
+ /**
72
+ * The source map upload, on only when `SENTRY_AUTH_TOKEN`, `SENTRY_ORG`, and
73
+ * `SENTRY_PROJECT` are all set and the build knows its commit. Off, the
74
+ * build is exactly what it was: no plugin, no source maps.
75
+ */
76
+ export function sentryUpload(
77
+ env: Record<string, string | undefined> = process.env,
78
+ ): SentryUpload | undefined {
79
+ const { SENTRY_AUTH_TOKEN: authToken, SENTRY_ORG: org, SENTRY_PROJECT: project } = env;
80
+ const release = buildRelease(env);
81
+ if (!authToken || !org || !project || !release) return undefined;
82
+ return { org, project, authToken, release };
83
+ }
84
+
85
+ /**
86
+ * The Sentry Vite plugin, loaded only when it runs: it creates the release
87
+ * named by the commit, uploads the build's hidden source maps, and deletes
88
+ * every map file from the output afterwards, so none is ever served.
89
+ */
90
+ function sentryPlugin(upload: SentryUpload): PluginOption {
91
+ return import("@sentry/vite-plugin").then(
92
+ ({ sentryVitePlugin }) =>
93
+ sentryVitePlugin({
94
+ org: upload.org,
95
+ project: upload.project,
96
+ authToken: upload.authToken,
97
+ release: { name: upload.release, inject: false },
98
+ sourcemaps: { filesToDeleteAfterUpload: ["./dist/**/*.map"] },
99
+ telemetry: false,
100
+ }) as PluginOption,
101
+ );
102
+ }
103
+
104
+ /**
105
+ * The environment the browser files its errors under, as
106
+ * `import.meta.env.VITE_ENVIRONMENT`: Vercel's (production, preview,
107
+ * development) when the build runs there, else the build's mode. A Vite
108
+ * production build's mode is production on every deploy, a preview's
109
+ * included, so the mode alone filed every error as production.
110
+ */
111
+ export function environmentPlugin(env: Record<string, string | undefined> = process.env): Plugin {
112
+ return {
113
+ name: "atelic-build-environment",
114
+ config: (_config, { mode }) => ({
115
+ define: {
116
+ "import.meta.env.VITE_ENVIRONMENT": JSON.stringify(env.VERCEL_ENV || mode),
117
+ },
118
+ }),
119
+ };
120
+ }
121
+
52
122
  /** The 404 page, prerendered and copied to 404.html by the build, never in the sitemap. */
53
123
  export const NOT_FOUND_PAGE: MarketingPage = {
54
124
  path: "/404",
@@ -84,6 +154,8 @@ export function marketingConfig({
84
154
  env = process.env,
85
155
  }: MarketingConfigOptions): UserConfig {
86
156
  const basePath = marketingBasePath(site, env);
157
+ const release = buildRelease(env);
158
+ const upload = sentryUpload(env);
87
159
  const listed = pages.filter((page) => page.path !== NOT_FOUND_PAGE.path);
88
160
  const config: UserConfig = {
89
161
  // The base becomes Vite's `base`, so every built asset URL and every
@@ -110,7 +182,15 @@ export function marketingConfig({
110
182
  },
111
183
  }),
112
184
  react(),
185
+ environmentPlugin(env),
186
+ ...(upload ? [sentryPlugin(upload)] : []),
113
187
  ],
188
+ // The commit, for the browser to report under (`startErrorReporting`'s
189
+ // `release`), read as `import.meta.env.VITE_RELEASE`.
190
+ ...(release ? { define: { "import.meta.env.VITE_RELEASE": JSON.stringify(release) } } : {}),
191
+ // Maps only for Sentry, and hidden: the bundles carry no comment
192
+ // pointing at one, and the plugin deletes them once uploaded.
193
+ ...(upload ? { build: { sourcemap: "hidden" as const } } : {}),
114
194
  resolve: {
115
195
  alias: {
116
196
  // The site's src, from the directory Vite is run in: this file