Skip to content

chore: integrate web vitals#7

Merged
prdai merged 10 commits intomainfrom
CROW-104-web-vitals-integration-for-rogue-store
Dec 21, 2025
Merged

chore: integrate web vitals#7
prdai merged 10 commits intomainfrom
CROW-104-web-vitals-integration-for-rogue-store

Conversation

@prdai
Copy link
Copy Markdown
Member

@prdai prdai commented Dec 2, 2025

Summary by CodeRabbit

  • New Features

    • Added client-side web vitals reporting with console logging to track performance metrics.
  • Chores

    • Switched runtime used for building/starting the app to Bun.
    • Expanded Tailwind content scanning to cover additional component files.
    • Added a gitignore entry to exclude Lighthouse output.

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

@prdai prdai requested a review from Methika1234 December 2, 2025 09:21
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 2, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds client-side Web Vitals reporting and logging, integrates the WebVitals component into the root layout (only in non-production), extends Tailwind content paths to include components, adds .lighthouse to .gitignore, and switches the Docker runner image and runtime invocation from Node.js to Bun.

Changes

Cohort / File(s) Summary
Web Vitals Monitoring
app/layout.tsx, _components/web-vitals.js, lib/utils.ts
Introduced a client WebVitals component using useReportWebVitals; wired <WebVitals /> into RootLayout wrapped by an NODE_ENV !== "production" check; added logWebVitals(metric: any) to log metrics.
Build & Runtime
Dockerfile
Replaced runner stage base image with oven/bun:1-alpine and changed final start command from node server.js to bun server.js; other stages largely unchanged.
Styling / Tooling
tailwind.config.ts
Added _components/**/*.{js,ts,jsx,tsx,mdx} to Tailwind content globs.
Git ignore
.gitignore
Added .lighthouse/ entry.
Formatting only
components/ui/button.tsx
Minor reformatting of ButtonProps interface line break; no behavioral or type changes.

Sequence Diagram

sequenceDiagram
    participant Browser as Browser (Client)
    participant Root as RootLayout
    participant WebVitals as WebVitals Component
    participant NextHook as useReportWebVitals (Next.js)
    participant Logger as logWebVitals
    participant Console as Browser Console

    Browser->>Root: Render app/layout
    Root->>WebVitals: Mount (conditional: NODE_ENV !== "production")
    WebVitals->>NextHook: Register reporting callback
    Note over Browser,NextHook: Page lifecycle events (load/paint/interaction)
    NextHook->>Logger: Invoke with metric object
    Logger->>Console: console.log(metric)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review focus:
    • app/layout.tsx — verify correct placement and conditional rendering of <WebVitals />.
    • _components/web-vitals.js & lib/utils.ts — confirm useReportWebVitals usage and logWebVitals signature/typing.
    • Dockerfile — ensure Bun runtime invocation and image choice are correct for production expectations.
    • tailwind.config.ts — check glob scope to avoid unintended file scanning.

Poem

🐰 I hopped through code at break of dawn,
I placed small measures on each bumpy lawn,
Metrics whispered secrets, I logged them with glee,
Bun hums the kettle, Tailwind tends the lea,
A rabbit’s patch grows tidy, swift, and free. 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: integrate web vitals' directly summarizes the main change—adding web vitals integration throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

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.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @prdai, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the application's performance monitoring capabilities by integrating Web Vitals reporting. It introduces a dedicated component and a logging utility, then strategically deploys this monitoring across various critical pages to gather essential user experience metrics. This foundational work will enable future analysis and optimization efforts to improve site performance.

Highlights

  • New WebVitals Component: A new client-side component, WebVitals, has been introduced in app/_components/web-vitals.js. This component leverages Next.js's useReportWebVitals hook to capture and report core web vital metrics.
  • Web Vitals Integration: The WebVitals component has been integrated into numerous page components across the application, including accessories, cart, checkout, checkout/success, error, gifts, men, home, products, product details, and women pages. This ensures that web vital metrics are reported for key user journeys.
  • Logging Utility: A new utility function, logWebVitals, has been added to lib/utils.ts. This function is responsible for logging the captured web vital metrics to the console.
  • Dependency Update: The package.json file has been updated to include loglevel as a new dependency, although the provided code snippets do not explicitly use it for logging web vitals.
  • Tailwind CSS Configuration: The tailwind.config.ts file has been updated to include the new _components directory in its content scanning paths, ensuring that any Tailwind CSS classes used within the new WebVitals component are correctly processed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Web Vitals reporting, which is a great addition for performance monitoring. However, the current implementation has a critical architectural issue: the WebVitals component is being called as a function (WebVitals()) in every page component. This violates the Rules of Hooks and will cause the application to crash. It also introduces a lot of code duplication. The correct approach is to render <WebVitals /> once in the root layout (app/layout.tsx) to apply it globally. I've left comments on app/accessories/page.tsx demonstrating the necessary changes, which should be applied to all other pages modified in this PR. Additionally, I've suggested improvements for type safety in the logWebVitals function and pointed out an unused dependency.

@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

cloudflare-workers-and-pages bot commented Dec 2, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
crow-rogue-store-dev 42dbbbe Commit Preview URL

Branch Preview URL
Dec 24 2025, 02:21 PM

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: 0

♻️ Duplicate comments (3)
app/checkout/success/page.tsx (1)

12-25: WebVitals usage mirrors HomePage pattern

This file follows the same WebVitals(); side-effect pattern as app/page.tsx. The general suggestions there (treating WebVitals consistently as either a hook or a component and possibly centralising its usage) apply here as well; no additional issues specific to this page.

app/accessories/page.tsx (1)

18-25: Consistent with global WebVitals pattern; consider aligning import style

This page’s WebVitals(); usage matches the pattern discussed in app/page.tsx (see that comment for abstraction suggestions). Functionally it’s fine. You may also want to standardize on either alias-based (@/app/_components/web-vitals) or relative imports for this module across pages for consistency.

app/checkout/page.tsx (1)

24-33: Checkout page WebVitals wiring matches other pages

The Checkout page wires WebVitals(); the same way as the other client pages, with a stable hook order. No new concerns here; the abstraction/centralization suggestions from app/page.tsx apply equally to this file.

🧹 Nitpick comments (7)
tailwind.config.ts (1)

7-7: Confirm whether ./_components is needed in Tailwind content

"./app/**/*.{js,ts,jsx,tsx,mdx}" already covers app/_components/**, so this additional ./_components/**/* entry is redundant unless you also have a top-level _components directory. Consider dropping it or clarifying the intended folder to keep the config minimal.

lib/utils.ts (1)

58-62: Tighten logWebVitals typing and integrate loglevel

Right now logWebVitals uses any plus a lint suppression and logs directly to console.log, while loglevel has been added as a dependency but isn’t used.

Consider:

  • Typing the argument with the Web Vitals metric type (e.g., from next/web-vitals or web-vitals), and
  • Using loglevel (e.g., log.info(metric)) so you can drop the // eslint-disable-next-line and have consistent, configurable logging.

Example diff for this block:

-// eslint-disable-next-line
-export const logWebVitals = (metric: any) => {
-  console.log(metric);
-};
+export const logWebVitals = (metric: unknown) => {
+  // e.g., narrow `metric` to the concrete Web Vitals type here if desired
+  // and route through your logging library:
+  // log.info("web-vitals", metric);
+  console.log(metric);
+};

(You’d also add a loglevel import at the top if you choose to wire it in.)

package.json (1)

34-34: Ensure loglevel is actually used or remove it

loglevel is added as a runtime dependency, but the current Web Vitals logger still uses console.log. To avoid unused dependencies, either:

  • Hook loglevel into logWebVitals (preferred for configurable logging), or
  • Remove loglevel for now and reintroduce it when you have a concrete usage.
app/page.tsx (1)

8-11: Clarify WebVitals abstraction and usage pattern

Here WebVitals() is invoked like a custom hook, but the implementation (in app/_components/web-vitals.js) looks like a component-style wrapper around useReportWebVitals. To reduce confusion and make hook usage more idiomatic:

  • Either treat it as a hook: rename to useWebVitals and keep calling it at the top of each client page, or
  • Treat it as a component: have it return null and render <WebVitals /> in a central place (e.g., a client-only wrapper) so instrumentation is registered once instead of on every page.

The current pattern works, but a clearer abstraction will make future changes to Web Vitals instrumentation safer and easier to follow, especially as more analytics logic is added.

app/men/page.tsx (1)

18-25: WebVitals wiring is correct; consider centralizing usage

Importing WebVitals and calling WebVitals() at the top of MenPage correctly ensures Web Vitals reporting is registered for this route. Longer term, you might consider mounting this once in a shared root layout/provider instead of per page to reduce duplication, but it's not required for correctness.

app/products/[slug]/page.tsx (1)

29-45: Align WebVitals import path style with other pages (optional)

WebVitals() is correctly integrated here. This file uses the alias path "@/app/_components/web-vitals" while other pages use "../_components/web-vitals". For consistency and easier refactors, consider standardizing on one style (likely the alias form everywhere), but it's purely a style/maintainability tweak.

app/_components/web-vitals.js (1)

1-6: WebVitals helper should explicitly return null to match Next.js documentation

The implementation correctly registers logWebVitals with useReportWebVitals. However, the official Next.js 15 App Router documentation shows this exact pattern should return null, allowing safe rendering as <WebVitals /> in your root layout (the recommended approach to keep the client boundary minimal).

Add return null; at the end of the function:

"use client";

import { useReportWebVitals } from "next/web-vitals";
import { logWebVitals } from "@/lib/utils";

export function WebVitals() {
  useReportWebVitals(logWebVitals);
+  return null;
}

Optionally add a comment to clarify its purpose. The logWebVitals import from @/lib/utils is correct.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1d8b8c and 3ee62bb.

⛔ Files ignored due to path filters (2)
  • bun.lock is excluded by !**/*.lock
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • app/_components/web-vitals.js (1 hunks)
  • app/accessories/page.tsx (1 hunks)
  • app/cart/page.tsx (2 hunks)
  • app/checkout/page.tsx (1 hunks)
  • app/checkout/success/page.tsx (2 hunks)
  • app/error.tsx (2 hunks)
  • app/gifts/page.tsx (1 hunks)
  • app/layout.tsx (1 hunks)
  • app/men/page.tsx (1 hunks)
  • app/page.tsx (1 hunks)
  • app/products/[slug]/page.tsx (2 hunks)
  • app/products/page.tsx (2 hunks)
  • app/women/page.tsx (1 hunks)
  • lib/utils.ts (1 hunks)
  • package.json (1 hunks)
  • tailwind.config.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (11)
app/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/cart/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/accessories/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/gifts/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/women/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/checkout/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/checkout/success/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/men/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/_components/web-vitals.js (1)
lib/utils.ts (1)
  • logWebVitals (60-62)
app/products/[slug]/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
app/products/page.tsx (1)
app/_components/web-vitals.js (1)
  • WebVitals (4-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test
  • GitHub Check: Workers Builds: rouge-store
🔇 Additional comments (6)
app/layout.tsx (1)

23-41: No-op layout change

Only formatting changed around the closing brace; layout behavior and structure remain intact. Nothing to address here.

app/products/page.tsx (1)

27-38: WebVitals integration in ProductsContent looks good

Calling WebVitals() at the start of ProductsContent cleanly hooks Web Vitals into this page without affecting existing state/logic; hook ordering is preserved.

app/error.tsx (1)

8-27: Error boundary now participates in Web Vitals reporting

Importing WebVitals and invoking WebVitals() at the top of ErrorPage cleanly ensures metrics are still collected when the error UI is shown, without changing the existing useEffect-based logging or reset behavior.

app/cart/page.tsx (1)

21-34: Cart page Web Vitals hook-in is straightforward and safe

The added WebVitals import and WebVitals() call at the top of CartPage correctly attach metrics reporting to this route without impacting cart state or conditional rendering for the empty/non-empty views.

app/women/page.tsx (1)

18-25: Women’s page instrumentation matches the pattern elsewhere

The Web Vitals integration here (WebVitals import and WebVitals() call) is consistent with other collection pages and does not alter the existing filtering or UI behavior.

app/gifts/page.tsx (1)

18-25: Gifts page Web Vitals hook-in is correct and non-intrusive

The WebVitals import and WebVitals() call at the top of GiftsPage correctly opt this route into metrics collection without affecting the existing gifts filtering or animations.

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

🧹 Nitpick comments (1)
_components/web-vitals.js (1)

5-8: Return null (or nothing) instead of rendering an empty <div>.
This component exists for side effects only; an extra div in RootLayout is avoidable.

 export const WebVitals = () => {
   useReportWebVitals(logWebVitals);
-  return <div></div>;
+  return null;
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5d0548 and f931120.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • _components/web-vitals.js (1 hunks)
  • app/layout.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/layout.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
_components/web-vitals.js (1)
lib/utils.ts (1)
  • logWebVitals (60-62)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Workers Builds: rouge-store
  • GitHub Check: build-and-push

@prdai prdai merged commit 3340f63 into main Dec 21, 2025
4 checks passed
prdai added a commit that referenced this pull request Mar 16, 2026
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.

3 participants