@marktiderman/genesis-sites 0.8.0 → 0.9.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 +128 -11
  2. package/SKILL.md +5 -0
  3. package/dist/analytics.d.ts +184 -0
  4. package/dist/analytics.js +3 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/assets/islands.399b13ea6f.js +1 -0
  7. package/dist/assets/sites-forms.b64c156079.css +10 -0
  8. package/dist/assets/sites-forms.css +1 -1
  9. package/dist/assets/sites.2fac65f96a.css +2 -0
  10. package/dist/assets/sites.css +1 -1
  11. package/dist/assets.generated-ZBFSP23U.js +3 -0
  12. package/dist/{assets.generated-YGLB7VKL.js.map → assets.generated-ZBFSP23U.js.map} +1 -1
  13. package/dist/{chunk-MXV2HOJO.js → chunk-5G2H6EZ2.js} +6 -6
  14. package/dist/chunk-5G2H6EZ2.js.map +1 -0
  15. package/dist/chunk-5RYCQEEE.js +256 -0
  16. package/dist/chunk-5RYCQEEE.js.map +1 -0
  17. package/dist/{chunk-FMQTSXJN.js → chunk-ATRS5GSD.js} +60 -19
  18. package/dist/chunk-ATRS5GSD.js.map +1 -0
  19. package/dist/{chunk-MU2Z2C4F.js → chunk-CXBBUKGB.js} +14 -4
  20. package/dist/chunk-CXBBUKGB.js.map +1 -0
  21. package/dist/{chunk-6CXTOPYI.js → chunk-QGU6FDH5.js} +74 -8
  22. package/dist/chunk-QGU6FDH5.js.map +1 -0
  23. package/dist/{chunk-I767PDBR.js → chunk-SBONYMUC.js} +38 -15
  24. package/dist/chunk-SBONYMUC.js.map +1 -0
  25. package/dist/{chunk-YAMQ2JKO.js → chunk-UOKNFG5O.js} +127 -14
  26. package/dist/chunk-UOKNFG5O.js.map +1 -0
  27. package/dist/{chunk-QE7KS2JS.js → chunk-UUC5USJH.js} +8 -45
  28. package/dist/chunk-UUC5USJH.js.map +1 -0
  29. package/dist/editor.d.ts +63 -14
  30. package/dist/editor.js +682 -254
  31. package/dist/editor.js.map +1 -1
  32. package/dist/handler-OR554RTS.js +11 -0
  33. package/dist/{handler-J5BCH2VW.js.map → handler-OR554RTS.js.map} +1 -1
  34. package/dist/import.d.ts +3 -3
  35. package/dist/import.js +1 -1
  36. package/dist/index.d.ts +23 -9
  37. package/dist/index.js +4 -4
  38. package/dist/{redirects-BNSD9MKa.d.ts → redirects-LcCNIJHQ.d.ts} +2 -2
  39. package/dist/{registry-BPn-tDlL.d.ts → registry-Cw7NF_le.d.ts} +17 -1
  40. package/dist/sections.d.ts +1 -1
  41. package/dist/sections.js +3 -3
  42. package/dist/{store-B_GMH42V.d.ts → store-BNYD5NAQ.d.ts} +30 -4
  43. package/dist/supabase.d.ts +4 -4
  44. package/dist/supabase.js +4 -4
  45. package/dist/{templates-CFSSG1iU.d.ts → templates-DPv0OYLl.d.ts} +2 -2
  46. package/dist/templates.d.ts +3 -3
  47. package/dist/templates.js +7 -3
  48. package/dist/templates.js.map +1 -1
  49. package/dist/{theme-Dw42GDI_.d.ts → theme-HJzN2tOm.d.ts} +2 -2
  50. package/dist/web.d.ts +49 -13
  51. package/dist/web.js +7 -6
  52. package/package.json +6 -2
  53. package/dist/assets/islands.83aaf5e0df.js +0 -1
  54. package/dist/assets/sites-forms.bac9a6aafd.css +0 -10
  55. package/dist/assets/sites.323090ba26.css +0 -2
  56. package/dist/assets.generated-YGLB7VKL.js +0 -3
  57. package/dist/chunk-6CXTOPYI.js.map +0 -1
  58. package/dist/chunk-FMQTSXJN.js.map +0 -1
  59. package/dist/chunk-I767PDBR.js.map +0 -1
  60. package/dist/chunk-MU2Z2C4F.js.map +0 -1
  61. package/dist/chunk-MXV2HOJO.js.map +0 -1
  62. package/dist/chunk-QE7KS2JS.js.map +0 -1
  63. package/dist/chunk-YAMQ2JKO.js.map +0 -1
  64. package/dist/handler-J5BCH2VW.js +0 -10
package/README.md CHANGED
@@ -179,11 +179,18 @@ const editorStore = withCacheInvalidation(store, (tags, { action }) =>
179
179
  );
180
180
  ```
181
181
 
182
- Archiving a site, or editing its brand, doesn't go through the store: purge
183
- the tag there too (the database sends a `genesis_sites` notification on every
184
- publish, rollback and archive, for a listener). A page rendered with a brand
185
- that changed since the release was checked is served with a 5-minute cache
186
- and a warning until you publish again. A failed purge is logged and rethrown.
182
+ Archiving a site doesn't go through the store: purge the tag there too (the
183
+ database sends a `genesis_sites` notification on every publish, rollback and
184
+ archive, for a listener). A failed purge is logged and rethrown.
185
+
186
+ A release keeps the brand it was published with (`snapshot.brand`), and the
187
+ live site renders with it: editing the brand changes the editor and the
188
+ preview at once, and the live site with the next publish, so a brand edit
189
+ needs no purge, and a rollback brings back the look the site had. The
190
+ Publish panel says when the look changed since the live release. The brand
191
+ is public, like the page it styles. A release from before releases kept
192
+ their brand renders with the host's current brand, cached for 5 minutes
193
+ with a warning when that brand changed since it was checked.
187
194
 
188
195
  A hidden section stays in the draft and is left out of the release, so it is
189
196
  never public. A stored page that no longer parses is left out of the site
@@ -331,6 +338,12 @@ props; `migrateNode` runs the steps on read and a publish writes the result
331
338
  into the release. `sectionJsonSchema(type)` gives the props' JSON Schema (for
332
339
  editor fields and AI output) and `sectionManifests()` the editor's catalog.
333
340
 
341
+ Mark a preset `sample: true` when its props are made-up content its owner must
342
+ replace (names, prices, times, quotes, an address, or copy that says what to
343
+ write). A section added from it, in the editor or with `nodeFromPreset`, is a
344
+ placeholder: the publish check holds it until it is edited or hidden, and the
345
+ editor shows its text as hints, so typing replaces the sample.
346
+
334
347
  ## Design systems
335
348
 
336
349
  A brand is identity (name, colours, fonts, logo). A **design system** is the
@@ -411,9 +424,7 @@ for (const template of Object.values(industryTemplates)) {
411
424
  }
412
425
  ```
413
426
 
414
- CI (`scripts/check-industry-words.mjs`, word list in
415
- `scripts/industry-words.mjs`) fails on industry words anywhere in this
416
- package but `src/templates/`.
427
+ Keep industry words out of this package but `src/templates/`.
417
428
 
418
429
  ## Publish checks
419
430
 
@@ -430,7 +441,9 @@ to publish (`PublishBlockedError`, with `issues`) when:
430
441
  pairs, which are solved to pass);
431
442
  - an image has no alt text and isn't marked decorative;
432
443
  - a section is unknown, has invalid props or was saved by newer code;
433
- - a template placeholder is still visible;
444
+ - a template placeholder, or a section added from a `sample` preset, is still
445
+ visible and unedited (on a landing page, the message says it can be deleted
446
+ to publish the rest of the site);
434
447
  - a page path is malformed or reserved, or the site has no home page;
435
448
  - on a site with `images: "own"`, an image, a file or the brand's logo loads
436
449
  from a host other than the site and the store's asset origin.
@@ -444,6 +457,25 @@ host says how to fix it: upload it again, or copy the old site's files with
444
457
  the same `{ images, assetOrigins }` as its third argument; the stores pass the
445
458
  site's setting when they publish a post.
446
459
 
460
+ ## Show dates
461
+
462
+ A page can be shown only between two times: `showFrom` and `showUntil` on its
463
+ root props (ISO times with an offset), set in the editor's Publish tab under
464
+ "Show dates" (in the editor's time zone). Before the start and from the end,
465
+ the published page is as if it weren't there: an unknown path (its 404 page
466
+ with `unknownPath: "not-found"`), and out of the sitemap. The editor's preview
467
+ always shows it. A sale's landing page that ends at midnight needs no publish
468
+ and no purge job: the page, its 404 answer, a prefix redirect over it and the
469
+ sitemap are cached no longer than the next boundary (`s-maxage` up to it, and
470
+ no `stale-while-revalidate`), so the CDN asks again then. That holds for what
471
+ the package answers: with the default `unknownPath: "fall-through"` a hidden
472
+ page returns `null`, and the host serves its own 404 and owns its cache, so
473
+ keep that 404 out of the shared cache (or use `"not-found"`) for the page to
474
+ appear on time. `handleSiteRequest`'s `now` sets the clock for
475
+ tests. A publish refuses an end before its start, and dates on the home page,
476
+ the 404 page or the blog's post page. `isPageShown`, `nextPageBoundary`,
477
+ `pageWindow` and `pageWindowProblems` are exported.
478
+
447
479
  ## SEO
448
480
 
449
481
  Each page gets a title from the site's template (`%s · Riverside Works`), a
@@ -483,6 +515,51 @@ visitor's query string. `matchPrefixRedirect` and `isUnderPrefix` are exported;
483
515
  a release refuses a prefix redirect from `/`, one into its own prefix (it would
484
516
  redirect again), and `keepRest` on an exact one.
485
517
 
518
+ ## Analytics
519
+
520
+ First-party and server-side: no third-party script on the page, nothing
521
+ stored on the visitor's device, and the Content-Security-Policy is unchanged.
522
+ Pass `analytics` to `handleSiteRequest` and every live page loads the islands
523
+ loader, which sends a small beacon to the site's own `/_gs/e`: a page view,
524
+ and clicks on links with `data-gs-event`, links off the site, and downloads.
525
+ `collect` gets each beacon with the request, but only from the site's own pages
526
+ (a beacon whose `Origin` or `Sec-Fetch-Site` names another site, or that has
527
+ neither, is answered 204 and dropped). A beacon's page address keeps only its
528
+ campaign tags (`utm_*`, `gclid`, `gbraid`, `wbraid`) from the query, in the page
529
+ and again in `beaconEvent`, so a prefilled email or a token never reaches a
530
+ provider. The request waits for `collect`: forward after the response, with
531
+ `waitUntil` or a queue, using `@marktiderman/genesis-sites/analytics`:
532
+
533
+ ```ts
534
+ import { beaconEvent, forwardEvent, sendsGpc, visitorId } from "@marktiderman/genesis-sites/analytics";
535
+
536
+ handleSiteRequest(request, {
537
+ ...options,
538
+ analytics: {
539
+ async collect(beacon, { request, siteId, origin }) {
540
+ const destinations = await destinationsFor(siteId); // { ga4?: { measurementId, apiSecret }, meta?: { pixelId, accessToken } }
541
+ if (!destinations) return;
542
+ const visitor = await visitorId({ salt: env.ANALYTICS_SALT, siteId, ip: clientIp(request), userAgent: request.headers.get("user-agent") ?? "" });
543
+ waitUntil(forwardEvent(beaconEvent(beacon, { origin, visitor, id: crypto.randomUUID(), gpc: sendsGpc(request) }), destinations));
544
+ },
545
+ },
546
+ });
547
+ ```
548
+
549
+ Your server records the conversions where they happen (`lead`, `sign_up`,
550
+ `submit_form`, `schedule`, `start_trial`, `purchase`) as a `SiteEvent` and
551
+ forwards them the same way. GA4 gets them through the Measurement Protocol,
552
+ Meta through the Conversions API (`ga4Request` and `metaRequest` build the
553
+ requests, for a queue of your own).
554
+
555
+ Personal data: a visitor is a daily hash of a secret salt, the site, the day,
556
+ the IP address and the browser, so a day's visits count once and nothing
557
+ identifies the visitor. An event carries an email or phone (hashed), the IP
558
+ address or the browser only with `consent.personalData`, which your server
559
+ sets when the person agreed (a form's or an offer's consent tick); a beacon
560
+ never has it. Meta gets only events with consent, and nothing from a browser
561
+ that sends Global Privacy Control.
562
+
486
563
  ## Forms
487
564
 
488
565
  A `form-embed` section names a form by slug. Your `forms` resolver says what
@@ -514,11 +591,42 @@ forms: (slug) =>
514
591
  same fields as an ordinary form.
515
592
  - A definition that needs the engine renders with forms-web's `<Form>`, and
516
593
  the form bundle loads on that page only.
517
- - `embed` shows an https URL in a sandboxed iframe.
594
+ - `embed` shows an https URL in a sandboxed iframe. An http URL on this
595
+ computer (`localhost`, `127.0.0.1`, `[::1]`, `*.localhost`) is framed too,
596
+ so a local stack's forms show while you build.
518
597
 
519
598
  Either way, your endpoint checks the answers again (`validateSubmission` from
520
599
  genesis-forms). An unknown slug renders nothing and logs.
521
600
 
601
+ In the editor, give `<SiteEditor>` a `listForms` service
602
+ (`() => Promise<{ slug, title }[]>`) and the form section's field becomes a
603
+ picker of your forms. Pass `listForms` (and `forms`) to `checkSite` and
604
+ `publishSite` too: a form section whose slug isn't on that list is flagged
605
+ (`form-missing`), so the check agrees with the picker. Without
606
+ `listForms`, the check asks the `forms` resolver, which must then return null
607
+ for a slug you don't have (a resolver that embeds any slug passes them all).
608
+
609
+ The Photo grid and Logo row start with sample pictures (`/_gs/sample/…`),
610
+ drawn inline in the editor and the preview. The check (`sample-image`) names
611
+ the section and the picture to replace.
612
+
613
+ ### Checks the app chooses
614
+
615
+ Those two checks are yours to set, on `<SiteEditor checks>`, `checkSite` and
616
+ `publishSite`. Each one blocks the publish, warns in the Publish panel, or is
617
+ off; left out, it warns. A store's `publish` and `checkRelease` take
618
+ `sampleImages` only: the forms check needs your forms, so it runs in
619
+ `checkSite`.
620
+
621
+ ```tsx
622
+ <SiteEditor checks={{ sampleImages: "block", missingForms: "warn" }} … />
623
+ ```
624
+
625
+ | Key | Issue | Flags |
626
+ | --- | --- | --- |
627
+ | `sampleImages` | `sample-image` | a section still showing a starter sample picture |
628
+ | `missingForms` | `form-missing` | a form section naming no form you have (off: the host isn't asked) |
629
+
522
630
  ## The blog
523
631
 
524
632
  A site's posts live beside its pages, each with a draft and a published
@@ -661,7 +769,16 @@ import { SiteEditor } from "@marktiderman/genesis-sites/editor";
661
769
  </div>;
662
770
  ```
663
771
 
664
- `SiteEditor` fills its parent, so give the parent a height. Props:
772
+ `SiteEditor` fills its parent, so give the parent a height. On Vite, an app
773
+ that leaves genesis-sites out of `optimizeDeps` (to keep its generated assets
774
+ out of the pre-bundle) must pre-bundle its CommonJS dependencies itself, or
775
+ the editor's preview fails in dev ("no export named renderToReadableStream"):
776
+
777
+ ```ts
778
+ optimizeDeps: { exclude: ["@marktiderman/genesis-sites"], include: ["@puckeditor/core", "react-dom/server"] },
779
+ ```
780
+
781
+ Props:
665
782
 
666
783
  | Prop | |
667
784
  |---|---|
package/SKILL.md CHANGED
@@ -57,4 +57,9 @@ Then, as `genesis add` prints:
57
57
  everything under it" (`match: "prefix"`, optionally `keepRest`), not one per old page; pages
58
58
  under it still show. There are no pattern redirects: list stray old addresses one by one.
59
59
 
60
+ - A page that must disappear (or appear) at a set time gets Show dates in its Publish tab
61
+ (`showFrom`/`showUntil`); never a scheduled publish. With `unknownPath: "not-found"` its cache ends
62
+ at the boundary and no purge job is needed; with the default `"fall-through"` the host serves and
63
+ caches its own 404, so keep that 404 out of the shared cache.
64
+
60
65
  Details: the package README and [docs/SITES.md](https://github.com/marktiderman/genesis/blob/main/docs/SITES.md).
@@ -0,0 +1,184 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * First-party, server-side analytics for a site: the page sends a small
5
+ * beacon to its own address (`/_gs/e`), and the host forwards events (those
6
+ * beacons, and the conversions its own server code records) to Google
7
+ * Analytics 4 through the Measurement Protocol and to Meta through the
8
+ * Conversions API. No third-party script runs on the page, nothing is stored
9
+ * on the visitor's device, and the Content-Security-Policy doesn't change.
10
+ *
11
+ * Personal data:
12
+ * - A visitor is a daily hash of their IP address and browser with a secret
13
+ * salt (`visitorId`), so a day's visits count once and nothing identifies
14
+ * them; the hash changes every day.
15
+ * - Events carry personal data (an email or phone, hashed; the IP address;
16
+ * the browser) only when the person agreed to it (`consent.personalData`),
17
+ * such as by ticking a form's or an offer's consent. Meta gets only events
18
+ * with consent: without it, it gets nothing.
19
+ * - A browser that sends Global Privacy Control (`Sec-GPC: 1`) is never sent
20
+ * to Meta, whatever the consent.
21
+ */
22
+
23
+ /** The page's events, sent by the islands loader. */
24
+ declare const BEACON_EVENTS: readonly ["page_view", "click", "outbound", "download"];
25
+ /** The events the host's server records where they happen. */
26
+ declare const CONVERSION_EVENTS: readonly ["lead", "sign_up", "submit_form", "schedule", "start_trial", "purchase"];
27
+ type BeaconEventName = (typeof BEACON_EVENTS)[number];
28
+ type ConversionEventName = (typeof CONVERSION_EVENTS)[number];
29
+ type SiteEventName = BeaconEventName | ConversionEventName;
30
+ /** The path a site page sends its beacon to, under the site's base path. */
31
+ declare const BEACON_PATH = "/_gs/e";
32
+ /** The most a beacon's body may be. */
33
+ declare const BEACON_MAX_BYTES = 2048;
34
+ /** What the islands loader sends: short keys, no personal data. */
35
+ declare const SiteBeacon: z.ZodObject<{
36
+ n: z.ZodEnum<{
37
+ page_view: "page_view";
38
+ click: "click";
39
+ outbound: "outbound";
40
+ download: "download";
41
+ }>;
42
+ p: z.ZodString;
43
+ r: z.ZodOptional<z.ZodString>;
44
+ e: z.ZodOptional<z.ZodString>;
45
+ h: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strip>;
47
+ type SiteBeacon = z.infer<typeof SiteBeacon>;
48
+ interface SiteEventUser {
49
+ email?: string | undefined;
50
+ phone?: string | undefined;
51
+ firstName?: string | undefined;
52
+ lastName?: string | undefined;
53
+ /** The host's own id for the person (hashed before it leaves). */
54
+ externalId?: string | undefined;
55
+ }
56
+ /** One event to forward. */
57
+ interface SiteEvent {
58
+ name: SiteEventName;
59
+ /** When it happened (default now). */
60
+ at?: Date | undefined;
61
+ /** An id unique to this event, so a destination counts a retried send once. */
62
+ id: string;
63
+ /** The page's full address. */
64
+ url: string;
65
+ referrer?: string | undefined;
66
+ /** From `visitorId`. */
67
+ visitor: string;
68
+ /** The click's event name, or the link's address (outbound, download). */
69
+ label?: string | undefined;
70
+ href?: string | undefined;
71
+ /** A purchase's (or a booking's) value. */
72
+ value?: number | undefined;
73
+ currency?: string | undefined;
74
+ /** A purchase's order id, or what was booked or claimed. */
75
+ transactionId?: string | undefined;
76
+ item?: string | undefined;
77
+ /** Rough place, from the host's edge (country and region codes, city). */
78
+ location?: {
79
+ country?: string | undefined;
80
+ region?: string | undefined;
81
+ city?: string | undefined;
82
+ } | undefined;
83
+ /** Whether the person agreed to personal data in this event, and whether the browser asked not to be tracked. */
84
+ consent: {
85
+ personalData: boolean;
86
+ gpc?: boolean | undefined;
87
+ };
88
+ /** Sent only with `consent.personalData`. */
89
+ user?: SiteEventUser | undefined;
90
+ ip?: string | undefined;
91
+ userAgent?: string | undefined;
92
+ }
93
+ /** A site's destinations: either, both or neither. */
94
+ interface AnalyticsDestinations {
95
+ ga4?: {
96
+ measurementId: string;
97
+ apiSecret: string;
98
+ } | null | undefined;
99
+ meta?: {
100
+ pixelId: string;
101
+ accessToken: string;
102
+ testEventCode?: string | undefined;
103
+ } | null | undefined;
104
+ }
105
+ declare const GA4_MEASUREMENT_ID: RegExp;
106
+ declare const META_PIXEL_ID: RegExp;
107
+ /**
108
+ * The visitor's id for a day: a hash of the salt, the site, the day, the IP
109
+ * address and the browser. The salt is the host's secret; a new day gives a
110
+ * new id, so visitors can't be followed across days.
111
+ */
112
+ declare function visitorId(input: {
113
+ salt: string;
114
+ siteId: string;
115
+ ip: string;
116
+ userAgent: string;
117
+ at?: Date;
118
+ }): Promise<string>;
119
+ /** The normalised, hashed email (lowercase, trimmed), as Meta takes it. */
120
+ declare function hashEmail(email: string): Promise<string | undefined>;
121
+ /** The normalised, hashed phone: digits only, with the country code, as Meta takes it. */
122
+ declare function hashPhone(phone: string): Promise<string | undefined>;
123
+ /** A request to the destination, for `fetch`. */
124
+ interface DestinationRequest {
125
+ destination: "ga4" | "meta";
126
+ url: string;
127
+ init: {
128
+ method: "POST";
129
+ headers: Record<string, string>;
130
+ body: string;
131
+ };
132
+ }
133
+ /** The Measurement Protocol request for an event. */
134
+ declare function ga4Request(event: SiteEvent, ga4: NonNullable<AnalyticsDestinations["ga4"]>): Promise<DestinationRequest>;
135
+ /** The Conversions API request for an event, or null when Meta mustn't have it. */
136
+ declare function metaRequest(event: SiteEvent, meta: NonNullable<AnalyticsDestinations["meta"]>, graphVersion?: string): Promise<DestinationRequest | null>;
137
+ interface ForwardResult {
138
+ destination: "ga4" | "meta";
139
+ ok: boolean;
140
+ status?: number;
141
+ error?: string;
142
+ }
143
+ /**
144
+ * Sends an event to the site's destinations, both at once, with a time limit.
145
+ * Never throws: a destination that fails is reported, not retried.
146
+ */
147
+ declare function forwardEvent(event: SiteEvent, destinations: AnalyticsDestinations, options?: {
148
+ fetch?: typeof fetch;
149
+ timeoutMs?: number;
150
+ }): Promise<ForwardResult[]>;
151
+ /** Whether the browser sent Global Privacy Control. */
152
+ declare const sendsGpc: (request: Request) => boolean;
153
+ /**
154
+ * Reads a beacon's body: the event, or null when it isn't one (over
155
+ * `BEACON_MAX_BYTES` bytes, not JSON, unknown fields' values out of range).
156
+ * The page sends it as text/plain, which needs no preflight. The page's path
157
+ * comes as sent, query included: `beaconEvent` keeps only its campaign tags.
158
+ */
159
+ declare function readBeacon(request: Request): Promise<SiteBeacon | null>;
160
+ /** The query keys a page address keeps for analytics: campaign tags and ad click ids, nothing else. */
161
+ declare const CAMPAIGN_QUERY_KEY: RegExp;
162
+ /**
163
+ * A page path with only its campaign query (utm_*, gclid, gbraid, wbraid):
164
+ * a query can carry a prefilled email or a token, which must not reach an
165
+ * analytics provider. The fragment goes too.
166
+ */
167
+ declare function campaignPath(path: string): string;
168
+ /**
169
+ * An event from a page's beacon: the page address on the site's origin (the
170
+ * beacon's path already starts with the site's base path, as the browser
171
+ * shows it), with only its campaign query; the referrer and the link's
172
+ * address without their query or fragment; the visitor's daily id; and no
173
+ * personal data (a beacon never has consent).
174
+ */
175
+ declare function beaconEvent(beacon: SiteBeacon, input: {
176
+ origin: string;
177
+ visitor: string;
178
+ id: string;
179
+ at?: Date;
180
+ location?: SiteEvent["location"];
181
+ gpc?: boolean;
182
+ }): SiteEvent;
183
+
184
+ export { type AnalyticsDestinations, BEACON_EVENTS, BEACON_MAX_BYTES, BEACON_PATH, type BeaconEventName, CAMPAIGN_QUERY_KEY, CONVERSION_EVENTS, type ConversionEventName, type DestinationRequest, type ForwardResult, GA4_MEASUREMENT_ID, META_PIXEL_ID, SiteBeacon, type SiteEvent, type SiteEventName, type SiteEventUser, beaconEvent, campaignPath, forwardEvent, ga4Request, hashEmail, hashPhone, metaRequest, readBeacon, sendsGpc, visitorId };
@@ -0,0 +1,3 @@
1
+ export { BEACON_EVENTS, BEACON_MAX_BYTES, BEACON_PATH, CAMPAIGN_QUERY_KEY, CONVERSION_EVENTS, GA4_MEASUREMENT_ID, META_PIXEL_ID, SiteBeacon, beaconEvent, campaignPath, forwardEvent, ga4Request, hashEmail, hashPhone, metaRequest, readBeacon, sendsGpc, visitorId } from './chunk-5RYCQEEE.js';
2
+ //# sourceMappingURL=analytics.js.map
3
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"analytics.js"}
@@ -0,0 +1 @@
1
+ var u=document.querySelectorAll('details[data-gs-island="menu"]');u.forEach(e=>{e.addEventListener("focusout",r=>{let n=r.relatedTarget;e.open&&n&&!e.contains(n)&&(e.open=!1)}),e.addEventListener("keydown",r=>{r.key==="Escape"&&e.open&&(e.open=!1,e.querySelector("summary")?.focus())}),e.addEventListener("click",r=>{r.target.closest("a")&&(e.open=!1)})});u.length&&document.addEventListener("click",e=>{u.forEach(r=>{r.open&&!r.contains(e.target)&&(r.open=!1)})});function g(e,r,n){let s=[...e.querySelectorAll(`[name="${CSS.escape(r)}"]`)];if(n==="multi"){let o=s.filter(t=>t.checked).map(t=>t.value);return o.length?o:void 0}if(n==="single"||n==="yes-no"){let t=s.find(a=>a.type==="radio"?a.checked:!0)?.value??"";return t?n==="yes-no"?t==="yes":t:void 0}if(n==="consent")return s[0]?.checked?!0:void 0;let i=(s[0]?.value??"").trim();if(i)return n==="number"?Number(i):i}document.querySelectorAll('form[data-gs-island="light-form"]').forEach(e=>{let r=e.querySelector("[data-gs-status]"),n=e.querySelector('button[type="submit"]'),s=o=>{r&&(r.textContent=o)},i=()=>{let o=!0;return e.querySelectorAll('[data-gs-kind="multi"][data-gs-required]').forEach(t=>{let a=[...t.querySelectorAll('input[type="checkbox"]')],c=a.some(l=>l.checked)?"":"Choose at least one.";a[0]?.setCustomValidity(c),c&&(o=!1)}),o};e.addEventListener("change",i),e.addEventListener("submit",async o=>{if(o.preventDefault(),!i()||!e.checkValidity()){e.reportValidity();return}let t={};e.querySelectorAll("[data-gs-field]").forEach(a=>{let c=a.dataset.gsField,l=g(a,c,a.dataset.gsKind??"text");l!==void 0&&(t[c]=l)}),n&&(n.disabled=!0),s("Sending\u2026");try{let a=await fetch(e.action,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({form:e.dataset.gsForm,answers:t}),credentials:"same-origin"});if(!a.ok)throw new Error(String(a.status));let c=document.createElement("p");c.setAttribute("role","status"),c.tabIndex=-1,c.className="text-lg font-medium",c.textContent=e.dataset.gsSent??"Thanks.",e.replaceWith(c),c.focus()}catch(a){console.error(`[genesis-sites] the form "${e.dataset.gsForm}" couldn't be sent.`,a),s("That didn't send. Check your connection and try again."),n&&(n.disabled=!1,n.focus())}})});var f=["https://www.openstreetmap.org/","https://www.google.com/maps"];document.querySelectorAll('[data-gs-island="map"]').forEach(e=>{let r=e.dataset.gsMapSrc??"",n=e.querySelector("[data-gs-map-load]");!n||!f.some(s=>r.startsWith(s))||(n.hidden=!1,n.addEventListener("click",()=>{let s=document.createElement("iframe");s.src=r,s.title=e.dataset.gsMapTitle||"Map",s.loading="lazy",s.referrerPolicy="strict-origin-when-cross-origin",s.className="absolute inset-0 h-full w-full border-0",e.querySelectorAll("[data-gs-map-drop]").forEach(i=>i.remove()),e.prepend(s),s.focus()}))});document.querySelector('[data-gs-island="form"]')&&import(new URL("./form-island.da6c662a73.js",import.meta.url).href).catch(e=>{console.error("[genesis-sites] the form couldn't load.",e)});var d=document.documentElement.dataset.gsBeacon,m=/^(utm_[a-z_]+|gclid|gbraid|wbraid)$/;if(d){let e=new URLSearchParams;new URLSearchParams(location.search).forEach((o,t)=>m.test(t)&&e.append(t,o));let r=location.pathname+(String(e)?`?${e}`:""),n=(o,t={})=>{let a=JSON.stringify({n:o,p:r.slice(0,512),...t});navigator.sendBeacon?.(d,a)||fetch(d,{method:"POST",body:a,keepalive:!0,credentials:"omit"}).catch(()=>{})},s=document.referrer,i=s&&!s.startsWith(location.origin)?s.replace(/[?#].*$/,""):"";n("page_view",i?{r:i.slice(0,512)}:{}),document.addEventListener("click",o=>{let t=o.target.closest?.("a[href]");if(!t)return;let a=/^https?:$/.test(t.protocol)?(t.origin+t.pathname).slice(0,512):"",c=a?{h:a}:{};t.dataset.gsEvent==="download"?n("download",c):t.dataset.gsOutbound!==void 0?n("outbound",{...c,...t.dataset.gsEvent?{e:t.dataset.gsEvent}:{}}):t.dataset.gsEvent&&n("click",{e:t.dataset.gsEvent,...c})})}