From 4cc5a37aef121e01915a89582355081bbbafb507 Mon Sep 17 00:00:00 2001 From: Alberto Arias Date: Fri, 20 Sep 2024 16:14:51 +0200 Subject: [PATCH] App router migration analytics (#1123) * Add basic Root Layout * Add metadata * Add reference included by next * Add comment to explain the default meta tags * Add public testing page to check the migration * Remove non required file * Create Analytics component * Add analytics to root layout * Update layout.tsx --------- Co-authored-by: eleanorreem --- app/layout.tsx | 3 ++- components/head/Analytics.tsx | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 components/head/Analytics.tsx diff --git a/app/layout.tsx b/app/layout.tsx index d047a338..9eb58a9c 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,9 +1,9 @@ +import Analytics from '../components/head/Analytics'; import GoogleTagManagerScript from '../components/head/GoogleTagManagerScript'; import ErrorBoundary from '../components/layout/ErrorBoundary'; import rootMetadata from './rootMetadata'; import RollbarScript from '../components/head/RollbarScript'; import ThemeRegistry from './ThemeRegistry'; -import rootMetadata from './rootMetadata'; export const metadata = rootMetadata; @@ -26,6 +26,7 @@ export default function RootLayout({ {children} + ); diff --git a/components/head/Analytics.tsx b/components/head/Analytics.tsx new file mode 100644 index 00000000..ac86d261 --- /dev/null +++ b/components/head/Analytics.tsx @@ -0,0 +1,13 @@ +import { Analytics as VercelAnalytics } from '@vercel/analytics/react'; +import { Hotjar } from 'nextjs-hotjar'; + +export default function Analytics() { + return ( + <> + {!!process.env.NEXT_PUBLIC_HOTJAR_ID && process.env.NEXT_PUBLIC_ENV !== 'local' && ( + + )} + + + ); +}