feat: integrate Plausible analytics script and adjust routing for marketing site

This commit is contained in:
Mo Tarbin
2026-08-14 01:13:46 -04:00
parent e2b41c85f6
commit 27560a078c
3 changed files with 40 additions and 9 deletions

View File

@@ -16,6 +16,28 @@
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" /> <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
<meta name="msapplication-TileColor" content="#da532c" /> <meta name="msapplication-TileColor" content="#da532c" />
<meta name="theme-color" content="#ffffff" /> <meta name="theme-color" content="#ffffff" />
<!--
Plausible. This index.html is shared by the app and the marketing bundles
(see src/main.jsx), so the tag is gated rather than hardcoded: it loads
only when the page host matches VITE_APP_PLAUSIBLE_DOMAIN, which is the
site registered in Plausible. On app.donetick.com the host never matches,
so nothing loads. Unset the variable to disable it entirely.
-->
<script>
;(function () {
var domain = 'donetick.com'
// Vite leaves the literal placeholder when the variable is unset.
var host = window.location.hostname
if (host !== domain) return
var s = document.createElement('script')
s.defer = true
// s.setAttribute('data-domain', domain)
s.setAttribute('data-domain', 'donetick.com')
s.src = 'https://collector.wannaknow.link/js/script.js'
document.head.appendChild(s)
})()
</script>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>

View File

@@ -23,6 +23,9 @@ const AppRedirect = () => {
const router = createBrowserRouter([ const router = createBrowserRouter([
{ path: '/', element: <Landing /> }, { path: '/', element: <Landing /> },
// Mirrors the app router, where /welcome is the canonical Landing path —
// without it this falls through to AppRedirect and bounces to /login.
{ path: '/welcome', element: <Landing /> },
{ path: '/privacy', element: <PrivacyPolicyView /> }, { path: '/privacy', element: <PrivacyPolicyView /> },
{ path: '/terms', element: <TermsView /> }, { path: '/terms', element: <TermsView /> },
{ path: '*', element: <AppRedirect /> }, { path: '*', element: <AppRedirect /> },
@@ -50,17 +53,20 @@ const ThemeClass = () => {
return null return null
} }
// Same ordering constraint as contexts/Contexts.jsx: ThemeContext reads the
// active language via useLocalization() to pick the text direction, so
// LocalizationProvider has to sit above it.
const MarketingApp = () => ( const MarketingApp = () => (
<ThemeContext> <LocalizationProvider>
<ThemeClass /> <ThemeContext>
<QueryClientProvider client={queryClient}> <ThemeClass />
<LocalizationProvider> <QueryClientProvider client={queryClient}>
<ImpersonateUserProvider> <ImpersonateUserProvider>
<RouterProvider router={router} /> <RouterProvider router={router} />
</ImpersonateUserProvider> </ImpersonateUserProvider>
</LocalizationProvider> </QueryClientProvider>
</QueryClientProvider> </ThemeContext>
</ThemeContext> </LocalizationProvider>
) )
export default MarketingApp export default MarketingApp

View File

@@ -5,10 +5,13 @@ import React from 'react'
import ReactDOM from 'react-dom/client' import ReactDOM from 'react-dom/client'
const marketingHosts = new Set(['donetick.com', 'www.donetick.com']) const marketingHosts = new Set(['donetick.com', 'www.donetick.com'])
// ?site=marketing works in every build, not just dev, so preview deploys on
// *.pages.dev can exercise the marketing bundle. Landing on the app host with
// the flag set just renders the marketing pages — nothing sensitive is gated
// on this.
const isMarketingSite = const isMarketingSite =
marketingHosts.has(window.location.hostname) || marketingHosts.has(window.location.hostname) ||
(import.meta.env.DEV && new URLSearchParams(window.location.search).get('site') === 'marketing'
new URLSearchParams(window.location.search).get('site') === 'marketing')
export const Site = React.lazy(() => export const Site = React.lazy(() =>
isMarketingSite ? import('./MarketingApp.jsx') : import('./Application.jsx'), isMarketingSite ? import('./MarketingApp.jsx') : import('./Application.jsx'),