Répare le tracking des changements de page

pull/301/head
Johan Girod 2018-08-23 15:38:29 +02:00
parent 6977650add
commit 0623c15d66
6 changed files with 20 additions and 15 deletions

View File

@ -46,7 +46,7 @@ let initialStore = {
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
if (process.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker
.register('/sw.js')

View File

@ -13,10 +13,7 @@ export default class Piwik {
this.options = options
if (
this.options.url === undefined ||
this.options.siteId === undefined
) {
if (this.options.url === undefined || this.options.siteId === undefined) {
throw new Error(
'PiwikTracker cannot be initialized! SiteId and url are mandatory.'
)

View File

@ -0,0 +1,12 @@
import withTracker from 'Components/utils/withTracker'
import { Component } from 'react'
@withTracker
export default class TrackPageView extends Component {
componentDidMount() {
this.props.tracker.push(['trackPageView'])
}
render() {
return null
}
}

View File

@ -1,6 +1,6 @@
import Mecanisms from 'Components/Mecanisms'
import RulePage from 'Components/RulePage'
import withTracker from 'Components/utils/withTracker'
import TrackPageView from 'Components/utils/TrackPageView'
import React, { Component } from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'
import 'Ui/index.css'
@ -15,14 +15,12 @@ import Integration from './pages/Integration'
import IntegrationTest from './pages/IntegrationTest'
import Route404 from './pages/Route404'
import RulesList from './pages/RulesList'
@withTracker
class EmbaucheRoute extends Component {
componentDidMount() {
this.props.tracker.push(['trackPageView'])
}
render() {
return (
<Provider basename="embauche">
<TrackPageView/>
<Header />
<Switch>
<Route exact path="/" component={Home} />

View File

@ -1,6 +1,5 @@
import React from 'react'
import { render } from 'react-dom'
import App from './App'
let anchor = document.querySelector('#js')
render(<App />, anchor)

View File

@ -1,9 +1,9 @@
import withTracker from 'Components/utils/withTracker'
import TrackPageView from 'Components/utils/TrackPageView'
import React, { Component } from 'react'
import { Route, Switch } from 'react-router-dom'
import 'Ui/index.css'
import './App.css'
import Provider from '../../Provider'
import './App.css'
import Landing from './Landing'
import CreateMyCompany from './pages/Company'
import Footer from './pages/Footer/Footer'
@ -11,17 +11,16 @@ import StepsHeader from './pages/Header/StepsHeader'
import HiringProcess from './pages/HiringProcess'
import SocialSecurity from './pages/SocialSecurity'
@withTracker
class InFranceRoute extends Component {
componentDidMount() {
if (typeof sessionStorage !== 'undefined') {
sessionStorage['lang'] = 'en'
}
this.props.tracker.push(['trackPageView'])
}
render() {
return (
<Provider basename="infrance" language="en">
<TrackPageView />
<div id="content">
<Switch>
<Route exact path="/" component={Landing} />