Merge pull request 'Add configurable Plausible analytics' (#3) from dev into main
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
@@ -38,6 +38,11 @@ PUBLIC_API_URL=
|
|||||||
# Canonical origin for canonical links, OpenGraph tags and the sitemap.
|
# Canonical origin for canonical links, OpenGraph tags and the sitemap.
|
||||||
SITE_URL=https://cashumints.space
|
SITE_URL=https://cashumints.space
|
||||||
|
|
||||||
|
# Plausible-compatible analytics script and the domain reported with each page view.
|
||||||
|
# Leave either value empty to disable analytics.
|
||||||
|
PLAUSIBLE_URL=https://analytics.azzamo.net/js/script.js
|
||||||
|
PLAUSIBLE_DOMAIN=cashumints.space
|
||||||
|
|
||||||
# Whether a rated mint's JSON-LD also carries the review-snippet-eligible Product
|
# Whether a rated mint's JSON-LD also carries the review-snippet-eligible Product
|
||||||
# type next to Service (web/src/lib/schema.ts explains the trade). On by default;
|
# type next to Service (web/src/lib/schema.ts explains the trade). On by default;
|
||||||
# set to 0 to ship the plain Service node on the next build, no code change needed.
|
# set to 0 to ship the plain Service node on the next build, no code change needed.
|
||||||
|
|||||||
@@ -541,11 +541,13 @@ so a systemd `Environment=` line or a one-off `PORT=9000 pnpm dev:api` still ove
|
|||||||
### Web (`web/`)
|
### Web (`web/`)
|
||||||
|
|
||||||
| Variable | Default | Meaning |
|
| Variable | Default | Meaning |
|
||||||
| ---------------- | -------------------------- | --------------------------------------------- |
|
| ------------------ | ------------------------------------------------- | --------------------------------------------- |
|
||||||
| `WEB_PORT` | `4321` | Dev server and preview port |
|
| `WEB_PORT` | `4321` | Dev server and preview port |
|
||||||
| `API_URL` | `http://127.0.0.1:8787` | API origin used at build time |
|
| `API_URL` | `http://127.0.0.1:8787` | API origin used at build time |
|
||||||
| `PUBLIC_API_URL` | empty (same origin) | API origin baked into markup and islands |
|
| `PUBLIC_API_URL` | empty (same origin) | API origin baked into markup and islands |
|
||||||
| `SITE_URL` | `https://cashumints.space` | Canonical origin for meta tags |
|
| `SITE_URL` | `https://cashumints.space` | Canonical origin for meta tags |
|
||||||
|
| `PLAUSIBLE_URL` | `https://analytics.azzamo.net/js/script.js` | Analytics script URL; empty disables analytics |
|
||||||
|
| `PLAUSIBLE_DOMAIN` | `cashumints.space` | Domain reported to analytics; empty disables analytics |
|
||||||
| `RELAYS` | see `shared/src/nostr.ts` | Relays for the build-time review fetch |
|
| `RELAYS` | see `shared/src/nostr.ts` | Relays for the build-time review fetch |
|
||||||
| `BONES_URL` | `http://localhost:$WEB_PORT` | Dev server `pnpm bones` captures against |
|
| `BONES_URL` | `http://localhost:$WEB_PORT` | Dev server `pnpm bones` captures against |
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ const apiUrl = process.env.API_URL ?? 'http://127.0.0.1:8787';
|
|||||||
// https://api.cashumints.space.
|
// https://api.cashumints.space.
|
||||||
const publicApiUrl = process.env.PUBLIC_API_URL ?? '';
|
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.
|
// 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;
|
const port = Number.parseInt(process.env.WEB_PORT ?? '', 10) || 4321;
|
||||||
|
|
||||||
@@ -73,6 +79,8 @@ export default defineConfig({
|
|||||||
vite: {
|
vite: {
|
||||||
define: {
|
define: {
|
||||||
'import.meta.env.PUBLIC_API_URL': JSON.stringify(publicApiUrl),
|
'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 },
|
server: { proxy },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -130,6 +130,9 @@ const i18nPayload = JSON.stringify({ locale, catalog: clientCatalog(locale) }).r
|
|||||||
*/
|
*/
|
||||||
const imageUrl = new URL(image, site).href;
|
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.
|
* This page's JSON-LD, assembled here and nowhere else.
|
||||||
*
|
*
|
||||||
@@ -267,6 +270,9 @@ const noscriptMotion =
|
|||||||
{graph.length > 0 && (
|
{graph.length > 0 && (
|
||||||
<script type="application/ld+json" is:inline set:html={serializeGraph(graph)} />
|
<script type="application/ld+json" is:inline set:html={serializeGraph(graph)} />
|
||||||
)}
|
)}
|
||||||
|
{plausibleUrl && plausibleDomain && (
|
||||||
|
<script is:inline defer data-domain={plausibleDomain} src={plausibleUrl}></script>
|
||||||
|
)}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{/*
|
{/*
|
||||||
|
|||||||
Reference in New Issue
Block a user