fix(analytics): ensure Umami Website ID is visible to client bundle
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m18s
Build & Deploy / 🏗️ Build (push) Successful in 3m46s
Build & Deploy / 🚀 Deploy (push) Successful in 30s
Build & Deploy / 🔔 Notify (push) Successful in 2s

This commit is contained in:
2026-02-12 17:19:01 +01:00
parent 67046b9301
commit 0f705b474b
5 changed files with 19 additions and 6 deletions

View File

@@ -68,12 +68,15 @@ export class UmamiAnalyticsService implements AnalyticsService {
private async sendPayload(type: 'event', data: Record<string, any>) {
if (!this.options.enabled) return;
// On the client, we don't need the websiteId (it's injected by the server-side proxy handler).
// On the server, we need it because we're calling the Umami API directly.
const isClient = typeof window !== 'undefined';
const websiteId =
this.websiteId ||
(isClient ? (process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID as string) : undefined);
if (!isClient && !this.websiteId) {
this.logger.warn('Umami tracking called on server but no Website ID configured');
if (!websiteId) {
this.logger.warn(
`Umami tracking called on ${isClient ? 'client' : 'server'} but no Website ID configured`,
);
return;
}