Skip to content

Commit

Permalink
[Issue #1619] Update Google Analytics to add App Router support (#1879)
Browse files Browse the repository at this point in the history
## Summary
Fixes #1619 

### Time to review: __4 mins__

## Changes proposed
> Added GA to App Router

## Context for reviewers
> Next.js requires a different GA setup for pages using the App Router
compared to the page router.
https://nextjs.org/docs/messages/next-script-for-ga

## Additional information
> Screenshots, GIF demos, code examples or output to help show the
changes working as expected.
  • Loading branch information
btabaska authored Apr 30, 2024
1 parent 15296c5 commit fbf5100
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "src/styles/styles.scss";
import { GoogleAnalytics } from "@next/third-parties/google";
import { PUBLIC_ENV } from "../constants/environments";

import Layout from "src/components/AppLayout";
/**
Expand Down Expand Up @@ -30,6 +32,9 @@ export default function RootLayout({ children }: LayoutProps) {
{/* TODO: Add locale="english" prop when ready for i18n */}
<Layout>{children}</Layout>
</body>
{process.env.NEXT_PUBLIC_ENVIRONMENT === "prod" && (
<GoogleAnalytics gaId={PUBLIC_ENV.GOOGLE_TAG_ID} />
)}
</html>
);
}

2 comments on commit fbf5100

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for ./frontend

St.❔
Category Percentage Covered / Total
🟒 Statements 83.89% 854/1018
🟑 Branches 64.9% 220/339
🟑 Functions 75.34% 165/219
🟒 Lines 83.89% 797/950

Test suite run success

166 tests passing in 55 suites.

Report generated by πŸ§ͺjest coverage report action from fbf5100

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for ./frontend

St.❔
Category Percentage Covered / Total
🟒 Statements 83.89% 854/1018
🟑 Branches 64.9% 220/339
🟑 Functions 75.34% 165/219
🟒 Lines 83.89% 797/950

Test suite run success

166 tests passing in 55 suites.

Report generated by πŸ§ͺjest coverage report action from fbf5100

Please sign in to comment.