react-code-dataset / wp-calypso /client /performance-profiler /hooks /use-report-track-events-effect.ts
react-code-dataset / wp-calypso /client /performance-profiler /hooks /use-report-track-events-effect.ts
Download wp-calypso/client/performance-profiler/hooks/use-report-track-events-effect.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 699 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/performance-profiler/hooks/use-report-track-events-effect.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/performance-profiler/hooks/use-report-track-events-effect.ts
-
curl -L -o use-report-track-events-effect.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/performance-profiler/hooks/use-report-track-events-effect.ts
699 Bytes
| import { useEffect } from 'react'; | |
| import { recordTracksEvent } from 'calypso/lib/analytics/tracks'; | |
| import { profilerVersion } from 'calypso/performance-profiler/utils/profiler-version'; | |
| export const useReportCompletedEffect = ( url: string, hash: string ) => { | |
| useEffect( () => { | |
| if ( performance.getEntriesByName( 'test-started' ).length > 0 ) { | |
| performance.mark( 'test-completed' ); | |
| const testMeasure = performance.measure( 'test-duration', 'test-started', 'test-completed' ); | |
| recordTracksEvent( 'calypso_performance_profiler_test_completed', { | |
| url, | |
| hash, | |
| duration: testMeasure?.duration ?? undefined, | |
| version: profilerVersion(), | |
| } ); | |
| } | |
| }, [ url, hash ] ); | |
| }; | |