-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π App Router - added app insights telemetry for app components (#3151)
* π Added app insights telemetry for app components * π¨ Cleaned up linting errors * removed fallback text from suspense boundary * π Fixed screen rendering blank while query params resolve * β»οΈ Removed unnecessary suspense boundary * β‘ Removed unnecessary suspense boundary from app router layout component * β‘ Added telemetry provider to template.tsx * π¨ Fixed useReportWebVitals being called conditionally * π¨ Removed unused imports from layout.tsx * Added template to layout properly * π Fixed TelemetryProvider not receiving appInsights from context provider * π¨ Removed unused import * Adding web vitals as client component * cleaning up redundant components * handling undefined for appInsight * Fixing rewards URL * removing console log * Adding ISR * Adding placeholder for the countdown * Removing unused MenuData variable * removing unused import * Wrapping web vitals with AppInsight --------- Co-authored-by: Calinator444 <[email protected]> Co-authored-by: Aman Kumar [SSW] <[email protected]>
- Loading branch information
1 parent
f014828
commit a03d292
Showing
5 changed files
with
49 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use client"; | ||
|
||
import { useAppInsightsContext } from "@microsoft/applicationinsights-react-js"; | ||
import { usePathname } from "next/navigation"; | ||
import { useReportWebVitals } from "next/web-vitals"; | ||
|
||
export const WebVitals = () => { | ||
const appInsights = useAppInsightsContext(); | ||
const pathname = usePathname(); | ||
|
||
useReportWebVitals((metric) => { | ||
switch (metric.name) { | ||
case "TTFB": | ||
case "FCP": | ||
case "LCP": | ||
case "FID": | ||
case "CLS": | ||
case "INP": | ||
appInsights?.trackMetric( | ||
{ name: metric.name, average: metric.value }, | ||
{ page: `${pathname}` } | ||
); | ||
break; | ||
} | ||
}); | ||
return <></>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters