Skip to content

Commit

Permalink
App router migration analytics (#1123)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
boodland and eleanorreem authored Sep 20, 2024
1 parent bf7c899 commit db8dd34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -26,6 +26,7 @@ export default function RootLayout({
<ErrorBoundary>
<ThemeRegistry>{children}</ThemeRegistry>
</ErrorBoundary>
<Analytics />
</body>
</html>
);
Expand Down
13 changes: 13 additions & 0 deletions components/head/Analytics.tsx
Original file line number Diff line number Diff line change
@@ -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' && (
<Hotjar id={process.env.NEXT_PUBLIC_HOTJAR_ID} sv={6} strategy="lazyOnload" />
)}
<VercelAnalytics />
</>
);
}

0 comments on commit db8dd34

Please sign in to comment.