-
Notifications
You must be signed in to change notification settings - Fork 0
📝 Scribe: Add docs for reportWebVitals #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
398cca9
7ccaa2a
0c7d8f2
7ab5e07
5323e78
abf7f20
7cc057f
ab9642d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,23 @@ | |
| */ | ||
|
|
||
| /** | ||
| * Reports Core Web Vitals and other metrics to the console | ||
| * Helps with debugging performance issues during development | ||
| * Instruments the application to collect and report Core Web Vitals and other key performance metrics. | ||
| * | ||
| * This function initializes `PerformanceObserver`s for Largest Contentful Paint (LCP), Cumulative Layout Shift (CLS), | ||
| * First Input Delay (FID), First Contentful Paint (FCP), and Time to First Byte (TTFB). These metrics are crucial | ||
| * for monitoring the real-world user experience and identifying performance bottlenecks. | ||
|
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs explicitly call out FID, which is deprecated in favor of INP in modern Core Web Vitals guidance. If the implementation already measures INP (or plans to), this comment will become misleading; if it truly measures FID, it’s worth noting that it’s legacy/deprecated to set expectations for readers. SuggestionUpdate the JSDoc to either (a) mention INP instead of FID (if applicable), or (b) explicitly mark FID as legacy. For example:
or
Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this change.
Comment on lines
+10
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix inaccurate TTFB instrumentation wording. Line 10-Line 12 says TTFB is collected via 🤖 Prompt for AI Agents |
||
| * | ||
| * @remarks | ||
| * Reporting is conditionally enabled. It will only log metrics to the console if the `NODE_ENV` environment | ||
| * variable is set to `"development"`, or if the `ENABLE_METRICS` environment variable is set to `"true"`. | ||
| * | ||
|
Comment on lines
+8
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JSDoc is now tightly coupled to specific implementation details (e.g., claiming it "initializes
Consider describing what is collected/reported (and under what conditions) without asserting how it is implemented, and update the metric list to reflect modern CWV ( SuggestionReword the JSDoc to avoid hard-coding implementation details and update the metrics list to reflect current Core Web Vitals. For example:
/**
* Instruments the application to collect and report key performance metrics.
*
* Collects metrics such as LCP, CLS, INP (replaces FID), FCP, and TTFB.
*
* @remarks
* Reporting is enabled in development (`NODE_ENV === "development"`) or when explicitly enabled (`ENABLE_METRICS === "true"`).
*/Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this tweak. |
||
| * @example | ||
| * ```typescript | ||
| * // In a top-level application entry point: | ||
| * import { reportWebVitals } from "./utils/performance-optimization"; | ||
| * | ||
| * reportWebVitals(); | ||
| * ``` | ||
| */ | ||
| export function reportWebVitals() { | ||
| if (typeof window !== 'undefined') { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The JSDoc incorrectly says TTFB is captured via
PerformanceObserver, but the code reads it from navigation timing entries.Prompt for AI agents