Commit 9a2d78c 1 parent 81a19a6 commit 9a2d78c Copy full SHA for 9a2d78c
File tree 1 file changed +9
-6
lines changed
1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,21 @@ const getEventValueFromMetric = (metric: Metric) => {
30
30
}
31
31
return Math . round ( metric . value )
32
32
}
33
-
33
+
34
34
const reportHandler = ( metric : Metric ) => {
35
- ReactGA . event ( {
35
+ const event = {
36
36
category : 'Web Vitals' ,
37
37
action : metric . name ,
38
38
value : getEventValueFromMetric ( metric ) ,
39
39
label : metric . id ,
40
40
nonInteraction : true
41
- } )
41
+ }
42
+
43
+ if ( process . env . NODE_ENV && process . env . NODE_ENV === 'development' ) {
44
+ console . log ( `[web-vitals-dev] ${ metric . name } : ${ metric . id } ` , metric ) // eslint-disable-line no-console
45
+ } else {
46
+ ReactGA . event ( event )
47
+ }
42
48
}
43
49
44
- // If you want to start measuring performance in your app, pass a function
45
- // to log results (for example: reportWebVitals(console.log))
46
- // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
47
50
reportWebVitals ( reportHandler )
You can’t perform that action at this time.
0 commit comments