mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Move more analytics to server (#12782)
* track events on the client by default, remove unused ones * fix lint, remove some calls to updateUser * remove dead code from guide.js
This commit is contained in:
@@ -232,7 +232,7 @@ export default {
|
||||
eventCategory: 'drop-cap-reached',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Drop Cap Reached > Modal > Wiki',
|
||||
}, { trackOnServer: true });
|
||||
});
|
||||
},
|
||||
toLearnMore () {
|
||||
Analytics.track({
|
||||
@@ -240,7 +240,7 @@ export default {
|
||||
eventCategory: 'drop-cap-reached',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Drop Cap Reached > Modal > Subscriptions',
|
||||
}, { trackOnServer: true });
|
||||
});
|
||||
|
||||
this.close();
|
||||
this.$router.push('/user/settings/subscription');
|
||||
|
||||
@@ -622,13 +622,6 @@ export default {
|
||||
await this.$store.dispatch('guilds:join', { groupId: this.group._id, type: 'guild' });
|
||||
},
|
||||
clickLeave () {
|
||||
Analytics.track({
|
||||
hitType: 'event',
|
||||
eventCategory: 'button',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Leave Party',
|
||||
});
|
||||
|
||||
// @TODO: Get challenges and ask to keep or remove
|
||||
if (!window.confirm('Are you sure you want to leave?')) return; // eslint-disable-line no-alert
|
||||
const keep = true;
|
||||
|
||||
@@ -36,7 +36,7 @@ export default {
|
||||
eventCategory: 'drop-cap-reached',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Drop Cap Reached > Notification Click',
|
||||
}, { trackOnServer: true });
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ export default {
|
||||
eventCategory: 'button',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'User Dropdown > Subscriptions',
|
||||
}, { trackOnServer: true });
|
||||
});
|
||||
|
||||
this.$router.push({ name: 'subscription' });
|
||||
},
|
||||
|
||||
@@ -386,7 +386,6 @@ import size from 'lodash/size';
|
||||
import reduce from 'lodash/reduce';
|
||||
import moment from 'moment';
|
||||
|
||||
import * as Analytics from '@/libs/analytics';
|
||||
import spellsMixin from '@/mixins/spells';
|
||||
import planGemLimits from '@/../../common/script/libs/planGemLimits';
|
||||
import numberInvalid from '@/mixins/numberInvalid';
|
||||
@@ -611,14 +610,6 @@ export default {
|
||||
}
|
||||
},
|
||||
purchaseGems () {
|
||||
if (this.item.key === 'rebirth_orb') {
|
||||
Analytics.track({
|
||||
hitType: 'event',
|
||||
eventCategory: 'button',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Gems > Rebirth',
|
||||
});
|
||||
}
|
||||
this.$root.$emit('bv::show::modal', 'buy-gems');
|
||||
},
|
||||
togglePinned () {
|
||||
|
||||
@@ -286,13 +286,13 @@ export default {
|
||||
}
|
||||
|
||||
// @TODO duplicate of code in home.vue
|
||||
|
||||
Analytics.track({
|
||||
hitType: 'event',
|
||||
eventCategory: 'button',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Play',
|
||||
});
|
||||
|
||||
this.$router.push('/register');
|
||||
},
|
||||
scrollToMobileApp () {
|
||||
|
||||
@@ -897,13 +897,6 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
Analytics.track({
|
||||
hitType: 'pageview',
|
||||
eventCategory: 'page',
|
||||
eventAction: 'landing page',
|
||||
page: '/static/home',
|
||||
});
|
||||
|
||||
hello.init({
|
||||
facebook: process.env.FACEBOOK_KEY, // eslint-disable-line
|
||||
// windows: WINDOWS_CLIENT_ID,
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import * as Analytics from '@/libs/analytics';
|
||||
import { mapState } from '@/libs/store';
|
||||
import scoreTask from '@/mixins/scoreTask';
|
||||
import Task from './task';
|
||||
@@ -181,8 +180,6 @@ export default {
|
||||
|
||||
this.isLoading = false;
|
||||
this.$root.$emit('bv::hide::modal', 'yesterdaily');
|
||||
|
||||
Analytics.updateUser();
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -88,14 +88,14 @@ export function track (properties, options = {}) {
|
||||
if (_doesNotHaveRequiredFields(properties)) return;
|
||||
if (_doesNotHaveAllowedHitType(properties)) return;
|
||||
|
||||
const trackOnServer = options && options.trackOnServer === true;
|
||||
if (trackOnServer === true) {
|
||||
// Track an event on the server
|
||||
const store = getStore();
|
||||
store.dispatch('analytics:trackEvent', properties);
|
||||
} else {
|
||||
const trackOnClient = options && options.trackOnClient === true;
|
||||
// Track events on the server by default
|
||||
if (trackOnClient === true) {
|
||||
amplitude.getInstance().logEvent(properties.eventAction, properties);
|
||||
window.ga('send', properties);
|
||||
} else {
|
||||
const store = getStore();
|
||||
store.dispatch('analytics:trackEvent', properties);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -143,12 +143,6 @@ export default {
|
||||
|
||||
return null;
|
||||
},
|
||||
hoyo (user) {
|
||||
// @TODO: What is was the timeout for?
|
||||
// @TODO move to analytics
|
||||
window.amplitude.setUserId(user._id);
|
||||
window.ga('set', { userId: user._id });
|
||||
},
|
||||
goto (chapter, page, force) {
|
||||
if (chapter === 'intro' && this.user.flags.welcomed !== true) {
|
||||
// @TODO: Add dispatch User.set({'flags.welcomed': true});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import Vue from 'vue';
|
||||
|
||||
import * as Analytics from '@/libs/analytics';
|
||||
import notifications from './notifications';
|
||||
import scoreTask from '@/../../common/script/ops/scoreTask';
|
||||
import { mapState } from '@/libs/store';
|
||||
@@ -64,7 +63,6 @@ export default {
|
||||
|
||||
this.playTaskScoreSound(task, direction);
|
||||
|
||||
Analytics.updateUser();
|
||||
const response = await this.$store.dispatch('tasks:score', {
|
||||
taskId: task._id,
|
||||
direction,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
import getStore from '@/store';
|
||||
import * as Analytics from '@/libs/analytics';
|
||||
import handleRedirect from './handleRedirect';
|
||||
|
||||
import ParentPage from '@/components/parentPage';
|
||||
@@ -412,13 +411,6 @@ router.beforeEach((to, from, next) => {
|
||||
});
|
||||
}
|
||||
|
||||
Analytics.track({
|
||||
hitType: 'pageview',
|
||||
eventCategory: 'navigation',
|
||||
eventAction: 'navigate',
|
||||
page: to.name || to.path,
|
||||
});
|
||||
|
||||
if ((to.name === 'userProfile' || to.name === 'userProfilePage') && from.name !== null) {
|
||||
let startingPage = 'profile';
|
||||
if (to.params.startingPage !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user