fix(analytics, perf): fix umami proxy route redirect and remove blocking 10MB video preload to fix pagespeed
This commit is contained in:
@@ -189,8 +189,7 @@ export default async function Layout(props: {
|
|||||||
<link rel="preconnect" href="https://img.infra.mintel.me" />
|
<link rel="preconnect" href="https://img.infra.mintel.me" />
|
||||||
<link rel="icon" href="/favicon.ico" sizes="any" />
|
<link rel="icon" href="/favicon.ico" sizes="any" />
|
||||||
<link rel="apple-touch-icon" href="/apple-icon.png" sizes="180x180" />
|
<link rel="apple-touch-icon" href="/apple-icon.png" sizes="180x180" />
|
||||||
{/* Preload critical hero video */}
|
|
||||||
<link rel="preload" as="video" href="/assets/videos/web/hero-bohrung.mp4" type="video/mp4" />
|
|
||||||
</head>
|
</head>
|
||||||
<body className="relative flex flex-col min-h-screen font-sans antialiased overflow-x-hidden selection:bg-primary/90 selection:text-white">
|
<body className="relative flex flex-col min-h-screen font-sans antialiased overflow-x-hidden selection:bg-primary/90 selection:text-white">
|
||||||
<NextIntlClientProvider messages={clientMessages} locale={safeLocale}>
|
<NextIntlClientProvider messages={clientMessages} locale={safeLocale}>
|
||||||
|
|||||||
@@ -40,7 +40,10 @@ export async function POST(request: NextRequest) {
|
|||||||
website: websiteId,
|
website: websiteId,
|
||||||
};
|
};
|
||||||
|
|
||||||
const umamiEndpoint = config.analytics.umami.apiEndpoint;
|
let umamiEndpoint = config.analytics.umami.apiEndpoint || 'https://analytics.infra.mintel.me';
|
||||||
|
if (!umamiEndpoint.startsWith('http')) {
|
||||||
|
umamiEndpoint = `https://${umamiEndpoint}`;
|
||||||
|
}
|
||||||
|
|
||||||
// Log the event (internal only)
|
// Log the event (internal only)
|
||||||
logger.debug('Forwarding analytics event', {
|
logger.debug('Forwarding analytics event', {
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
|
|
||||||
const PRELOAD_VIDEOS = [
|
|
||||||
'/assets/videos/web/hero-bohrung.mp4'
|
|
||||||
];
|
|
||||||
|
|
||||||
export function InitialLoader({ shouldShowLoader = true }: { shouldShowLoader?: boolean }) {
|
export function InitialLoader({ shouldShowLoader = true }: { shouldShowLoader?: boolean }) {
|
||||||
const [isLoading, setIsLoading] = useState(shouldShowLoader);
|
const [isLoading, setIsLoading] = useState(shouldShowLoader);
|
||||||
@@ -14,30 +11,11 @@ export function InitialLoader({ shouldShowLoader = true }: { shouldShowLoader?:
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!shouldShowLoader) return;
|
if (!shouldShowLoader) return;
|
||||||
|
|
||||||
// Fallback Timeout (4 Sekunden), falls Videos hängen
|
// Just show the animation for a short time to allow UI to mount,
|
||||||
|
// we don't preload 10MB videos anymore to save pagespeed!
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
finishLoading();
|
finishLoading();
|
||||||
}, 4000);
|
}, 1200);
|
||||||
|
|
||||||
let videosLoaded = 0;
|
|
||||||
|
|
||||||
const checkAllLoaded = () => {
|
|
||||||
videosLoaded++;
|
|
||||||
if (videosLoaded === PRELOAD_VIDEOS.length) {
|
|
||||||
clearTimeout(timeout);
|
|
||||||
// Kleine Verzögerung für die smootheness
|
|
||||||
setTimeout(finishLoading, 800);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
PRELOAD_VIDEOS.forEach((src) => {
|
|
||||||
const video = document.createElement('video');
|
|
||||||
video.preload = 'auto';
|
|
||||||
video.oncanplaythrough = checkAllLoaded;
|
|
||||||
video.onerror = checkAllLoaded; // bei Fehler trotzdem weitermachen
|
|
||||||
video.src = src;
|
|
||||||
video.load();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
|
|||||||
3
proxy.ts
3
proxy.ts
@@ -9,8 +9,9 @@ export default createMiddleware({
|
|||||||
export const config = {
|
export const config = {
|
||||||
// Match all pathnames except for
|
// Match all pathnames except for
|
||||||
// - /api (API routes)
|
// - /api (API routes)
|
||||||
|
// - /stats (Analytics proxy)
|
||||||
// - /_next (Next.js internals)
|
// - /_next (Next.js internals)
|
||||||
// - /_static (inside /public)
|
// - /_static (inside /public)
|
||||||
// - all root files inside /public (e.g. /favicon.ico)
|
// - all root files inside /public (e.g. /favicon.ico)
|
||||||
matcher: ['/((?!api|_next|assets|_static|_vercel|[\\w-]+\\.\\w+).*)']
|
matcher: ['/((?!api|stats|_next|assets|_static|_vercel|[\\w-]+\\.\\w+).*)']
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user