Skip to content

Commit df17666

Browse files
committed
Simplify tracked events
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent f1786b8 commit df17666

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

src/components/SelectedLicenseCode.vue

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,20 @@ 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
90+
}
8191
this.$ga.event({
8292
eventCategory: 'Attribution',
8393
eventAction: 'copied',
84-
// Label is either rich-text or html
85-
eventLabel: this.currentSelection,
86-
// Value is the license copied
87-
eventValue: this.$props.value.shortName
88-
})
89-
const fieldsFilledIn = []
90-
for (const detail in this.$props.value.attributionDetails) {
91-
if (this.$props.value.attributionDetails[detail] !== '') {
92-
fieldsFilledIn.push(detail)
93-
}
94-
}
95-
fieldsFilledIn.forEach((field) => {
96-
this.$ga.event({
97-
eventCategory: 'AttributionDetails',
98-
eventAction: 'filledIn',
99-
// Label is the field that is not blank when a user copies the license
100-
eventLabel: field
101-
})
94+
eventLabel: JSON.stringify(copiedLicense)
10295
})
10396
this.$emit('copied', { content: e.text })
10497
setTimeout(() => {

src/components/SelectedLicenseDropdown.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export default {
5252
set(currentLicense) {
5353
const fullLicenseName = this.fullLicenseName(currentLicense)
5454
this.$ga.event({
55-
eventCategory: 'licenseDropdown',
56-
eventAction: 'clicked',
57-
eventLabel: 'License selected from the dropdown'
55+
eventCategory: 'LicenseDropdown',
56+
eventAction: 'licenseSelected',
57+
eventLabel: currentLicense
5858
})
5959
this.$emit('input', { ...this.$props.value, fullName: fullLicenseName, shortName: currentLicense })
6060
}

src/components/Stepper.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ export default {
121121
if (payload === ndStep && this.$props.value.shortName.includes('ND')) {
122122
this.currentStep = attributionDetailsStep
123123
}
124+
if (this.currentStep === attributionDetailsStep) {
125+
this.sendSelectedToGa()
126+
}
127+
},
128+
sendSelectedToGa() {
129+
this.$ga.event({
130+
eventCategory: 'Stepper',
131+
eventAction: 'licenseSelected',
132+
eventLabel: this.$props.value.shortName
133+
})
124134
},
125135
getIcon(attrName) {
126136
if (attrName === 'BY') {
@@ -144,12 +154,6 @@ export default {
144154
fullName: this.fullLicenseName(attrs),
145155
attributionDetails: this.$props.value.attributionDetails
146156
}
147-
this.$ga.event({
148-
eventCategory: 'Stepper',
149-
eventAction: 'clicked',
150-
eventLabel: itemId,
151-
eventValue: licenseData.shortName
152-
})
153157
this.$emit('input', licenseData)
154158
},
155159
shortLicenseName(attr) {

0 commit comments

Comments
 (0)