Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

Commit

Permalink
Fix analytcs reference
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa committed Aug 17, 2018
1 parent 90fb8ad commit 894ce5b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export default (code, Router, { localhost = "localhost" } = {}) => Page => {
// check if it should track
const shouldNotTrack = isLocal(localhost) || isDev();
// check if it should use production or dev analytics
const analytics = shouldNotTrack ? devLytics : prodLytics;
this.analytics = shouldNotTrack ? devLytics : prodLytics;

// init analytics
analytics.init(code);
this.analytics.init(code);
// log page
analytics.pageview();
this.analytics.pageview();

// save possible previously defined callback
const previousCallback = Router.onRouteChangeComplete
Expand All @@ -31,12 +31,12 @@ export default (code, Router, { localhost = "localhost" } = {}) => Page => {
previousCallback();
}
// log page
analytics.pageview();
this.analytics.pageview();
}
}

render() {
return createElement(Page, { ...this.props, analytics });
return createElement(Page, { ...this.props, analytics: this.analytics });
}
}

Expand Down

0 comments on commit 894ce5b

Please sign in to comment.