Created
July 3, 2017 04:30
-
-
Save UberMouse/bc96f43c9aa0953a465867812a412fdc to your computer and use it in GitHub Desktop.
Tracking React Router navigation events with Raygun4JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { withRouter } from 'react-router' | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.props.history.listen((location, action) => { | |
window.rg4js('trackEvent', { type: 'pageView', path: location.pathname }); | |
}); | |
} | |
render() { | |
return ( | |
<Route exact path="/" Component={...} /> | |
<Route exact path="/Home" Component={...} /> | |
); | |
} | |
} | |
export default withRouter(App); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AppContainer from './AppContainer'; | |
import { BrowserRouter, Route } from 'react-router-dom'; | |
ReactDOM.render( | |
<BrowserRouter> | |
<App /> | |
</BrowserRouter>, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment