Analytics for global reset/remove

pull/159/head
MattIPv4 2020-07-14 16:41:55 +01:00
parent da9fddac06
commit a9cb3e54f6
2 changed files with 51 additions and 26 deletions

View File

@ -151,6 +151,7 @@ THE SOFTWARE.
import delegatedFromDefaults from '../../util/delegated_from_defaults'; import delegatedFromDefaults from '../../util/delegated_from_defaults';
import computedFromDefaults from '../../util/computed_from_defaults'; import computedFromDefaults from '../../util/computed_from_defaults';
import shareQuery from '../../util/share_query'; import shareQuery from '../../util/share_query';
import analytics from '../../util/analytics';
const defaults = { const defaults = {
modularizedStructure: { modularizedStructure: {
@ -244,6 +245,7 @@ THE SOFTWARE.
'Reset global config', 'Reset global config',
'Are you sure you want to reset all configuration options in the global config section?', 'Are you sure you want to reset all configuration options in the global config section?',
() => { () => {
analytics('reset_global', 'Reset');
Object.values(this.$parent.$props.data).forEach(category => { Object.values(this.$parent.$props.data).forEach(category => {
Object.values(category).forEach(property => { Object.values(category).forEach(property => {
property.value = property.default; property.value = property.default;
@ -261,7 +263,10 @@ THE SOFTWARE.
this.confirm( this.confirm(
'Reset domain config', 'Reset domain config',
`Are you sure you want to reset all configuration options for the ${domain.server.domain.computed} domain?`, `Are you sure you want to reset all configuration options for the ${domain.server.domain.computed} domain?`,
() => this.doResetDomain(domain), () => {
analytics('reset_domain', 'Reset', domain.server.domain.computed);
this.doResetDomain(domain);
},
); );
}, },
removeDomain(index) { removeDomain(index) {
@ -272,7 +277,16 @@ THE SOFTWARE.
this.confirm( this.confirm(
'Remove domain', 'Remove domain',
`Are you sure you want to remove the ${domain.server.domain.computed} domain configuration?`, `Are you sure you want to remove the ${domain.server.domain.computed} domain configuration?`,
() => this.doRemoveDomain(index), () => {
analytics(
'remove_domain',
'Remove',
domain.server.domain.computed,
this.$parent.$parent.activeDomains.length - 1,
);
this.doRemoveDomain(index);
},
); );
}, },
resetDomains() { resetDomains() {
@ -280,6 +294,13 @@ THE SOFTWARE.
'Reset all domain configs', 'Reset all domain configs',
'Are you sure you want to reset the configuration of ALL domains?', 'Are you sure you want to reset the configuration of ALL domains?',
() => { () => {
analytics(
'reset_all',
'Reset',
this.$parent.$parent.activeDomains.map(x => x[0].server.domain.computed).join(','),
this.$parent.$parent.activeDomains.length,
);
for (let i = 0; i < this.$parent.$parent.$data.domains.length; i++) { for (let i = 0; i < this.$parent.$parent.$data.domains.length; i++) {
this.doResetDomain(this.$parent.$parent.$data.domains[i]); this.doResetDomain(this.$parent.$parent.$data.domains[i]);
} }
@ -291,6 +312,13 @@ THE SOFTWARE.
'Remove all domains', 'Remove all domains',
'Are you sure you want to remove ALL domain configurations?', 'Are you sure you want to remove ALL domain configurations?',
() => { () => {
analytics(
'remove_all',
'Remove',
this.$parent.$parent.activeDomains.map(x => x[0].server.domain.computed).join(','),
this.$parent.$parent.activeDomains.length,
);
for (let i = 0; i < this.$parent.$parent.$data.domains.length; i++) { for (let i = 0; i < this.$parent.$parent.$data.domains.length; i++) {
this.doRemoveDomain(i); this.doRemoveDomain(i);
} }

View File

@ -25,30 +25,27 @@ THE SOFTWARE.
*/ */
export default (action, category, label, value) => { export default (action, category, label, value) => {
console.log({ try {
eventCategory: category, // gtag.js
eventAction: action, if (window.gtag) {
eventLabel: label, return window.gtag('event', action, {
eventValue: value, event_category: category,
}); event_label: label,
value,
});
}
// gtag.js // analytics.js
if (window.gtag) { if (window.ga) {
return window.gtag('event', action, { return window.ga('send', {
event_category: category, hitType: 'event',
event_label: label, eventCategory: category,
value, eventAction: action,
}); eventLabel: label,
} eventValue: value,
});
// analytics.js }
if (window.ga) { } catch (_) {
return window.ga('send', { // If analytics fail, don't block anything else
hitType: 'event',
eventCategory: category,
eventAction: action,
eventLabel: label,
eventValue: value,
});
} }
}; };