Skip to content

Commit 33c5742

Browse files
committed
Only send analytics data in production mode
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 12a1290 commit 33c5742

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

src/App.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ export default {
4949
},
5050
created: function() {
5151
// send home to google analytics
52-
this.$ga.page('/')
52+
if (process.env.NODE_ENV === 'production') {
53+
this.$ga.page('/')
54+
}
5355
}
5456
}</script>
5557
<style lang="scss">

src/components/HelpSection.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,13 @@ export default {
277277
methods: {
278278
clickHandler(modalNumber) {
279279
this.modals[modalNumber].status = true
280-
this.$ga.event({
281-
eventCategory: 'HelpSection',
282-
eventAction: 'clicked',
283-
eventLabel: this.modals[modalNumber].title
284-
})
280+
if (process.env.NODE_ENV === 'production') {
281+
this.$ga.event({
282+
eventCategory: 'HelpSection',
283+
eventAction: 'clicked',
284+
eventLabel: this.modals[modalNumber].title
285+
})
286+
}
285287
}
286288
}
287289
}

src/components/SelectedLicenseCode.vue

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,23 @@ export default {
7878
methods: {
7979
onCopySuccess(e) {
8080
this.success = true
81-
const fieldsFilled = {}
82-
for (const detail in this.$props.value.attributionDetails) {
83-
fieldsFilled[detail] = this.$props.value.attributionDetails[detail] !== ''
84-
}
85-
const copiedLicense = {
86-
license: this.$props.value.shortName,
87-
// codeType can be either rich-text or html
88-
codeType: this.currentSelection,
89-
fieldsFilled: fieldsFilled
81+
if (process.env.NODE_ENV === 'production') {
82+
const fieldsFilled = {}
83+
for (const detail in this.$props.value.attributionDetails) {
84+
fieldsFilled[detail] = this.$props.value.attributionDetails[detail] !== ''
85+
}
86+
const copiedLicense = {
87+
license: this.$props.value.shortName,
88+
// codeType can be either rich-text or html
89+
codeType: this.currentSelection,
90+
fieldsFilled: fieldsFilled
91+
}
92+
this.$ga.event({
93+
eventCategory: 'Attribution',
94+
eventAction: 'copied',
95+
eventLabel: JSON.stringify(copiedLicense)
96+
})
9097
}
91-
this.$ga.event({
92-
eventCategory: 'Attribution',
93-
eventAction: 'copied',
94-
eventLabel: JSON.stringify(copiedLicense)
95-
})
9698
this.$emit('copied', { content: e.text })
9799
setTimeout(() => {
98100
this.success = false

src/components/SelectedLicenseDropdown.vue

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ export default {
5151
},
5252
set(currentLicense) {
5353
const fullLicenseName = this.fullLicenseName(currentLicense)
54-
this.$ga.event({
55-
eventCategory: 'LicenseDropdown',
56-
eventAction: 'licenseSelected',
57-
eventLabel: currentLicense
58-
})
54+
if (process.env.NODE_ENV === 'production') {
55+
this.$ga.event({
56+
eventCategory: 'LicenseDropdown',
57+
eventAction: 'licenseSelected',
58+
eventLabel: currentLicense
59+
})
60+
}
5961
this.$emit('input', { ...this.$props.value, fullName: fullLicenseName, shortName: currentLicense })
6062
}
6163
}

src/components/Stepper.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default {
121121
if (payload === ndStep && this.$props.value.shortName.includes('ND')) {
122122
this.currentStep = attributionDetailsStep
123123
}
124-
if (this.currentStep === attributionDetailsStep) {
124+
if (this.currentStep === attributionDetailsStep && process.env.NODE_ENV === 'production') {
125125
this.sendSelectedToGa()
126126
}
127127
},

0 commit comments

Comments
 (0)