fix(analytics): restore Smart Proxy mechanism and remove conflicting rewrites
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 9s
Build & Deploy / 🧪 QA (push) Successful in 1m36s
Build & Deploy / 🏗️ Build (push) Successful in 6m37s
Build & Deploy / 🚀 Deploy (push) Successful in 31s
Build & Deploy / 🔔 Notify (push) Successful in 2s

This commit is contained in:
2026-02-12 17:33:42 +01:00
parent 0f705b474b
commit d7f5504149
7 changed files with 6 additions and 34 deletions

View File

@@ -29,9 +29,9 @@ function createConfig() {
analytics: {
umami: {
websiteId: env.NEXT_PUBLIC_UMAMI_WEBSITE_ID || env.UMAMI_WEBSITE_ID,
websiteId: env.UMAMI_WEBSITE_ID,
apiEndpoint: env.UMAMI_API_ENDPOINT,
enabled: Boolean(env.NEXT_PUBLIC_UMAMI_WEBSITE_ID || env.UMAMI_WEBSITE_ID),
enabled: Boolean(env.UMAMI_WEBSITE_ID),
},
},

View File

@@ -25,8 +25,6 @@ const envExtension = {
// Analytics
UMAMI_WEBSITE_ID: z.string().optional(),
NEXT_PUBLIC_UMAMI_WEBSITE_ID: z.string().optional(),
UMAMI_API_ENDPOINT: z.string().optional(),
};
/**

View File

@@ -68,15 +68,12 @@ 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 (!websiteId) {
this.logger.warn(
`Umami tracking called on ${isClient ? 'client' : 'server'} but no Website ID configured`,
);
if (!isClient && !this.websiteId) {
this.logger.warn('Umami tracking called on server but no Website ID configured');
return;
}