MCPcopy Create free account
hub / github.com/DavidWells/analytics / App

Class App

examples/preact/src/app.js:24–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24export default class App extends Component {
25
26 componentDidMount() {
27 analytics.on('pageEnd', ({ payload }) => {
28 console.log('pageView fired from analytics', payload.properties)
29 })
30 }
31 /** Gets fired when the route changes.
32 * @param {Object} event "change" event from [preact-router](http://git.io/preact-router)
33 * @param {string} event.url The newly routed URL
34 */
35 handleRoute = e => {
36 this.currentUrl = e.url
37 this.previousUrl = e.previous
38 if (inBrowser) {
39 analytics.page()
40 }
41 };
42
43 render() {
44 return (
45 <div id="app">
46 <Header />
47 <Router onChange={this.handleRoute}>
48 <Home path='/' />
49 <About path='/about' />
50 <Login path="/login" />
51
52 <PrivateRoute
53 path="/dashboard"
54 component={() => <Dashboard />}
55 />
56 <PrivateRoute
57 path="/dashboard/:id"
58 component={(p) => <DashboardItem {...p} />}
59 />
60 <PrivateRoute
61 path="/dashboard/profile"
62 component={() => <Profile user="me" />}
63 />
64
65 <NotFound type="404" default />
66 </Router>
67 </div>
68 )
69 }
70}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected