Add configurable Plausible analytics
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,6 +28,12 @@ const apiUrl = process.env.API_URL ?? 'http://127.0.0.1:8787';
|
||||
// https://api.cashumints.space.
|
||||
const publicApiUrl = process.env.PUBLIC_API_URL ?? '';
|
||||
|
||||
// Plausible-compatible analytics endpoint and site identifier. Empty values disable the
|
||||
// script, which is useful for local builds that should not report page views.
|
||||
const plausibleUrl =
|
||||
process.env.PLAUSIBLE_URL ?? 'https://analytics.azzamo.net/js/script.js';
|
||||
const plausibleDomain = process.env.PLAUSIBLE_DOMAIN ?? 'cashumints.space';
|
||||
|
||||
// Dev server and preview port. Set WEB_PORT in .env; a --port flag still overrides it.
|
||||
const port = Number.parseInt(process.env.WEB_PORT ?? '', 10) || 4321;
|
||||
|
||||
@@ -73,6 +79,8 @@ export default defineConfig({
|
||||
vite: {
|
||||
define: {
|
||||
'import.meta.env.PUBLIC_API_URL': JSON.stringify(publicApiUrl),
|
||||
'import.meta.env.PLAUSIBLE_URL': JSON.stringify(plausibleUrl),
|
||||
'import.meta.env.PLAUSIBLE_DOMAIN': JSON.stringify(plausibleDomain),
|
||||
},
|
||||
server: { proxy },
|
||||
},
|
||||
|
||||
@@ -130,6 +130,9 @@ const i18nPayload = JSON.stringify({ locale, catalog: clientCatalog(locale) }).r
|
||||
*/
|
||||
const imageUrl = new URL(image, site).href;
|
||||
|
||||
const plausibleUrl = import.meta.env.PLAUSIBLE_URL;
|
||||
const plausibleDomain = import.meta.env.PLAUSIBLE_DOMAIN;
|
||||
|
||||
/**
|
||||
* This page's JSON-LD, assembled here and nowhere else.
|
||||
*
|
||||
@@ -267,6 +270,9 @@ const noscriptMotion =
|
||||
{graph.length > 0 && (
|
||||
<script type="application/ld+json" is:inline set:html={serializeGraph(graph)} />
|
||||
)}
|
||||
{plausibleUrl && plausibleDomain && (
|
||||
<script is:inline defer data-domain={plausibleDomain} src={plausibleUrl}></script>
|
||||
)}
|
||||
</head>
|
||||
<body>
|
||||
{/*
|
||||
|
||||
Reference in New Issue
Block a user