Skip to content

feat/ms-clarity#189

Merged
rklpoi5678 merged 2 commits intodevfrom
feat/ms-clarity
Feb 25, 2026
Merged

feat/ms-clarity#189
rklpoi5678 merged 2 commits intodevfrom
feat/ms-clarity

Conversation

@rklpoi5678
Copy link
Contributor

@rklpoi5678 rklpoi5678 commented Feb 25, 2026

🔗 관련 이슈

  • Closes #이슈번호

✨ 작업 단계 및 변경 사항

  • 작업 단계: (Phase 1: 기능 구현 / Phase 2: 디자인 및 API 연동)
  • 변경 사항:
    • 예: B0 수업 목록 페이지 뼈대 및 라우팅 구현
    • 예: 공통 버튼 컴포넌트 상태 로직 추가

🧪 테스트 방법

리뷰어가 확인해야 할 핵심 포인트를 적어주세요.

  • 브라우저에서 ID: B0 페이지가 정상적으로 렌더링되는가?
  • Phase 1 기준, 버튼 클릭 시 콘솔에 로그가 잘 찍히는가?

📸 스크린샷 (선택)

  • UI 변경이 있거나 Phase 2 작업인 경우 반드시 첨부해주세요.

✅ 체크리스트

  • Phase에 맞는 이슈 체크리스트를 모두 완료했는가?
  • lint / type-check 통과 및 불필요한 console.log 제거
  • 머지 후 이 이슈가 [QA] 컬럼으로 이동함을 인지하고 있는가?

Summary by CodeRabbit

  • Chores
    • Added conditional Microsoft Clarity analytics so tracking is injected only in production, alongside existing analytics, to improve monitoring of performance, user interactions, and system health.

@rklpoi5678 rklpoi5678 self-assigned this Feb 25, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

Conditionally injects the Microsoft Clarity analytics script into the RootLayout when NEXT_PUBLIC_APP_ENV indicates production, using Next.js Script with afterInteractive strategy; adds an isProd constant and imports next/script.

Changes

Cohort / File(s) Summary
Microsoft Clarity Integration
src/app/layout.tsx
Imported next/script; added isProd (based on NEXT_PUBLIC_APP_ENV); conditionally renders Microsoft Clarity <Script> with strategy="afterInteractive" when isProd is true. Minor lines added/removed (+13/-0).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • EduOps-Lab/ssambee-fe#174 — also modifies src/app/layout.tsx to inject analytics scripts (Vercel Analytics/SpeedInsights); related integration point in RootLayout.

Suggested labels

feature, FE

Suggested reviewers

  • yoorrll
  • p-changki

Poem

🐰 I hopped in code to plant a trace,
A tiny script that wakes in production's space,
Quiet and swift, it joins the flight,
Watching paths by day and night. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat/ms-clarity' is specific and directly related to the main change—adding Microsoft Clarity analytics integration to the layout.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/ms-clarity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/app/layout.tsx (1)

94-94: Move the hardcoded Clarity project ID to an environment variable.

The existing GA_ID is already read from process.env.NEXT_PUBLIC_GA_ID — apply the same pattern here so the Clarity project ID can be rotated or changed without a code change.

♻️ Proposed refactor

Add to your .env files:

NEXT_PUBLIC_CLARITY_ID=vmrhru1kzt

Then apply this diff:

 const GA_ID = process.env.NEXT_PUBLIC_GA_ID;
+const CLARITY_ID = process.env.NEXT_PUBLIC_CLARITY_ID;
 const isProd = process.env.NEXT_PUBLIC_APP_ENV === "production";

And update the condition and inline script:

-      {isProd && (
+      {isProd && CLARITY_ID && (
         <Script id="microsoft-clarity" strategy="afterInteractive">
           {`
               (function(c,l,a,r,i,t,y){
                 c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
                 t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
                 y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
-              })(window, document, "clarity", "script", "vmrhru1kzt");
+              })(window, document, "clarity", "script", "${CLARITY_ID}");
           `}
         </Script>
       )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/layout.tsx` at line 94, Replace the hardcoded Clarity project ID
string ("vmrhru1kzt") in src/app/layout.tsx with an environment variable similar
to GA_ID: read NEXT_PUBLIC_CLARITY_ID from process.env and use that value when
injecting the Clarity script (the IIFE that calls clarity/script with arguments
including "vmrhru1kzt"); also update any conditional that checks for GA_ID to
also check NEXT_PUBLIC_CLARITY_ID before injecting, and ensure you fall back or
skip injection if NEXT_PUBLIC_CLARITY_ID is undefined.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/layout.tsx`:
- Around line 86-98: Remove the explicit <head> wrapper around the Script in
layout.tsx: instead of rendering <head>{isProd && <Script ...>}</head>, place
the next/script <Script> component directly in the JSX tree (e.g., alongside
where GoogleAnalytics is rendered) and guard it with the isProd check; this
prevents emitting an empty <head> when not in production and avoids hydration
warnings—also prefer the metadata API for any actual <head> metadata rather than
manual head markup.

---

Nitpick comments:
In `@src/app/layout.tsx`:
- Line 94: Replace the hardcoded Clarity project ID string ("vmrhru1kzt") in
src/app/layout.tsx with an environment variable similar to GA_ID: read
NEXT_PUBLIC_CLARITY_ID from process.env and use that value when injecting the
Clarity script (the IIFE that calls clarity/script with arguments including
"vmrhru1kzt"); also update any conditional that checks for GA_ID to also check
NEXT_PUBLIC_CLARITY_ID before injecting, and ensure you fall back or skip
injection if NEXT_PUBLIC_CLARITY_ID is undefined.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 129d992 and 5eb63f2.

📒 Files selected for processing (1)
  • src/app/layout.tsx

@github-actions
Copy link

⚡️ Lighthouse Report

🏠 URL: http://localhost:3000/

Category Score
🔴 Performance 39
🟢 Accessibility 96
🟢 Best practices 93
🟢 SEO 100

상세 리포트는 하단의 lhci/url Checks 내 Details 링크를 확인해주세요! 🚀

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/app/layout.tsx (1)

93-100: Move the Clarity project ID to env config.

Hardcoding the ID on Line 99 makes rotation and environment separation harder. Prefer NEXT_PUBLIC_CLARITY_PROJECT_ID and only render when it is set.

♻️ Proposed refactor
 const GA_ID = process.env.NEXT_PUBLIC_GA_ID;
 const isProd = process.env.NEXT_PUBLIC_APP_ENV === "production";
+const CLARITY_PROJECT_ID = process.env.NEXT_PUBLIC_CLARITY_PROJECT_ID;

@@
-      {isProd && (
+      {isProd && CLARITY_PROJECT_ID && (
         <Script id="microsoft-clarity" strategy="afterInteractive">
           {`
                 (function(c,l,a,r,i,t,y){
                   c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
                   t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
                   y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
-                })(window, document, "clarity", "script", "vmrhru1kzt");
+                })(window, document, "clarity", "script", "${CLARITY_PROJECT_ID}");
             `}
         </Script>
       )}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/layout.tsx` around lines 93 - 100, Replace the hardcoded Clarity
project ID in the microsoft-clarity Script block with the environment variable
NEXT_PUBLIC_CLARITY_PROJECT_ID and only render the <Script
id="microsoft-clarity" ...> when that env var is present; locate the Script
block in src/app/layout.tsx (Script id="microsoft-clarity") and change logic to
read process.env.NEXT_PUBLIC_CLARITY_PROJECT_ID (or use Next.js runtime env
access) and guard rendering so the injected script template uses that variable
instead of "vmrhru1kzt".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/layout.tsx`:
- Around line 92-102: Wrap all analytics script injections (the Script with id
"microsoft-clarity" and any Vercel Analytics, SpeedInsights, GoogleAnalytics
injections) behind a runtime consent check instead of only isProd; add or use a
consent API (e.g., hasConsent('analytics') or read consent cookie/state) inside
the Layout component and only render or dynamically inject those Script
components when consent is true, or queue them and load them in a
useEffect/dynamic import after consent is granted; ensure the check is applied
to the Script id="microsoft-clarity" and corresponding places that render
analytics so no tracking code is executed before user consent.

---

Nitpick comments:
In `@src/app/layout.tsx`:
- Around line 93-100: Replace the hardcoded Clarity project ID in the
microsoft-clarity Script block with the environment variable
NEXT_PUBLIC_CLARITY_PROJECT_ID and only render the <Script
id="microsoft-clarity" ...> when that env var is present; locate the Script
block in src/app/layout.tsx (Script id="microsoft-clarity") and change logic to
read process.env.NEXT_PUBLIC_CLARITY_PROJECT_ID (or use Next.js runtime env
access) and guard rendering so the injected script template uses that variable
instead of "vmrhru1kzt".

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb63f2 and a57132f.

📒 Files selected for processing (1)
  • src/app/layout.tsx

@github-actions
Copy link

⚡️ Lighthouse Report

🏠 URL: http://localhost:3000/

Category Score
🔴 Performance 41
🟢 Accessibility 96
🟢 Best practices 93
🟢 SEO 100

상세 리포트는 하단의 lhci/url Checks 내 Details 링크를 확인해주세요! 🚀

@rklpoi5678 rklpoi5678 merged commit 0b39240 into dev Feb 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant