Download wp-calypso/client/dashboard/app/analytics/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 698 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/dashboard/app/analytics/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/dashboard/app/analytics/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/dashboard/app/analytics/index.tsx
698 Bytes
| import { createContext, useContext } from 'react'; | |
| export type AnalyticsClient = { | |
| recordTracksEvent: ( eventName: string, properties?: Record< string, unknown > ) => void; | |
| recordPageView: ( url: string, title: string ) => void; | |
| }; | |
| const AnalyticsContext = createContext< AnalyticsClient >( { | |
| recordTracksEvent() {}, | |
| recordPageView() {}, | |
| } ); | |
| interface AnalyticsProviderProps { | |
| children: React.ReactNode; | |
| client: AnalyticsClient; | |
| } | |
| export function AnalyticsProvider( { children, client }: AnalyticsProviderProps ) { | |
| return <AnalyticsContext.Provider value={ client }>{ children }</AnalyticsContext.Provider>; | |
| } | |
| export function useAnalytics() { | |
| return useContext( AnalyticsContext ); | |
| } | |