Analytics: track generic events through the server (#12735)

* Loggly-only user support events (#12676)

* feat(analytics): Loggly-only user support events

* fix(analytics): clean up more Unknowns

* wip: allow tracking events from the server

* analytics: allow tracking generic events on the server

* remove console.logs

* remove console.log (client)

* add integration test

Co-authored-by: Sabe Jones <sabrecat@gmail.com>
This commit is contained in:
Matteo Pagliazzi
2020-10-28 22:39:19 +01:00
committed by GitHub
parent b15462596b
commit 48dbe547c0
16 changed files with 120 additions and 17 deletions

View File

@@ -82,14 +82,21 @@ export function setUser () {
window.ga('set', { userId: user._id });
}
export function track (properties) {
export function track (properties, options = {}) {
// Use nextTick to avoid blocking the UI
Vue.nextTick(() => {
if (_doesNotHaveRequiredFields(properties)) return;
if (_doesNotHaveAllowedHitType(properties)) return;
amplitude.getInstance().logEvent(properties.eventAction, properties);
window.ga('send', properties);
const trackOnServer = options && options.trackOnServer === true;
if (trackOnServer === true) {
// Track an event on the server
const store = getStore();
store.dispatch('analytics:trackEvent', properties);
} else {
amplitude.getInstance().logEvent(properties.eventAction, properties);
window.ga('send', properties);
}
});
}