Download wp-calypso/client/sites/v2/hooks/use-analytics-client.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 630 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/v2/hooks/use-analytics-client.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/v2/hooks/use-analytics-client.ts
-
curl -L -o use-analytics-client.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/v2/hooks/use-analytics-client.ts
630 Bytes
| import { useMemo } from 'react'; | |
| import { useDispatch } from 'calypso/state'; | |
| import { recordTracksEvent, recordPageView } from 'calypso/state/analytics/actions'; | |
| import type { AnalyticsClient } from 'calypso/dashboard/app/analytics'; | |
| export const useAnalyticsClient = () => { | |
| const dispatch = useDispatch(); | |
| const analyticsClient: AnalyticsClient = useMemo( | |
| () => ( { | |
| recordTracksEvent( eventName, properties ) { | |
| dispatch( recordTracksEvent( eventName, properties ) ); | |
| }, | |
| recordPageView( url, title ) { | |
| dispatch( recordPageView( url, title ) ); | |
| }, | |
| } ), | |
| [ dispatch ] | |
| ); | |
| return analyticsClient; | |
| }; | |