feat: integrate Plausible analytics script and adjust routing for marketing site
This commit is contained in:
22
index.html
22
index.html
@@ -16,6 +16,28 @@
|
||||
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
|
||||
<meta name="msapplication-TileColor" content="#da532c" />
|
||||
<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>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -23,6 +23,9 @@ const AppRedirect = () => {
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{ 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: '/terms', element: <TermsView /> },
|
||||
{ path: '*', element: <AppRedirect /> },
|
||||
@@ -50,17 +53,20 @@ const ThemeClass = () => {
|
||||
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 = () => (
|
||||
<ThemeContext>
|
||||
<ThemeClass />
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<LocalizationProvider>
|
||||
<LocalizationProvider>
|
||||
<ThemeContext>
|
||||
<ThemeClass />
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ImpersonateUserProvider>
|
||||
<RouterProvider router={router} />
|
||||
</ImpersonateUserProvider>
|
||||
</LocalizationProvider>
|
||||
</QueryClientProvider>
|
||||
</ThemeContext>
|
||||
</QueryClientProvider>
|
||||
</ThemeContext>
|
||||
</LocalizationProvider>
|
||||
)
|
||||
|
||||
export default MarketingApp
|
||||
|
||||
@@ -5,10 +5,13 @@ import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
|
||||
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 =
|
||||
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(() =>
|
||||
isMarketingSite ? import('./MarketingApp.jsx') : import('./Application.jsx'),
|
||||
|
||||
Reference in New Issue
Block a user