Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import GlobalClientEffects from '@/global/components/GlobalClientEffects';
import KakaoProvider from '@/global/context/KakaoProvider';
import QueryProvider from '@/global/context/QueryProvider';
import { GoogleAnalytics, GoogleTagManager } from '@next/third-parties/google';
import { GoogleAnalytics } from '@next/third-parties/google';
import type { Metadata } from 'next';
import localFont from 'next/font/local';
import './globals.css';
Expand Down Expand Up @@ -96,7 +96,6 @@ export default function RootLayout({
</Script> */}
{process.env.NODE_ENV === 'production' && (
<>
<GoogleTagManager gtmId='GTM-PH2N3NWM' />
<GoogleAnalytics gaId='G-2EN8NDYR97' />
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

GA ID가 코드에 하드코딩되어 있습니다. 유지보수성을 높이기 위해 이 값을 환경 변수(process.env.NEXT_PUBLIC_GA_ID)로 추출하는 것을 권장합니다. 이렇게 하면 여러 환경에서 다른 ID를 사용하거나 코드를 변경하지 않고 ID를 쉽게 업데이트할 수 있습니다. 제안된 코드의 !는 환경 변수가 항상 존재한다고 가정합니다. 만약 값이 없을 수 있다면, 렌더링 전에 유효성 검사를 추가하는 것이 안전합니다.

Suggested change
<GoogleAnalytics gaId='G-2EN8NDYR97' />
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GA_ID!} />

</>
)}
Expand Down
Loading