Skip to content

Commit

Permalink
Merge pull request #59 from depromeet/feat/monitoring-setting
Browse files Browse the repository at this point in the history
Feat/monitoring setting
  • Loading branch information
JUNOSHON authored Dec 12, 2023
2 parents 96fdd91 + 9d288c3 commit f24bf5a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Metadata } from 'next';
import MonitoringInitializer from '@/components/MonitoringInitializer';
import { css } from '@/styled-system/css';
import { pretendardFont } from '@/styles/font';

Expand All @@ -15,6 +16,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<html lang="en" suppressHydrationWarning className={pretendardFont.variable}>
<body>
<MonitoringInitializer />
<QueryProvider>
<div className={css(containerCss)}>{children}</div>
</QueryProvider>
Expand Down
2 changes: 2 additions & 0 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default function Home() {
<h1 className={MainTitleCss}>하루 10분의 변화를 경험하세요.</h1>
</div>
<Link className={LinkCss} href={'/select'}>
{/* 이후 추가될 믹스패널 이벤트는 아래와 같이 추적 */}
{/* mixpanel.track("이벤트명"); */}
<button type={'button'} className={LoginButtonCss}>
게스트 로그인
</button>
Expand Down
31 changes: 31 additions & 0 deletions src/components/MonitoringInitializer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Script from 'next/script';

const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS;

const MonitoringInitializer = () => {
return (
<>
{
<>
<Script strategy="afterInteractive" src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`} />
<Script
id="gtag-init"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${GA_TRACKING_ID}', {
page_path: window.location.pathname,
});
`,
}}
/>
</>
}
</>
);
};

export default MonitoringInitializer;

0 comments on commit f24bf5a

Please sign in to comment.