Update analytics calls in app.vue
This commit is contained in:
parent
61f4df427e
commit
fbfc3bfb56
|
@ -1,5 +1,5 @@
|
||||||
<!--
|
<!--
|
||||||
Copyright 2020 DigitalOcean
|
Copyright 2021 DigitalOcean
|
||||||
|
|
||||||
This code is licensed under the MIT License.
|
This code is licensed under the MIT License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
@ -125,7 +125,6 @@ THE SOFTWARE.
|
||||||
import isObject from '../util/is_object';
|
import isObject from '../util/is_object';
|
||||||
import analytics from '../util/analytics';
|
import analytics from '../util/analytics';
|
||||||
import browserLanguage from '../util/browser_language';
|
import browserLanguage from '../util/browser_language';
|
||||||
import { toSep } from '../util/language_pack_name';
|
|
||||||
import { defaultPack } from '../util/language_pack_default';
|
import { defaultPack } from '../util/language_pack_default';
|
||||||
import { availablePacks } from '../util/language_pack_context';
|
import { availablePacks } from '../util/language_pack_context';
|
||||||
|
|
||||||
|
@ -174,6 +173,7 @@ THE SOFTWARE.
|
||||||
confFilesOutput: {},
|
confFilesOutput: {},
|
||||||
languageLoading: false,
|
languageLoading: false,
|
||||||
languagePrevious: defaultPack,
|
languagePrevious: defaultPack,
|
||||||
|
interactiveEvents: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -214,8 +214,12 @@ THE SOFTWARE.
|
||||||
},
|
},
|
||||||
'$data.global.app.lang': {
|
'$data.global.app.lang': {
|
||||||
handler(data) {
|
handler(data) {
|
||||||
|
// Lock out the dropdown
|
||||||
this.$data.languageLoading = true;
|
this.$data.languageLoading = true;
|
||||||
|
|
||||||
|
// Store if we should fire the event when this is done loading
|
||||||
|
const interactive = this.$data.interactiveEvents;
|
||||||
|
|
||||||
// Ensure valid pack
|
// Ensure valid pack
|
||||||
if (!availablePacks.includes(data.value)) data.computed = data.default;
|
if (!availablePacks.includes(data.value)) data.computed = data.default;
|
||||||
|
|
||||||
|
@ -227,7 +231,7 @@ THE SOFTWARE.
|
||||||
this.$data.languageLoading = false;
|
this.$data.languageLoading = false;
|
||||||
|
|
||||||
// Analytics
|
// Analytics
|
||||||
analytics(`set_language_${toSep(data.computed, '_')}`, 'Language');
|
this.languageSetEvent(!interactive);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
// Error
|
// Error
|
||||||
console.log('Failed to set language to', data.computed);
|
console.log('Failed to set language to', data.computed);
|
||||||
|
@ -255,8 +259,10 @@ THE SOFTWARE.
|
||||||
if (language) this.lang = language;
|
if (language) this.lang = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send an initial GA event for column mode
|
// Initial analytics events
|
||||||
this.splitColumnEvent(true);
|
this.splitColumnEvent(true);
|
||||||
|
for (let i = 0; i < this.activeDomains.length; i++) this.addSiteEvent(i + 1, true);
|
||||||
|
this.$data.interactiveEvents = true;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changes(index) {
|
changes(index) {
|
||||||
|
@ -285,15 +291,15 @@ THE SOFTWARE.
|
||||||
this.$data.domains.push(data);
|
this.$data.domains.push(data);
|
||||||
this.$data.active = this.$data.domains.length - 1;
|
this.$data.active = this.$data.domains.length - 1;
|
||||||
|
|
||||||
// GA
|
// Analytics
|
||||||
analytics('add_site', 'Sites', undefined, this.activeDomains.length);
|
this.addSiteEvent(this.activeDomains.length);
|
||||||
},
|
},
|
||||||
remove(index) {
|
remove(index) {
|
||||||
this.$set(this.$data.domains, index, null);
|
this.$set(this.$data.domains, index, null);
|
||||||
if (this.$data.active === index) this.$data.active = this.$data.domains.findIndex(d => d !== null);
|
if (this.$data.active === index) this.$data.active = this.$data.domains.findIndex(d => d !== null);
|
||||||
|
|
||||||
// GA
|
// Analytics
|
||||||
analytics('remove_site', 'Sites', undefined, this.activeDomains.length);
|
this.removeSiteEvent(this.activeDomains.length);
|
||||||
},
|
},
|
||||||
checkChange(oldConf) {
|
checkChange(oldConf) {
|
||||||
// If nothing has changed for a tick, we can use the config files
|
// If nothing has changed for a tick, we can use the config files
|
||||||
|
@ -351,7 +357,35 @@ THE SOFTWARE.
|
||||||
this.splitColumnEvent();
|
this.splitColumnEvent();
|
||||||
},
|
},
|
||||||
splitColumnEvent(nonInteraction = false) {
|
splitColumnEvent(nonInteraction = false) {
|
||||||
analytics('toggle_split_column', 'Button', undefined, Number(this.$data.splitColumn), nonInteraction);
|
analytics({
|
||||||
|
category: 'Split column',
|
||||||
|
action: this.$data.splitColumn ? 'Enabled' : 'Disabled',
|
||||||
|
nonInteraction,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
languageSetEvent(nonInteraction = false) {
|
||||||
|
analytics({
|
||||||
|
category: 'Language',
|
||||||
|
action: 'Set',
|
||||||
|
label: this.$data.global.app.lang.computed,
|
||||||
|
nonInteraction,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addSiteEvent(count, nonInteraction = false) {
|
||||||
|
analytics({
|
||||||
|
category: 'Site',
|
||||||
|
action: 'Added',
|
||||||
|
value: count,
|
||||||
|
nonInteraction,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
removeSiteEvent(count, nonInteraction = false) {
|
||||||
|
analytics({
|
||||||
|
category: 'Site',
|
||||||
|
action: 'Removed',
|
||||||
|
value: count,
|
||||||
|
nonInteraction,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
getPrismComponent(confName) {
|
getPrismComponent(confName) {
|
||||||
switch (confName) {
|
switch (confName) {
|
||||||
|
|
Loading…
Reference in New Issue