Analytics (#582)
* gtm > ga * Record pageviews in SPA * Remove home-rolled tracking in favor of autotrack * cleanup
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
// @flow
|
||||
import ScrollToTop from './ScrollToTop';
|
||||
export default ScrollToTop;
|
||||
20
app/index.js
20
app/index.js
@@ -1,5 +1,5 @@
|
||||
// @flow
|
||||
import React from 'react';
|
||||
import * as React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { Provider } from 'mobx-react';
|
||||
import {
|
||||
@@ -49,7 +49,7 @@ const RedirectDocument = ({ match }: { match: Object }) => (
|
||||
globalStyles();
|
||||
|
||||
render(
|
||||
<div style={{ display: 'flex', flex: 1, height: '100%' }}>
|
||||
<React.Fragment>
|
||||
<ErrorBoundary>
|
||||
<Provider {...stores}>
|
||||
<Router>
|
||||
@@ -120,6 +120,20 @@ render(
|
||||
</Provider>
|
||||
</ErrorBoundary>
|
||||
{DevTools && <DevTools position={{ bottom: 0, right: 0 }} />}
|
||||
</div>,
|
||||
</React.Fragment>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
// installation does not use Google Analytics, or tracking is blocked on client
|
||||
// no point loading the rest of the analytics bundles
|
||||
if (!process.env.GOOGLE_ANALYTICS_ID || !window.ga) return;
|
||||
|
||||
await import('autotrack/lib/plugins/outbound-link-tracker');
|
||||
await import('autotrack/lib/plugins/url-change-tracker');
|
||||
|
||||
window.ga('create', process.env.GOOGLE_ANALYTICS_ID, 'auto');
|
||||
window.ga('require', 'outboundLinkTracker');
|
||||
window.ga('require', 'urlChangeTracker');
|
||||
window.ga('send', 'pageview');
|
||||
});
|
||||
|
||||
@@ -113,6 +113,7 @@ class DocumentScene extends Component {
|
||||
|
||||
if (document) {
|
||||
this.props.ui.setActiveDocument(document);
|
||||
|
||||
// Cache data if user enters edit mode and cancels
|
||||
this.editCache = document.text;
|
||||
if (!this.isEditing) document.view();
|
||||
|
||||
Reference in New Issue
Block a user