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

@@ -3,6 +3,7 @@
import { useEffect } from 'react';
import { usePathname, useSearchParams } from 'next/navigation';
import { getAppServices } from '@/lib/services/create-services';
import Script from 'next/script';
/**
* AnalyticsProvider Component
@@ -40,6 +41,17 @@ export default function AnalyticsProvider() {
}
}, [pathname, searchParams]);
return null;
const websiteId = process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID;
if (!websiteId) return null;
return (
<Script
id="umami-analytics"
src="/stats/script.js"
data-website-id={websiteId}
strategy="afterInteractive"
defer
/>
);
}

View File

@@ -1,60 +0,0 @@
import Script from 'next/script';
interface UmamiScriptProps {
/**
* Custom website ID to override the environment variable
*/
websiteId?: string;
/**
* Custom script URL to override the environment variable
*/
scriptUrl?: string;
}
/**
* Umami Analytics Script Component
*
* Loads the Umami analytics script only when a website ID is available.
* Uses Next.js Script component with 'afterInteractive' strategy for optimal performance.
*
* @example
* ```tsx
* // Uses environment variables automatically
* <UmamiScript />
*
* // Or provide custom values
* <UmamiScript websiteId="custom-id" scriptUrl="https://custom.analytics.com/script.js" />
* ```
*/
export default function UmamiScript({ websiteId, scriptUrl }: UmamiScriptProps) {
// Use provided website ID or fall back to environment variable
const finalWebsiteId = websiteId ?? process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID;
// If no website ID is available, don't render the script
if (!finalWebsiteId) {
if (process.env.NODE_ENV === 'development') {
console.warn('[Umami] NEXT_PUBLIC_UMAMI_WEBSITE_ID is not set. Analytics will be disabled.');
}
return null;
}
// Use provided script URL or fall back to environment variable or default
const finalScriptUrl = scriptUrl ??
process.env.NEXT_PUBLIC_UMAMI_SCRIPT_URL ??
'https://analytics.infra.mintel.me/script.js';
return (
<Script
id="umami-analytics"
src={finalScriptUrl}
data-website-id={finalWebsiteId}
strategy="afterInteractive"
defer
// Add error handling for script loading failures
onError={(error) => {
console.error('[Umami] Failed to load analytics script:', error);
}}
/>
);
}