mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 16:46:42 +02:00
refactor(analytics): centralize Umami tracking via env vars and shared utility
Move Umami analytics from hardcoded script tags in app.html to server-side injection via hooks.server.ts. Website IDs are now managed centrally in .env.development and distributed via generate-env.mjs as PUBLIC_UMAMI_WEBSITE_ID. - Add @manacore/shared-utils/analytics-server with injectUmamiAnalytics() - Add UMAMI_WEBSITE_ID_* for all 17 web apps to .env.development - Add PUBLIC_UMAMI_WEBSITE_ID mapping in generate-env.mjs for all web apps - Update 10 existing hooks.server.ts to use shared utility - Create 7 new hooks.server.ts (picture, planta, presi, photos, clock, questions, manadeck) - Remove hardcoded Umami scripts from all 17 app.html files - Add missing Umami tracking to Mukke and Questions - Add shared-utils dependency to 6 web apps that lacked it - Update ANALYTICS.md with architecture docs and "add new app" guide Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
87516bb58a
commit
e01b740dba
44 changed files with 319 additions and 52 deletions
|
|
@ -5,8 +5,6 @@
|
|||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
%sveltekit.head%
|
||||
<!-- Umami Analytics -->
|
||||
<script defer src="https://stats.mana.how/script.js" data-website-id="1c43fd98-4767-4f89-9dc2-ebdfbd8960db"></script>
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import type { Handle } from '@sveltejs/kit';
|
||||
import { injectUmamiAnalytics } from '@manacore/shared-utils/analytics-server';
|
||||
|
||||
// Get client-side URLs from environment (Docker runtime)
|
||||
const PUBLIC_MANA_CORE_AUTH_URL_CLIENT =
|
||||
|
|
@ -22,7 +23,7 @@ export const handle: Handle = async ({ event, resolve }) => {
|
|||
window.__PUBLIC_MANA_CORE_AUTH_URL__ = ${JSON.stringify(PUBLIC_MANA_CORE_AUTH_URL_CLIENT)};
|
||||
window.__PUBLIC_BACKEND_URL__ = ${JSON.stringify(PUBLIC_BACKEND_URL_CLIENT)};
|
||||
</script>`;
|
||||
return html.replace('<head>', `<head>${envScript}`);
|
||||
return injectUmamiAnalytics(html.replace('<head>', `<head>${envScript}`));
|
||||
},
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue