Download wp-calypso/client/lib/analytics/track-component-view/index.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/track-component-view/index.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/lib/analytics/track-component-view/index.jsx
-
curl -L -o index.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/lib/analytics/track-component-view/index.jsx
1.15 kB
| import debugFactory from 'debug'; | |
| import PropTypes from 'prop-types'; | |
| import { Component } from 'react'; | |
| import { connect } from 'react-redux'; | |
| import { bumpStat, recordTracksEvent } from 'calypso/state/analytics/actions'; | |
| /** | |
| * Module variables | |
| */ | |
| const debug = debugFactory( 'calypso:analytics:TrackComponentView' ); | |
| class TrackComponentView extends Component { | |
| static propTypes = { | |
| eventName: PropTypes.string, | |
| eventProperties: PropTypes.object, | |
| recordTracksEvent: PropTypes.func, | |
| bumpStat: PropTypes.func, | |
| }; | |
| static defaultProps = { | |
| recordTracksEvent: () => {}, | |
| bumpStat: () => {}, | |
| }; | |
| componentDidMount() { | |
| debug( 'Component did mount.' ); | |
| const { eventName, eventProperties } = this.props; | |
| if ( eventName ) { | |
| debug( `Recording Tracks event "${ eventName }".` ); | |
| this.props.recordTracksEvent( eventName, eventProperties ); | |
| } | |
| const { statGroup, statName } = this.props; | |
| if ( statGroup ) { | |
| debug( `Bumping stat "${ statName }".` ); | |
| this.props.bumpStat( statGroup, statName ); | |
| } | |
| } | |
| render() { | |
| return null; | |
| } | |
| } | |
| export default connect( null, { bumpStat, recordTracksEvent } )( TrackComponentView ); | |