Let Cloudron turn on named admins, the ops token, and Umami after the image is built.
Tracker env is read at request time and the CSP already allows the analytics host, so staging can set a rule admin, an ops bearer token, and the cookieless Umami site without rebuilding.
This commit is contained in:
1 parent
36112f95d3
commit
f7d88a7d5c
9 files changed
+132
-49
No files matched your search
+10
-2
@@ -1,10 +1,18 @@
|
||||
/**
|
||||
* Optional Umami tracker. Unset env vars mean no script ships.
|
||||
* Cookie-free mode is an Umami server setting, not this snippet.
|
||||
*
|
||||
* Values are read by key at request time so Cloudron `env set` works
|
||||
* without rebuilding the image (`NEXT_PUBLIC_*` is otherwise inlined
|
||||
* at `next build`).
|
||||
*/
|
||||
function readEnv(name: string): string {
|
||||
return process.env[name]?.trim() ?? "";
|
||||
}
|
||||
|
||||
export function umamiTracker(): { src: string; websiteId: string } | null {
|
||||
const src = process.env.NEXT_PUBLIC_UMAMI_SRC?.trim() ?? "";
|
||||
const websiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID?.trim() ?? "";
|
||||
const src = readEnv("NEXT_PUBLIC_UMAMI_SRC");
|
||||
const websiteId = readEnv("NEXT_PUBLIC_UMAMI_WEBSITE_ID");
|
||||
if (!src || !websiteId) return null;
|
||||
try {
|
||||
const url = new URL(src);
|
||||
|
||||
Reference in new issue
Block a user