proxy urls
Some checks failed
Build & Deploy KLZ Cables / deploy (push) Failing after 2m21s

This commit is contained in:
2026-01-25 13:25:37 +01:00
parent cf5df1b46b
commit 1380d40b4d
7 changed files with 51 additions and 70 deletions

View File

@@ -71,7 +71,21 @@ export class UmamiAnalyticsService implements AnalyticsService {
*/
track(eventName: string, props?: AnalyticsEventProperties) {
if (!this.options.enabled) return;
if (typeof window === 'undefined') return;
// Server-side tracking via proxy
if (typeof window === 'undefined') {
const websiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID;
const umamiUrl = process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL?.replace('/script.js', '') || 'https://analytics.infra.mintel.me';
if (!websiteId) return;
fetch(`${umamiUrl}/api/send`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'User-Agent': 'KLZ-Server' },
body: JSON.stringify({ type: 'event', payload: { website: websiteId, name: eventName, data: props } }),
}).catch(() => {});
return;
}
const umami = (window as unknown as { umami?: UmamiGlobal }).umami;
umami?.track?.(eventName, props);
@@ -99,7 +113,21 @@ export class UmamiAnalyticsService implements AnalyticsService {
*/
trackPageview(url?: string) {
if (!this.options.enabled) return;
if (typeof window === 'undefined') return;
// Server-side tracking via proxy
if (typeof window === 'undefined') {
const websiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID;
const umamiUrl = process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL?.replace('/script.js', '') || 'https://analytics.infra.mintel.me';
if (!websiteId || !url) return;
fetch(`${umamiUrl}/api/send`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'User-Agent': 'KLZ-Server' },
body: JSON.stringify({ type: 'event', payload: { website: websiteId, url } }),
}).catch(() => {});
return;
}
const umami = (window as unknown as { umami?: UmamiGlobal }).umami;