From 61f4df427e60e1e3811f42de29704a5c45517105 Mon Sep 17 00:00:00 2001 From: MattIPv4 Date: Thu, 7 Jan 2021 17:44:14 +0000 Subject: [PATCH 01/17] Refactor analytics.js --- src/nginxconfig/util/analytics.js | 59 +++++++++++-------------------- 1 file changed, 20 insertions(+), 39 deletions(-) diff --git a/src/nginxconfig/util/analytics.js b/src/nginxconfig/util/analytics.js index 86ac225..99182ac 100644 --- a/src/nginxconfig/util/analytics.js +++ b/src/nginxconfig/util/analytics.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2021 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -24,49 +24,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -export default (action, category, label, value, nonInteraction = false) => { +export default ({ category, action, label, value, nonInteraction }) => { + console.info('Analytics event:', { category, action, label, value, nonInteraction }); + try { - const tracker = window.ga.getAll()[0]; - if (tracker) { - tracker.send({ - hitType: 'event', - eventCategory: category, - eventAction: action, - eventLabel: label, - eventValue: value, - nonInteraction, - }); - } + // Google + window.ga('send', 'event', { + eventCategory: category, + eventAction: action, + eventLabel: label, + eventValue: value, + nonInteraction, + }); } catch (_) { // If analytics fail, don't block anything else } - /*try { - // gtag.js - if (window.gtag) { - window.gtag('event', action, { - event_category: category, - event_label: label, - value, - }); - } + try { + // Segment + window.analytics.track(`${category} ${action}`, { + label, + value, + nonInteraction, + }); } catch (_) { // If analytics fail, don't block anything else - }*/ - - /*try { - // analytics.js - if (window.ga) { - window.ga('send', { - hitType: 'event', - eventCategory: category, - eventAction: action, - eventLabel: label, - eventValue: value, - nonInteraction, - }); - } - } catch (_) { - // If analytics fail, don't block anything else - }*/ + } }; From fbfc3bfb563db28643748aa2550395a2b1417914 Mon Sep 17 00:00:00 2001 From: MattIPv4 Date: Thu, 7 Jan 2021 17:45:59 +0000 Subject: [PATCH 02/17] Update analytics calls in app.vue --- src/nginxconfig/templates/app.vue | 52 +++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/src/nginxconfig/templates/app.vue b/src/nginxconfig/templates/app.vue index 76874f1..83acc1d 100644 --- a/src/nginxconfig/templates/app.vue +++ b/src/nginxconfig/templates/app.vue @@ -1,5 +1,5 @@ @@ -42,5 +42,10 @@ THE SOFTWARE. console.info(`Highlighting ${this.$props.cmd}...`); Prism.highlightAllUnder(this.$el); }, + methods: { + copied(event) { + this.$emit('copied', event.detail.text); + }, + }, }; diff --git a/src/nginxconfig/templates/prism/docker.vue b/src/nginxconfig/templates/prism/docker.vue index 96635db..9cbe80e 100644 --- a/src/nginxconfig/templates/prism/docker.vue +++ b/src/nginxconfig/templates/prism/docker.vue @@ -25,7 +25,7 @@ THE SOFTWARE. -->