Skip to content

added umami analytics#57

Merged
Abhijit-Jha merged 1 commit intomasterfrom
feat/umami-analytics
Jan 7, 2026
Merged

added umami analytics#57
Abhijit-Jha merged 1 commit intomasterfrom
feat/umami-analytics

Conversation

@Abhijit-Jha
Copy link
Copy Markdown
Member

@Abhijit-Jha Abhijit-Jha commented Jan 7, 2026

Summary by CodeRabbit

New Features

  • Integrated Umami analytics to enable application usage tracking and monitoring.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
itshover-icons Ready Ready Preview, Comment Jan 7, 2026 8:40am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Integrates Umami analytics into a Next.js application by introducing a new UmamiAnalytics component that conditionally loads the Umami tracking script based on environment variables, and includes it in the root layout alongside existing analytics.

Changes

Cohort / File(s) Summary
Umami Analytics Integration
components/UmamiAnalytics.tsx
New component that loads Umami analytics script via Next.js Script component. Reads NEXT_PUBLIC_UMAMI_SRC and NEXT_PUBLIC_UMAMI_ID environment variables; logs error and returns null if missing, otherwise renders Script with proper configuration and afterInteractive strategy.
Layout Integration
app/layout.tsx
Added import for UmamiAnalytics component and renders <UmamiAnalytics /> within RootLayout after existing Analytics component.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Hopping through analytics we go,
Umami tracking steals the show—
Scripts load quietly in the night,
Environment vars configured just right,
One more whisker for metrics delight! 📊

🚥 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 'added umami analytics' is directly related to the main change—adding Umami analytics functionality via a new component and integrating it into the app layout.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

@Abhijit-Jha Abhijit-Jha merged commit a9a6996 into master Jan 7, 2026
3 of 4 checks passed
@Abhijit-Jha Abhijit-Jha deleted the feat/umami-analytics branch January 7, 2026 08:43
Copy link
Copy Markdown
Contributor

@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

🤖 Fix all issues with AI agents
In @components/UmamiAnalytics.tsx:
- Around line 13-19: Remove the conflicting async attribute from the Next.js
Script component so the script respects the strategy prop: locate the <Script
id="umami-analytics" ... /> usage in the UmamiAnalytics component and delete the
async prop so it only uses src={umamiSrc}, data-website-id={umamiId} and
strategy="afterInteractive".
🧹 Nitpick comments (2)
components/UmamiAnalytics.tsx (2)

7-10: Consider removing or conditionalizing the error log.

The console.error will execute on every render when the environment variables are missing, potentially cluttering production logs. Consider either removing it entirely (silent skip) or wrapping it in a development check:

♻️ Suggested improvement
  if (!umamiSrc || !umamiId) {
-   console.error("Umami Analytics is not configured.");
+   if (process.env.NODE_ENV === 'development') {
+     console.warn("Umami Analytics is not configured.");
+   }
    return null;
  }

3-3: Consider adding an explicit return type annotation.

While TypeScript can infer the return type, explicitly annotating exported components improves code documentation and type safety.

♻️ Optional improvement
-export default function UmamiAnalytics() {
+export default function UmamiAnalytics(): JSX.Element | null {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d7bd63 and dd6e6ae.

📒 Files selected for processing (2)
  • app/layout.tsx
  • components/UmamiAnalytics.tsx
🔇 Additional comments (3)
app/layout.tsx (2)

16-16: LGTM!

The import statement follows the project's established patterns and correctly imports the new UmamiAnalytics component.


96-96: LGTM!

The placement of the UmamiAnalytics component is appropriate—rendered alongside the Vercel Analytics component and positioned outside the provider tree to avoid unnecessary re-renders.

components/UmamiAnalytics.tsx (1)

1-1: LGTM!

Correct import of the Next.js Script component for optimized script loading.

Comment on lines +13 to +19
<Script
id="umami-analytics"
src={umamiSrc}
data-website-id={umamiId}
strategy="afterInteractive"
async
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Next.js Script component strategy="afterInteractive" async attribute redundant

💡 Result:

Short answer: Yes — for Next.js <Script /> with strategy="afterInteractive" you generally should not add async. afterInteractive behaves like a deferred script (executed after hydration) and Next.js controls loading/execution order; adding async is unnecessary and can break ordering because async executes as soon as downloaded. See Next.js docs and the Chrome/Next.js guidance. [1][2]

Sources

  • Next.js Script docs (describes afterInteractive as the default / deferred behavior). [1]
  • Chrome for Developers blog post on optimizing third‑party scripts with Next.js (explains afterInteractive ≈ defer and why Script manages loading). [2]

Remove the async attribute — it conflicts with strategy="afterInteractive".

The async attribute executes scripts immediately upon download, which directly contradicts strategy="afterInteractive" that defers execution until after page hydration. Next.js Script component manages loading internally based on the strategy prop; the manual async attribute breaks this intended behavior and can cause the script to load prematurely.

Suggested change
    <Script
      id="umami-analytics"
      src={umamiSrc}
      data-website-id={umamiId}
      strategy="afterInteractive"
    />
🤖 Prompt for AI Agents
In @components/UmamiAnalytics.tsx around lines 13 - 19, Remove the conflicting
async attribute from the Next.js Script component so the script respects the
strategy prop: locate the <Script id="umami-analytics" ... /> usage in the
UmamiAnalytics component and delete the async prop so it only uses
src={umamiSrc}, data-website-id={umamiId} and strategy="afterInteractive".

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