Skip to content

Commit

Permalink
feat(analytics): ga4 & gtm 추가 (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
seongminn authored Nov 2, 2024
1 parent 6abfa4b commit c6613fb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
17 changes: 17 additions & 0 deletions apps/spectator/app/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { GoogleAnalytics, GoogleTagManager } from '@next/third-parties/google';
import { Analytics as VercelAnalytics } from '@vercel/analytics/next';
import { SpeedInsights as VercelSpeedInsights } from '@vercel/speed-insights/next';

export default function AnalyticsProvider() {
if (process.env.NODE_ENV === 'development') return;

return (
<>
<VercelAnalytics />
<VercelSpeedInsights />

<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GA_ID || ''} />
<GoogleTagManager gtmId={process.env.NEXT_PUBLIC_GTM_ID || ''} />
</>
);
}
7 changes: 3 additions & 4 deletions apps/spectator/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Toaster } from '@hcc/ui';
import { Analytics } from '@vercel/analytics/react';
import { SpeedInsights } from '@vercel/speed-insights/next';
import { clsx } from 'clsx';
import { extend } from 'dayjs';
import customParseFormat from 'dayjs/plugin/customParseFormat';
import { Metadata, Viewport } from 'next';
import localFont from 'next/font/local';
import { ReactNode } from 'react';

import AnalyticsProvider from './analytics';
import * as styles from './layout.css';
import Providers from './Providers';
import '@hcc/styles/dist/globals.css';
Expand Down Expand Up @@ -50,8 +49,8 @@ export default function RootLayout({ children }: RootLayoutProps) {
<Toaster />
{children}
</Providers>
<Analytics />
<SpeedInsights />

<AnalyticsProvider />
</body>
</html>
);
Expand Down
1 change: 1 addition & 0 deletions apps/spectator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@hcc/icons": "workspace:^",
"@hcc/styles": "workspace:*",
"@hcc/ui": "workspace:*",
"@next/third-parties": "^15.0.2",
"@stomp/stompjs": "^7.0.0",
"@tanstack/react-query": "^5.17.19",
"@tanstack/react-query-devtools": "^5.17.21",
Expand Down
20 changes: 20 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c6613fb

Please sign in to comment.