File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,20 +71,6 @@ Implement mitigations in test/e2e/specs/07-performance/PERFORMANCE.md
7171
7272Right now we're using string literals to define HTML email templates for site mails. We should use Nunjucks with the rule-checking for valid CSS in HTML emails like we have in the corporate email footer repo.
7373
74- ## Analytics
75-
76- Vercel Analytics
77-
78- - Highlighter component
79- - Social Shares component
80- - Social Embeds: Track embed interactions
81- - Cookie Consent
82- - Download Form component
83-
84- npm i @vercel/analytics
85- import Analytics from '@vercel/analytics /astro'
86- https://vercel.com/docs/analytics/quickstart#add-the-analytics-component-to-your-app
87-
8874## Set up webmentions
8975
9076Needs to add real API key and test
Original file line number Diff line number Diff line change 1+ ---
2+ import VercelAnalytics from ' @vercel/analytics/astro'
3+ import { isProd } from ' @components/scripts/utils/environmentClient'
4+
5+ const prod = isProd ()
6+ const mode = prod ? ' production' : ' development'
7+ const debug = ! prod
8+ ---
9+
10+ <script >
11+ window.webAnalyticsBeforeSend = (event) => {
12+ /** Ignore testing pages in tracking */
13+ if (event?.url?.includes('/testing/')) {
14+ return null
15+ }
16+ return event
17+ }
18+ </script >
19+ <VercelAnalytics
20+ debug ={ debug }
21+ mode ={ mode }
22+ />
Original file line number Diff line number Diff line change 1+ ---
2+ /**
3+ * Prefetch offline page during idle time for service worker
4+ */
5+ ---
6+
7+ <script >
8+ import { handleScriptError } from '@components/scripts/errors/handler'
9+
10+ const prefetch = (url: string) => {
11+ try {
12+ fetch(url, { credentials: 'same-origin' }).catch((error) => {
13+ handleScriptError(error, { scriptName: 'BaseLayout', operation: `prefetch ${url}` })
14+ })
15+ } catch (error) {
16+ handleScriptError(error, { scriptName: 'BaseLayout', operation: `prefetch ${url}` })
17+ }
18+ }
19+ if (typeof requestIdleCallback === 'function') {
20+ requestIdleCallback(() => prefetch('/offline'))
21+ } else {
22+ setTimeout(() => prefetch('/offline'), 500)
23+ }
24+ </script >
Original file line number Diff line number Diff line change 11---
2+ import Analytics from ' @components/Analytics/index.astro'
23import Breadcrumbs from ' @components/Breadcrumbs/index.astro'
34import Container from ' @components/Layout/Container/index.astro'
45import CookieConsent from ' @components/Consent/Banner/index.astro'
56import Footer from ' @components/Footer/index.astro'
67import HeadContent from ' @components/Head/index.astro'
78import Header from ' @components/Header/index.astro'
89import Content from ' @components/Layout/Content/index.astro'
10+ import PrefetchOfflinePage from ' @components/Pwa/PrefetchOfflinePage/index.astro'
911import PwaTitleBar from ' @components/Pwa/TitleBar/index.astro'
1012import RegisterServiceWorker from ' @components/Pwa/ServiceWorker/index.astro'
1113import Skip from ' @components/Layout/Skip/index.astro'
@@ -105,16 +107,12 @@ const {
105107 </Content >
106108 <Footer />
107109 </Container >
110+ { /** Vercel Analytics */ }
111+ <Analytics />
108112 { /* Register the service worker via @vite-pwa/astro virtual module */ }
109113 <RegisterServiceWorker />
110- <script >
111- const prefetch = (url: string) => fetch(url, { credentials: 'same-origin' }).catch(() => {})
112- if (typeof requestIdleCallback === 'function') {
113- requestIdleCallback(() => prefetch('/offline'))
114- } else {
115- setTimeout(() => prefetch('/offline'), 500)
116- }
117- </script >
114+ { /* Prefetch offline page during idle time for service worker */ }
115+ <PrefetchOfflinePage />
118116 </body >
119117 </>
120118</html >
You can’t perform that action at this time.
0 commit comments