refactor(analytics): streamline Google Analytics integration and remove proxy routes

- Replaced the previous Google Analytics proxy routes with a direct integration in the layout component for improved performance and simplicity.
- Updated the Next.js configuration to include new rewrite rules for Google Analytics scripts and collection endpoints.
- Removed outdated proxy logic to enhance code clarity and maintainability.
This commit is contained in:
Evandro Fonseca Junior committed 2026-01-20 21:20:03 -03:00
1 parent 54d99fbffd
commit 525ef140fe
5 files changed
+40 -195

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
'use client';
import Script from 'next/script';
const GA_MEASUREMENT_ID = 'G-QTT9QT0T3S';
export default function GoogleAnalytics() {
return (
<>
<Script
src="/metrics/js/script.js"
strategy="afterInteractive"
/>
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_MEASUREMENT_ID}', {
transport_url: '/metrics/collect',
cookie_flags: 'SameSite=None;Secure',
allow_ad_personalization_signals: false,
anonymize_ip: true
});
`}
</Script>
</>
);
}