@wealthreach/site-kit 1.0.1 → 1.0.3
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/dist/a11y/index.js +7 -2
- package/dist/a11y/shell-client.d.ts +1 -1
- package/dist/a11y/shell-client.js +4 -4
- package/dist/analytics/index.d.ts +2 -2
- package/dist/analytics/index.js +9 -3
- package/dist/{attribution-DQaAWtA5.d.ts → attribution-BajAl0tG.d.ts} +17 -7
- package/dist/blog/index.d.ts +16 -4
- package/dist/blog/index.js +57 -4
- package/dist/{chunk-Y77ARZE4.js → chunk-DHVKLLL7.js} +5 -3
- package/dist/{chunk-QQP7VG2C.js → chunk-JPUCXNHR.js} +109 -16
- package/dist/{chunk-4YRCSRZZ.js → chunk-SNTMH6M3.js} +2 -2
- package/dist/{chunk-7GDXQ6UB.js → chunk-T4Q4VJ6K.js} +34 -7
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +4 -3
- package/dist/consent/index.d.ts +5 -3
- package/dist/consent/index.js +4 -2
- package/dist/forms/index.d.ts +19 -7
- package/dist/forms/index.js +141 -42
- package/dist/next/leads-route.d.ts +8 -5
- package/dist/next/leads-route.js +136 -123
- package/dist/{schema-C1ixytx2.d.ts → schema-AcsTlgUv.d.ts} +4 -0
- package/dist/{schema-DD0nDOD0.d.ts → schema-CYsBDpoU.d.ts} +3 -0
- package/package.json +1 -1
package/dist/a11y/index.js
CHANGED
|
@@ -79,10 +79,13 @@ var MODE_MAX_AGE = 60 * 60 * 24;
|
|
|
79
79
|
var VISITOR_SCRIPT_ID = "wr-site-script";
|
|
80
80
|
var GTM_SCRIPT_ID = "wr-gtm-script";
|
|
81
81
|
var GA4_SCRIPT_ID = "wr-ga4-script";
|
|
82
|
+
function legacyConsentStorageKey(siteId) {
|
|
83
|
+
return `wr:consent:${siteId?.trim() || "site"}`;
|
|
84
|
+
}
|
|
82
85
|
|
|
83
86
|
// src/consent/bootstrap.ts
|
|
84
87
|
function safeJson(value) {
|
|
85
|
-
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
88
|
+
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
86
89
|
}
|
|
87
90
|
var GTM_ID_RE = /^GTM-[A-Z0-9]{4,16}$/;
|
|
88
91
|
var GA4_ID_RE = /^G-[A-Z0-9]{4,16}$/;
|
|
@@ -116,6 +119,7 @@ function buildConsentBootstrapScript(options) {
|
|
|
116
119
|
const ga4Id = sanitizeGa4Id(options.ga4MeasurementId);
|
|
117
120
|
if (!visitorUrl && !gtmId && !ga4Id) return null;
|
|
118
121
|
const legacy = options.legacyConsentCookies ?? [];
|
|
122
|
+
const legacyStorageCheck = options.siteId !== void 0 ? `if(!c){try{if(window.localStorage.getItem(${safeJson(legacyConsentStorageKey(options.siteId))})==='declined')c='analytics:no';}catch(e){}}` : "";
|
|
119
123
|
const loaders = [];
|
|
120
124
|
if (visitorUrl) {
|
|
121
125
|
loaders.push(
|
|
@@ -132,7 +136,7 @@ function buildConsentBootstrapScript(options) {
|
|
|
132
136
|
`if(!document.getElementById('${GA4_SCRIPT_ID}')){window.dataLayer=window.dataLayer||[];function gtag(){window.dataLayer.push(arguments);}window.gtag=window.gtag||gtag;gtag('js',new Date());gtag('config',${safeJson(ga4Id)});var a=document.createElement('script');a.id='${GA4_SCRIPT_ID}';a.async=true;a.src=${safeJson(`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(ga4Id)}`)};a.setAttribute('data-consent-category','analytics');document.head.appendChild(a);}`
|
|
133
137
|
);
|
|
134
138
|
}
|
|
135
|
-
return `(function(){try{var g=function(n){var p=document.cookie.split('; ').find(function(v){return v.indexOf(n+'=')===0});return p?decodeURIComponent(p.slice(n.length+1)):null};var c=g('${CONSENT_COOKIE}');if(!c){var leg=${safeJson(legacy)};for(var i=0;i<leg.length;i++){var lv=g(leg[i]);if(lv){c=lv.indexOf('analytics:yes')>-1?'analytics:yes':lv.indexOf('analytics:no')>-1?'analytics:no':null;if(c)break;}}}if(c==='analytics:no')return;var gpc=navigator.globalPrivacyControl===true;if(c!=='analytics:yes'&&!(g('${MODE_COOKIE}')==='opt-out'&&!gpc))return;${loaders.join("")}}catch(e){}})();`;
|
|
139
|
+
return `(function(){try{var g=function(n){var p=document.cookie.split('; ').find(function(v){return v.indexOf(n+'=')===0});return p?decodeURIComponent(p.slice(n.length+1)):null};var c=g('${CONSENT_COOKIE}');if(!c){var leg=${safeJson(legacy)};for(var i=0;i<leg.length;i++){var lv=g(leg[i]);if(lv){c=lv.indexOf('analytics:yes')>-1?'analytics:yes':lv.indexOf('analytics:no')>-1?'analytics:no':null;if(c)break;}}}${legacyStorageCheck}if(c==='analytics:no')return;var gpc=navigator.globalPrivacyControl===true;if(c!=='analytics:yes'&&!(g('${MODE_COOKIE}')==='opt-out'&&!gpc))return;${loaders.join("")}}catch(e){}})();`;
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
// src/a11y/site-shell.tsx
|
|
@@ -152,6 +156,7 @@ function SiteShell({
|
|
|
152
156
|
children
|
|
153
157
|
}) {
|
|
154
158
|
const bootstrapScript = buildConsentBootstrapScript({
|
|
159
|
+
siteId: config.siteId,
|
|
155
160
|
visitorScriptUrl: config.visitors?.enabled ? config.visitors.siteScriptUrl : void 0,
|
|
156
161
|
gtmId: config.integrations?.gtmId,
|
|
157
162
|
ga4MeasurementId: config.integrations?.ga4MeasurementId,
|
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
4
|
ConsentBanner
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-DHVKLLL7.js";
|
|
6
6
|
import {
|
|
7
7
|
PageTracker
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-SNTMH6M3.js";
|
|
9
|
+
import "../chunk-JPUCXNHR.js";
|
|
10
10
|
import {
|
|
11
11
|
ConsentGate,
|
|
12
12
|
ConsentProvider
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-T4Q4VJ6K.js";
|
|
14
14
|
|
|
15
15
|
// src/a11y/shell-client.tsx
|
|
16
16
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AttributionSnapshot, W as WebsiteVisitSnapshot, c as captureAttributionOnLanding, r as readAttributionSnapshot,
|
|
2
|
-
import { S as SiteConfig } from '../schema-
|
|
1
|
+
export { A as AttributionSnapshot, M as MAX_JOURNEY_SERIALIZED_BYTES, W as WebsiteVisitJourneyEntry, a as WebsiteVisitSnapshot, c as captureAttributionOnLanding, r as readAttributionSnapshot, b as readConsentedWebsiteVisit, s as sanitizeWebsiteJourney, d as sanitizeWebsiteVisit } from '../attribution-BajAl0tG.js';
|
|
2
|
+
import { S as SiteConfig } from '../schema-CYsBDpoU.js';
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
import 'zod';
|
|
5
5
|
|
package/dist/analytics/index.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
PageTracker
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-SNTMH6M3.js";
|
|
5
5
|
import {
|
|
6
|
+
MAX_JOURNEY_SERIALIZED_BYTES,
|
|
6
7
|
captureAttributionOnLanding,
|
|
7
8
|
pushDataLayerEvent,
|
|
8
9
|
readAttributionSnapshot,
|
|
9
10
|
readConsentedWebsiteVisit,
|
|
11
|
+
sanitizeWebsiteJourney,
|
|
12
|
+
sanitizeWebsiteVisit,
|
|
10
13
|
trackBookingCompleted,
|
|
11
14
|
trackCtaClick,
|
|
12
15
|
trackEvent,
|
|
13
16
|
trackFormSubmission,
|
|
14
17
|
trackPageView
|
|
15
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-JPUCXNHR.js";
|
|
16
19
|
import {
|
|
17
20
|
useConsent
|
|
18
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-T4Q4VJ6K.js";
|
|
19
22
|
|
|
20
23
|
// src/analytics/booking.tsx
|
|
21
24
|
import { useEffect } from "react";
|
|
@@ -108,11 +111,14 @@ function BookingEmbed({
|
|
|
108
111
|
}
|
|
109
112
|
export {
|
|
110
113
|
BookingEmbed,
|
|
114
|
+
MAX_JOURNEY_SERIALIZED_BYTES,
|
|
111
115
|
PageTracker,
|
|
112
116
|
captureAttributionOnLanding,
|
|
113
117
|
pushDataLayerEvent,
|
|
114
118
|
readAttributionSnapshot,
|
|
115
119
|
readConsentedWebsiteVisit,
|
|
120
|
+
sanitizeWebsiteJourney,
|
|
121
|
+
sanitizeWebsiteVisit,
|
|
116
122
|
trackBookingCompleted,
|
|
117
123
|
trackCtaClick,
|
|
118
124
|
trackEvent,
|
|
@@ -13,15 +13,18 @@ interface AttributionSnapshot {
|
|
|
13
13
|
referrer_host?: string;
|
|
14
14
|
captured_at?: string;
|
|
15
15
|
}
|
|
16
|
+
interface WebsiteVisitJourneyEntry {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
startedAt: string;
|
|
19
|
+
pages: string[];
|
|
20
|
+
referrer?: string | null;
|
|
21
|
+
activeMs?: number;
|
|
22
|
+
}
|
|
16
23
|
interface WebsiteVisitSnapshot {
|
|
17
24
|
visitorKey: string;
|
|
18
25
|
sessionId: string;
|
|
19
26
|
device: "desktop" | "mobile";
|
|
20
|
-
journey?:
|
|
21
|
-
landingPath?: string;
|
|
22
|
-
referrerHost?: string;
|
|
23
|
-
pagesViewed?: string[];
|
|
24
|
-
};
|
|
27
|
+
journey?: WebsiteVisitJourneyEntry[];
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* Cookie-free first-touch attribution capture (stored in sessionStorage only).
|
|
@@ -31,11 +34,18 @@ interface WebsiteVisitSnapshot {
|
|
|
31
34
|
*/
|
|
32
35
|
declare function captureAttributionOnLanding(): AttributionSnapshot;
|
|
33
36
|
declare function readAttributionSnapshot(): AttributionSnapshot;
|
|
37
|
+
/** Cap serialized optional journey well below `/api/leads` 64 KiB body limit so history never blocks lead capture. */
|
|
38
|
+
declare const MAX_JOURNEY_SERIALIZED_BYTES = 16384;
|
|
39
|
+
declare function sanitizeWebsiteJourney(raw: unknown): WebsiteVisitJourneyEntry[] | undefined;
|
|
40
|
+
declare function sanitizeWebsiteVisit(raw: unknown): WebsiteVisitSnapshot | undefined;
|
|
34
41
|
/**
|
|
35
42
|
* Reads optional first-party website visitor identity ONLY when caller has
|
|
36
43
|
* already verified BrandywineOak consent (`allowed === true`).
|
|
44
|
+
* Supports the served visitor script's `window.__wrVisitor.getVisitContext()`
|
|
45
|
+
* bridge as well as direct fallback to the script's persisted `wr_vid`,
|
|
46
|
+
* `wr:visitors:session:<siteId>`, and `wr:journey:<siteId>` records.
|
|
37
47
|
*/
|
|
38
48
|
declare function readConsentedWebsiteVisit(siteId: string, consentAllowed: boolean): WebsiteVisitSnapshot | undefined;
|
|
39
49
|
|
|
40
|
-
export { readConsentedWebsiteVisit as
|
|
41
|
-
export type { AttributionSnapshot as A,
|
|
50
|
+
export { MAX_JOURNEY_SERIALIZED_BYTES as M, readConsentedWebsiteVisit as b, captureAttributionOnLanding as c, sanitizeWebsiteVisit as d, readAttributionSnapshot as r, sanitizeWebsiteJourney as s };
|
|
51
|
+
export type { AttributionSnapshot as A, WebsiteVisitJourneyEntry as W, WebsiteVisitSnapshot as a };
|
package/dist/blog/index.d.ts
CHANGED
|
@@ -3,10 +3,19 @@ import { SiteConfig } from '../config/index.js';
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import '../regulatory-schema-uDKNJ7q8.js';
|
|
5
5
|
|
|
6
|
+
/** True when a blog file begins with a properly closed YAML frontmatter block (`---` or `---yaml`). */
|
|
7
|
+
declare function hasFrontmatterBlock(raw: string): boolean;
|
|
8
|
+
/** True when a file without a valid frontmatter block looks like malformed or non-YAML frontmatter. */
|
|
9
|
+
declare function looksLikeMalformedFrontmatter(raw: string): boolean;
|
|
10
|
+
/** Safely parses YAML frontmatter with gray-matter's JS/eval engines disabled. */
|
|
11
|
+
declare function parseSafeFrontmatter(raw: string): {
|
|
12
|
+
data: Record<string, unknown>;
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
6
15
|
/**
|
|
7
|
-
* Contract 3.5 blog post frontmatter schema:
|
|
16
|
+
* Contract 3.5 / 3.8 blog post frontmatter schema:
|
|
8
17
|
* - Accepts `date` or `publishedAt` (normalizing `date` from `publishedAt` when omitted).
|
|
9
|
-
* - Holds are marked `status: "waiting"`
|
|
18
|
+
* - Holds are marked `status: "waiting"` or `published: false` (bare or quoted `"true"`/`"false"`).
|
|
10
19
|
* - Unknown `status` values fail closed in `isPostLive`.
|
|
11
20
|
*/
|
|
12
21
|
declare const postFrontmatterSchema: z.ZodPipe<z.ZodObject<{
|
|
@@ -26,7 +35,10 @@ declare const postFrontmatterSchema: z.ZodPipe<z.ZodObject<{
|
|
|
26
35
|
waiting: "waiting";
|
|
27
36
|
live: "live";
|
|
28
37
|
}>>;
|
|
29
|
-
published: z.ZodOptional<z.ZodBoolean
|
|
38
|
+
published: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodPipe<z.ZodEnum<{
|
|
39
|
+
true: "true";
|
|
40
|
+
false: "false";
|
|
41
|
+
}>, z.ZodTransform<boolean, "true" | "false">>]>>;
|
|
30
42
|
}, z.core.$loose>, z.ZodTransform<{
|
|
31
43
|
date: string;
|
|
32
44
|
title: string;
|
|
@@ -127,5 +139,5 @@ declare function DraftOwnerBanner({ slug, className, }: {
|
|
|
127
139
|
className?: string;
|
|
128
140
|
}): React.JSX.Element;
|
|
129
141
|
|
|
130
|
-
export { DRAFT_AUDIENCE_COOKIE, DraftOwnerBanner, assertPostReadable, buildPostJsonLd, createFileSystemPostSource, getPostBySlug, isDraftViewEnabled, isOwnerAudienceCookie, isOwnerDraftAudience, isPostLive, loadPosts, logHiddenPost, postFrontmatterSchema };
|
|
142
|
+
export { DRAFT_AUDIENCE_COOKIE, DraftOwnerBanner, assertPostReadable, buildPostJsonLd, createFileSystemPostSource, getPostBySlug, hasFrontmatterBlock, isDraftViewEnabled, isOwnerAudienceCookie, isOwnerDraftAudience, isPostLive, loadPosts, logHiddenPost, looksLikeMalformedFrontmatter, parseSafeFrontmatter, postFrontmatterSchema };
|
|
131
143
|
export type { BlogPost, PostFrontmatter, PostSource };
|
package/dist/blog/index.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
// src/blog/frontmatter.ts
|
|
2
|
+
import matter from "gray-matter";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
var dateField = z.union([z.string().trim().min(1), z.date()]).transform((v) => v instanceof Date ? v.toISOString().slice(0, 10) : v);
|
|
5
|
+
var publishedField = z.union([
|
|
6
|
+
z.boolean(),
|
|
7
|
+
z.enum(["true", "false"]).transform((v) => v === "true")
|
|
8
|
+
]);
|
|
9
|
+
var FRONTMATTER_BLOCK_RE = /^(?:\uFEFF)?---(?:[ \t]*(?:yaml|yml))?[ \t]*\r?\n([\s\S]*?)^---[ \t]*\r?(?:\n|$)/m;
|
|
10
|
+
var MALFORMED_FRONTMATTER_RE = /^(?:\uFEFF)?(?:---(?!-)|(?:status|published):)/;
|
|
11
|
+
var SAFE_MATTER_OPTIONS = {
|
|
12
|
+
engines: {
|
|
13
|
+
js: () => {
|
|
14
|
+
throw new Error("JavaScript frontmatter engine is disabled for security.");
|
|
15
|
+
},
|
|
16
|
+
javascript: () => {
|
|
17
|
+
throw new Error("JavaScript frontmatter engine is disabled for security.");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
function hasFrontmatterBlock(raw) {
|
|
22
|
+
const match = raw.match(FRONTMATTER_BLOCK_RE);
|
|
23
|
+
return Boolean(match && match.index === 0);
|
|
24
|
+
}
|
|
25
|
+
function looksLikeMalformedFrontmatter(raw) {
|
|
26
|
+
return !hasFrontmatterBlock(raw) && MALFORMED_FRONTMATTER_RE.test(raw.slice(0, 1024));
|
|
27
|
+
}
|
|
28
|
+
function parseSafeFrontmatter(raw) {
|
|
29
|
+
const parsed = matter(raw, SAFE_MATTER_OPTIONS);
|
|
30
|
+
return {
|
|
31
|
+
data: parsed.data ?? {},
|
|
32
|
+
content: parsed.content
|
|
33
|
+
};
|
|
34
|
+
}
|
|
4
35
|
var postFrontmatterSchema = z.object({
|
|
5
36
|
title: z.string().trim().min(1),
|
|
6
37
|
description: z.string().trim().optional().default(""),
|
|
@@ -15,7 +46,7 @@ var postFrontmatterSchema = z.object({
|
|
|
15
46
|
videoUrl: z.string().trim().optional(),
|
|
16
47
|
transcript: z.string().optional(),
|
|
17
48
|
status: z.enum(["waiting", "live"]).optional(),
|
|
18
|
-
published:
|
|
49
|
+
published: publishedField.optional()
|
|
19
50
|
}).passthrough().superRefine((data, ctx) => {
|
|
20
51
|
if (!data.date && !data.publishedAt) {
|
|
21
52
|
ctx.addIssue({
|
|
@@ -32,7 +63,7 @@ var postFrontmatterSchema = z.object({
|
|
|
32
63
|
// src/blog/visibility.ts
|
|
33
64
|
function isPostLive(postOrFrontmatter) {
|
|
34
65
|
const fm = "frontmatter" in postOrFrontmatter && postOrFrontmatter.frontmatter !== null && typeof postOrFrontmatter.frontmatter === "object" ? postOrFrontmatter.frontmatter : postOrFrontmatter;
|
|
35
|
-
if (fm.published === false) return false;
|
|
66
|
+
if (fm.published === false || fm.published === "false") return false;
|
|
36
67
|
if (fm.status !== void 0 && fm.status !== "live") return false;
|
|
37
68
|
return true;
|
|
38
69
|
}
|
|
@@ -53,13 +84,15 @@ function assertPostReadable(post, options) {
|
|
|
53
84
|
// src/blog/source.ts
|
|
54
85
|
import fs from "fs";
|
|
55
86
|
import path from "path";
|
|
56
|
-
import matter from "gray-matter";
|
|
57
87
|
var POST_EXT_RE = /\.(?:mdx|md)$/i;
|
|
58
88
|
function createFileSystemPostSource(options) {
|
|
59
89
|
const baseDir = path.resolve(
|
|
60
90
|
options?.cwd ?? process.cwd(),
|
|
61
91
|
options?.postsDir ?? "data/blog"
|
|
62
92
|
);
|
|
93
|
+
function slugToTitle(slug) {
|
|
94
|
+
return slug.replace(/[-_]+/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase());
|
|
95
|
+
}
|
|
63
96
|
function parseFile(filePath, slug) {
|
|
64
97
|
try {
|
|
65
98
|
const raw = fs.readFileSync(
|
|
@@ -67,7 +100,24 @@ function createFileSystemPostSource(options) {
|
|
|
67
100
|
filePath,
|
|
68
101
|
"utf8"
|
|
69
102
|
);
|
|
70
|
-
|
|
103
|
+
if (!hasFrontmatterBlock(raw)) {
|
|
104
|
+
if (looksLikeMalformedFrontmatter(raw)) {
|
|
105
|
+
logHiddenPost(slug, "malformed frontmatter block");
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
slug,
|
|
110
|
+
filePath,
|
|
111
|
+
frontmatter: {
|
|
112
|
+
title: slugToTitle(slug),
|
|
113
|
+
description: "",
|
|
114
|
+
date: "",
|
|
115
|
+
tags: []
|
|
116
|
+
},
|
|
117
|
+
content: raw
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const { data, content } = parseSafeFrontmatter(raw);
|
|
71
121
|
const parsed = postFrontmatterSchema.safeParse(data);
|
|
72
122
|
if (!parsed.success) {
|
|
73
123
|
logHiddenPost(
|
|
@@ -249,11 +299,14 @@ export {
|
|
|
249
299
|
buildPostJsonLd,
|
|
250
300
|
createFileSystemPostSource,
|
|
251
301
|
getPostBySlug,
|
|
302
|
+
hasFrontmatterBlock,
|
|
252
303
|
isDraftViewEnabled,
|
|
253
304
|
isOwnerAudienceCookie,
|
|
254
305
|
isOwnerDraftAudience,
|
|
255
306
|
isPostLive,
|
|
256
307
|
loadPosts,
|
|
257
308
|
logHiddenPost,
|
|
309
|
+
looksLikeMalformedFrontmatter,
|
|
310
|
+
parseSafeFrontmatter,
|
|
258
311
|
postFrontmatterSchema
|
|
259
312
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useConsent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-T4Q4VJ6K.js";
|
|
5
5
|
|
|
6
6
|
// src/consent/banner.tsx
|
|
7
7
|
import { useEffect, useId, useRef } from "react";
|
|
@@ -62,6 +62,8 @@ function ConsentBanner({
|
|
|
62
62
|
if (config.consent?.enabled === false) return null;
|
|
63
63
|
const isOptOut = mode === "opt-out" && !gpc;
|
|
64
64
|
const message = config.consent?.message?.trim() || (isOptOut ? "We use cookies to understand website visits. You can turn analytics off at any time." : "May we use cookies to understand website visits? Forms and core site features work either way.");
|
|
65
|
+
const rawPolicyUrl = config.consent?.policyUrl?.trim() ?? "";
|
|
66
|
+
const safePolicyUrl = rawPolicyUrl.startsWith("/") && !rawPolicyUrl.startsWith("//") || /^https?:\/\//i.test(rawPolicyUrl) ? rawPolicyUrl : "";
|
|
65
67
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
68
|
!config.consent?.hideFloatingPrivacyButton && /* @__PURE__ */ jsx(
|
|
67
69
|
PrivacyChoicesButton,
|
|
@@ -134,10 +136,10 @@ function ConsentBanner({
|
|
|
134
136
|
/* @__PURE__ */ jsxs("p", { style: { margin: 0, fontSize: "0.875rem", lineHeight: 1.5 }, children: [
|
|
135
137
|
message,
|
|
136
138
|
" ",
|
|
137
|
-
|
|
139
|
+
safePolicyUrl && /* @__PURE__ */ jsx(
|
|
138
140
|
"a",
|
|
139
141
|
{
|
|
140
|
-
href:
|
|
142
|
+
href: safePolicyUrl,
|
|
141
143
|
style: { textDecoration: "underline", color: "inherit" },
|
|
142
144
|
children: "Privacy policy"
|
|
143
145
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
readBrowserCookie,
|
|
7
7
|
readGpcSignal,
|
|
8
8
|
readStoredConsent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-T4Q4VJ6K.js";
|
|
10
10
|
|
|
11
11
|
// src/analytics/attribution.ts
|
|
12
12
|
var ATTRIBUTION_STORAGE_KEY = "wr:attribution:v1";
|
|
@@ -84,52 +84,142 @@ function readAttributionSnapshot() {
|
|
|
84
84
|
return captureAttributionOnLanding();
|
|
85
85
|
}
|
|
86
86
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
87
|
+
var VISITOR_KEY_RE = /^[a-zA-Z0-9_-]{16,128}$/;
|
|
88
|
+
var ISO_OFFSET_DATETIME_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/i;
|
|
89
|
+
var SESSION_IDLE_MS = 30 * 60 * 1e3;
|
|
90
|
+
var MAX_JOURNEY_SERIALIZED_BYTES = 16384;
|
|
91
|
+
function sanitizeWebsiteJourney(raw) {
|
|
92
|
+
if (!Array.isArray(raw)) return void 0;
|
|
93
|
+
const entries = [];
|
|
94
|
+
for (const item of raw.slice(-10)) {
|
|
95
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) continue;
|
|
96
|
+
const row = item;
|
|
97
|
+
const sessionId = typeof row.sessionId === "string" ? row.sessionId.trim() : "";
|
|
98
|
+
const startedAt = typeof row.startedAt === "string" ? row.startedAt.trim() : "";
|
|
99
|
+
if (!UUID_RE.test(sessionId) || !ISO_OFFSET_DATETIME_RE.test(startedAt) || Number.isNaN(Date.parse(startedAt))) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const pages = Array.isArray(row.pages) ? row.pages.filter(
|
|
103
|
+
(page) => typeof page === "string" && page.length > 0 && page.length <= 2048
|
|
104
|
+
).slice(-100) : [];
|
|
105
|
+
const referrer = typeof row.referrer === "string" && row.referrer.length <= 2048 ? row.referrer : row.referrer === null ? null : void 0;
|
|
106
|
+
const activeMs = typeof row.activeMs === "number" && Number.isFinite(row.activeMs) && row.activeMs >= 0 ? Math.min(864e5, Math.round(row.activeMs)) : void 0;
|
|
107
|
+
entries.push({
|
|
108
|
+
sessionId,
|
|
109
|
+
startedAt,
|
|
110
|
+
pages,
|
|
111
|
+
...referrer !== void 0 ? { referrer } : {},
|
|
112
|
+
...activeMs !== void 0 ? { activeMs } : {}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
while (entries.length > 1 && JSON.stringify(entries).length > MAX_JOURNEY_SERIALIZED_BYTES) {
|
|
116
|
+
entries.shift();
|
|
117
|
+
}
|
|
118
|
+
if (entries.length === 1 && JSON.stringify(entries).length > MAX_JOURNEY_SERIALIZED_BYTES) {
|
|
119
|
+
const latest = entries[0];
|
|
120
|
+
while (latest.pages.length > 0 && JSON.stringify(entries).length > MAX_JOURNEY_SERIALIZED_BYTES) {
|
|
121
|
+
latest.pages.shift();
|
|
122
|
+
}
|
|
123
|
+
if (JSON.stringify(entries).length > MAX_JOURNEY_SERIALIZED_BYTES) {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return entries.length > 0 ? entries : void 0;
|
|
128
|
+
}
|
|
129
|
+
function sanitizeWebsiteVisit(raw) {
|
|
130
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
131
|
+
const obj = raw;
|
|
132
|
+
const visitorKey = typeof obj.visitorKey === "string" ? obj.visitorKey.trim() : "";
|
|
133
|
+
const sessionId = typeof obj.sessionId === "string" ? obj.sessionId.trim() : "";
|
|
134
|
+
if (!VISITOR_KEY_RE.test(visitorKey) || !UUID_RE.test(sessionId)) {
|
|
135
|
+
return void 0;
|
|
136
|
+
}
|
|
137
|
+
const device = obj.device === "mobile" ? "mobile" : "desktop";
|
|
138
|
+
const journey = sanitizeWebsiteJourney(obj.journey);
|
|
139
|
+
return {
|
|
140
|
+
visitorKey,
|
|
141
|
+
sessionId,
|
|
142
|
+
device,
|
|
143
|
+
...journey ? { journey } : {}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
87
146
|
function readConsentedWebsiteVisit(siteId, consentAllowed) {
|
|
88
147
|
if (!consentAllowed || typeof window === "undefined") return void 0;
|
|
89
148
|
const win = window;
|
|
90
149
|
let visitorKey;
|
|
91
150
|
let sessionId;
|
|
92
|
-
let
|
|
151
|
+
let device;
|
|
152
|
+
let rawJourney;
|
|
93
153
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
154
|
+
if (typeof win.__wrVisitor?.getVisitContext === "function") {
|
|
155
|
+
const bridge = win.__wrVisitor.getVisitContext();
|
|
156
|
+
if (bridge === null) return void 0;
|
|
157
|
+
if (bridge) {
|
|
158
|
+
visitorKey = bridge.visitorKey;
|
|
159
|
+
sessionId = bridge.sessionId;
|
|
160
|
+
if (bridge.device === "desktop" || bridge.device === "mobile") {
|
|
161
|
+
device = bridge.device;
|
|
162
|
+
}
|
|
163
|
+
rawJourney = bridge.journey;
|
|
164
|
+
}
|
|
99
165
|
} else if (win.__wrVisitor) {
|
|
100
166
|
visitorKey = win.__wrVisitor.visitorKey;
|
|
101
167
|
sessionId = win.__wrVisitor.sessionId;
|
|
102
168
|
}
|
|
103
169
|
} catch {
|
|
104
170
|
}
|
|
171
|
+
if (!visitorKey) {
|
|
172
|
+
try {
|
|
173
|
+
visitorKey = readBrowserCookie("wr_vid") ?? window.localStorage.getItem("wr_vid") ?? window.localStorage.getItem("wr_visitor_key") ?? void 0;
|
|
174
|
+
} catch {
|
|
175
|
+
visitorKey = readBrowserCookie("wr_vid") ?? void 0;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (!sessionId && siteId) {
|
|
179
|
+
try {
|
|
180
|
+
const rawSession = window.localStorage.getItem(
|
|
181
|
+
`wr:visitors:session:${siteId}`
|
|
182
|
+
);
|
|
183
|
+
if (rawSession) {
|
|
184
|
+
const state = JSON.parse(rawSession);
|
|
185
|
+
if (state && typeof state.id === "string" && UUID_RE.test(state.id) && (typeof state.last !== "number" || Date.now() - state.last <= SESSION_IDLE_MS) && (!state.vid || !visitorKey || state.vid === visitorKey)) {
|
|
186
|
+
sessionId = state.id;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
} catch {
|
|
190
|
+
}
|
|
191
|
+
}
|
|
105
192
|
if (!sessionId && siteId) {
|
|
106
193
|
try {
|
|
107
194
|
sessionId = window.sessionStorage.getItem(`wr:session:${siteId}`) ?? void 0;
|
|
108
195
|
} catch {
|
|
109
196
|
}
|
|
110
197
|
}
|
|
111
|
-
if (!
|
|
198
|
+
if (!rawJourney && siteId) {
|
|
112
199
|
try {
|
|
113
|
-
|
|
200
|
+
const raw = window.localStorage.getItem(`wr:journey:${siteId}`);
|
|
201
|
+
if (raw) rawJourney = JSON.parse(raw);
|
|
114
202
|
} catch {
|
|
115
203
|
}
|
|
116
204
|
}
|
|
117
|
-
if (!
|
|
118
|
-
|
|
205
|
+
if (!device) {
|
|
206
|
+
device = typeof window.matchMedia === "function" && window.matchMedia("(max-width: 767px)").matches ? "mobile" : "desktop";
|
|
119
207
|
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
208
|
+
return sanitizeWebsiteVisit({
|
|
122
209
|
visitorKey,
|
|
123
210
|
sessionId,
|
|
124
211
|
device,
|
|
125
|
-
|
|
126
|
-
};
|
|
212
|
+
journey: rawJourney
|
|
213
|
+
});
|
|
127
214
|
}
|
|
128
215
|
|
|
129
216
|
// src/analytics/tracker.ts
|
|
130
217
|
var inMemorySessionId = null;
|
|
131
218
|
function isConsentCurrentlyAllowed(config) {
|
|
132
|
-
const decision = readStoredConsent(
|
|
219
|
+
const decision = readStoredConsent(
|
|
220
|
+
config.consent?.legacyConsentCookies ?? [],
|
|
221
|
+
config.siteId
|
|
222
|
+
);
|
|
133
223
|
const rawMode = readBrowserCookie(MODE_COOKIE);
|
|
134
224
|
const mode = rawMode === "opt-out" ? "opt-out" : "opt-in";
|
|
135
225
|
return analyticsAllowed(decision, mode, readGpcSignal());
|
|
@@ -221,6 +311,9 @@ function pushDataLayerEvent(event, extra, configOverride) {
|
|
|
221
311
|
export {
|
|
222
312
|
captureAttributionOnLanding,
|
|
223
313
|
readAttributionSnapshot,
|
|
314
|
+
MAX_JOURNEY_SERIALIZED_BYTES,
|
|
315
|
+
sanitizeWebsiteJourney,
|
|
316
|
+
sanitizeWebsiteVisit,
|
|
224
317
|
readConsentedWebsiteVisit,
|
|
225
318
|
trackPageView,
|
|
226
319
|
trackEvent,
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
captureAttributionOnLanding,
|
|
4
4
|
trackPageView
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-JPUCXNHR.js";
|
|
6
6
|
import {
|
|
7
7
|
useConsent
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-T4Q4VJ6K.js";
|
|
9
9
|
|
|
10
10
|
// src/analytics/page-tracker.tsx
|
|
11
11
|
import { useEffect, useRef } from "react";
|
|
@@ -89,13 +89,25 @@ function readBrowserCookie(name) {
|
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function legacyConsentStorageKey(siteId) {
|
|
93
|
+
return `wr:consent:${siteId?.trim() || "site"}`;
|
|
94
|
+
}
|
|
95
|
+
function readStoredConsent(legacyCookieNames = [], siteId) {
|
|
93
96
|
const direct = parseConsentValue(readBrowserCookie(CONSENT_COOKIE));
|
|
94
97
|
if (direct) return direct;
|
|
95
98
|
for (const legacy of legacyCookieNames) {
|
|
96
99
|
const migrated = parseConsentValue(readBrowserCookie(legacy));
|
|
97
100
|
if (migrated) return migrated;
|
|
98
101
|
}
|
|
102
|
+
if (siteId !== void 0 && typeof window !== "undefined") {
|
|
103
|
+
try {
|
|
104
|
+
const legacyChoice = window.localStorage.getItem(
|
|
105
|
+
legacyConsentStorageKey(siteId)
|
|
106
|
+
);
|
|
107
|
+
if (legacyChoice === "declined") return "analytics:no";
|
|
108
|
+
} catch {
|
|
109
|
+
}
|
|
110
|
+
}
|
|
99
111
|
return null;
|
|
100
112
|
}
|
|
101
113
|
function writeConsentCookie(value) {
|
|
@@ -119,7 +131,7 @@ function resolveGeoFromHeaders(headers) {
|
|
|
119
131
|
|
|
120
132
|
// src/consent/bootstrap.ts
|
|
121
133
|
function safeJson(value) {
|
|
122
|
-
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
134
|
+
return JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
123
135
|
}
|
|
124
136
|
var GTM_ID_RE = /^GTM-[A-Z0-9]{4,16}$/;
|
|
125
137
|
var GA4_ID_RE = /^G-[A-Z0-9]{4,16}$/;
|
|
@@ -153,6 +165,7 @@ function buildConsentBootstrapScript(options) {
|
|
|
153
165
|
const ga4Id = sanitizeGa4Id(options.ga4MeasurementId);
|
|
154
166
|
if (!visitorUrl && !gtmId && !ga4Id) return null;
|
|
155
167
|
const legacy = options.legacyConsentCookies ?? [];
|
|
168
|
+
const legacyStorageCheck = options.siteId !== void 0 ? `if(!c){try{if(window.localStorage.getItem(${safeJson(legacyConsentStorageKey(options.siteId))})==='declined')c='analytics:no';}catch(e){}}` : "";
|
|
156
169
|
const loaders = [];
|
|
157
170
|
if (visitorUrl) {
|
|
158
171
|
loaders.push(
|
|
@@ -169,7 +182,7 @@ function buildConsentBootstrapScript(options) {
|
|
|
169
182
|
`if(!document.getElementById('${GA4_SCRIPT_ID}')){window.dataLayer=window.dataLayer||[];function gtag(){window.dataLayer.push(arguments);}window.gtag=window.gtag||gtag;gtag('js',new Date());gtag('config',${safeJson(ga4Id)});var a=document.createElement('script');a.id='${GA4_SCRIPT_ID}';a.async=true;a.src=${safeJson(`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(ga4Id)}`)};a.setAttribute('data-consent-category','analytics');document.head.appendChild(a);}`
|
|
170
183
|
);
|
|
171
184
|
}
|
|
172
|
-
return `(function(){try{var g=function(n){var p=document.cookie.split('; ').find(function(v){return v.indexOf(n+'=')===0});return p?decodeURIComponent(p.slice(n.length+1)):null};var c=g('${CONSENT_COOKIE}');if(!c){var leg=${safeJson(legacy)};for(var i=0;i<leg.length;i++){var lv=g(leg[i]);if(lv){c=lv.indexOf('analytics:yes')>-1?'analytics:yes':lv.indexOf('analytics:no')>-1?'analytics:no':null;if(c)break;}}}if(c==='analytics:no')return;var gpc=navigator.globalPrivacyControl===true;if(c!=='analytics:yes'&&!(g('${MODE_COOKIE}')==='opt-out'&&!gpc))return;${loaders.join("")}}catch(e){}})();`;
|
|
185
|
+
return `(function(){try{var g=function(n){var p=document.cookie.split('; ').find(function(v){return v.indexOf(n+'=')===0});return p?decodeURIComponent(p.slice(n.length+1)):null};var c=g('${CONSENT_COOKIE}');if(!c){var leg=${safeJson(legacy)};for(var i=0;i<leg.length;i++){var lv=g(leg[i]);if(lv){c=lv.indexOf('analytics:yes')>-1?'analytics:yes':lv.indexOf('analytics:no')>-1?'analytics:no':null;if(c)break;}}}${legacyStorageCheck}if(c==='analytics:no')return;var gpc=navigator.globalPrivacyControl===true;if(c!=='analytics:yes'&&!(g('${MODE_COOKIE}')==='opt-out'&&!gpc))return;${loaders.join("")}}catch(e){}})();`;
|
|
173
186
|
}
|
|
174
187
|
|
|
175
188
|
// src/consent/provider.tsx
|
|
@@ -404,7 +417,7 @@ var bookingConfigSchema = z2.object({
|
|
|
404
417
|
var consentConfigSchema = z2.object({
|
|
405
418
|
enabled: z2.boolean().default(true),
|
|
406
419
|
message: z2.string().trim().optional().default(""),
|
|
407
|
-
policyUrl: z2.string().trim().optional().default("
|
|
420
|
+
policyUrl: z2.string().trim().optional().default(""),
|
|
408
421
|
/** Legacy cookie names to migrate silently for returning visitors (e.g. Brandywine Oak). */
|
|
409
422
|
legacyConsentCookies: z2.array(z2.string().trim().min(1)).optional().default([]),
|
|
410
423
|
/** Additional US states requiring opt-in beyond California (CA is always opt-in). */
|
|
@@ -414,7 +427,8 @@ var consentConfigSchema = z2.object({
|
|
|
414
427
|
});
|
|
415
428
|
var visitorsConfigSchema = z2.object({
|
|
416
429
|
enabled: z2.boolean().default(false),
|
|
417
|
-
siteScriptUrl: z2.string().trim().optional().default("")
|
|
430
|
+
siteScriptUrl: z2.string().trim().optional().default(""),
|
|
431
|
+
recordings: z2.boolean().optional()
|
|
418
432
|
});
|
|
419
433
|
var blogConfigSchema = z2.object({
|
|
420
434
|
enabled: z2.boolean().optional().default(true),
|
|
@@ -463,7 +477,7 @@ var siteConfigSchema = z2.object({
|
|
|
463
477
|
consent: consentConfigSchema.optional().default({
|
|
464
478
|
enabled: true,
|
|
465
479
|
message: "",
|
|
466
|
-
policyUrl: "
|
|
480
|
+
policyUrl: "",
|
|
467
481
|
legacyConsentCookies: [],
|
|
468
482
|
extraOptInUsRegions: [],
|
|
469
483
|
hideFloatingPrivacyButton: false
|
|
@@ -622,7 +636,7 @@ function ConsentProvider({
|
|
|
622
636
|
useEffect(() => {
|
|
623
637
|
let cancelled = false;
|
|
624
638
|
const legacyCookies = config.consent?.legacyConsentCookies ?? [];
|
|
625
|
-
const storedDecision = readStoredConsent(legacyCookies);
|
|
639
|
+
const storedDecision = readStoredConsent(legacyCookies, config.siteId);
|
|
626
640
|
const detectedGpc = readGpcSignal();
|
|
627
641
|
const rawMode = readBrowserCookie(MODE_COOKIE);
|
|
628
642
|
const finalize = (resolvedMode) => {
|
|
@@ -663,6 +677,18 @@ function ConsentProvider({
|
|
|
663
677
|
(value2) => {
|
|
664
678
|
const wasMounted = hasMountedThirdPartyScripts();
|
|
665
679
|
writeConsentCookie(value2);
|
|
680
|
+
if (typeof window !== "undefined") {
|
|
681
|
+
try {
|
|
682
|
+
const legacyKey = legacyConsentStorageKey(config.siteId);
|
|
683
|
+
if (value2 === "analytics:yes" || readBrowserCookie(CONSENT_COOKIE) === value2) {
|
|
684
|
+
window.localStorage.removeItem(legacyKey);
|
|
685
|
+
}
|
|
686
|
+
} catch {
|
|
687
|
+
}
|
|
688
|
+
window.dispatchEvent(
|
|
689
|
+
new CustomEvent("wr:consent-changed", { detail: { consent: value2 } })
|
|
690
|
+
);
|
|
691
|
+
}
|
|
666
692
|
setDecision(value2);
|
|
667
693
|
setBannerOpen(false);
|
|
668
694
|
setReopened(false);
|
|
@@ -757,6 +783,7 @@ export {
|
|
|
757
783
|
parseConsentValue,
|
|
758
784
|
readCookieFromString,
|
|
759
785
|
readBrowserCookie,
|
|
786
|
+
legacyConsentStorageKey,
|
|
760
787
|
readStoredConsent,
|
|
761
788
|
writeConsentCookie,
|
|
762
789
|
readGpcSignal,
|