Send page event when new route is rendered.

This commit is contained in:
Douglas Hall
2019-03-15 16:36:59 -04:00
parent 189c3db630
commit 07ca42421c
3 changed files with 7 additions and 13 deletions

View File

@@ -37,7 +37,6 @@ function logEvent(eventType, eventData) {
});
}
function identifyUser() {
const authState = apiClient.getAuthenticationState();
if (authState.authentication && authState.authentication.userId) {
@@ -46,5 +45,9 @@ function identifyUser() {
}
}
function sendPageEvent() {
identifyUser();
window.analytics.page();
}
export { handleTrackEvents, identifyUser, logEvent };
export { handleTrackEvents, identifyUser, logEvent, sendPageEvent };

View File

@@ -85,11 +85,4 @@ import { configuration } from '../config/environment';
// load the tools you've enabled for your account. Boosh!
analytics.load(configuration.SEGMENT_KEY);
// TODO: Move this page call when we have multiple pages.
// - during routing.
// Make the first page call to load the integrations. If
// you'd like to manually name or tag the page, edit or
// move this call however you'd like.
analytics.page();
})();

View File

@@ -5,7 +5,7 @@ import ReactDOM from 'react-dom';
import configureStore from './config/configureStore';
import apiClient from './config/apiClient';
import { identifyUser } from './analytics/analytics';
import { sendPageEvent } from './analytics/analytics';
import './index.scss';
@@ -16,7 +16,5 @@ if (apiClient.ensurePublicOrAuthencationAndCookies(window.location.pathname)) {
ReactDOM.render(<App store={store} history={history} />, document.getElementById('root'));
// identify user for future analytics calls
// TODO: Call before each page call.
identifyUser();
sendPageEvent();
}