From abfdf0a8ea35af7e75425f633ea5a00334de452f Mon Sep 17 00:00:00 2001 From: Enrique Alcantara Date: Tue, 30 Apr 2019 16:24:40 -0400 Subject: Track clicks on uninstall app button --- .../uninstall_application_confirmation_modal.vue | 13 ++++++++++--- .../clusters/mixins/track_uninstall_button_click.js | 5 +++++ .../uninstall_application_confirmation_modal_spec.js | 15 ++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 app/assets/javascripts/clusters/mixins/track_uninstall_button_click.js diff --git a/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue b/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue index 2134e9b6bb7..6b1b532134d 100644 --- a/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue +++ b/app/assets/javascripts/clusters/components/uninstall_application_confirmation_modal.vue @@ -2,6 +2,7 @@ import { GlModal } from '@gitlab/ui'; import { sprintf, s__ } from '~/locale'; import { INGRESS, CERT_MANAGER, PROMETHEUS, RUNNER, KNATIVE, JUPYTER } from '../constants'; +import trackUninstallButtonClick from 'ee_else_ce/clusters/mixins/track_uninstall_button_click'; const CUSTOM_APP_WARNING_TEXT = { [INGRESS]: s__( @@ -20,6 +21,7 @@ export default { components: { GlModal, }, + mixins: [trackUninstallButtonClick], props: { application: { type: String, @@ -54,6 +56,12 @@ export default { return `uninstall-${this.application}`; }, }, + methods: { + confirmUninstall() { + this.trackUninstallApplicationClick(this.application); + this.$emit('confirm'); + }, + }, }; diff --git a/app/assets/javascripts/clusters/mixins/track_uninstall_button_click.js b/app/assets/javascripts/clusters/mixins/track_uninstall_button_click.js new file mode 100644 index 00000000000..a5a4813ea74 --- /dev/null +++ b/app/assets/javascripts/clusters/mixins/track_uninstall_button_click.js @@ -0,0 +1,5 @@ +export default { + methods: { + trackUninstallApplicationClick: () => {}, + }, +}; diff --git a/spec/frontend/clusters/components/uninstall_application_confirmation_modal_spec.js b/spec/frontend/clusters/components/uninstall_application_confirmation_modal_spec.js index 6a7126b45cd..fbba1b925d9 100644 --- a/spec/frontend/clusters/components/uninstall_application_confirmation_modal_spec.js +++ b/spec/frontend/clusters/components/uninstall_application_confirmation_modal_spec.js @@ -29,10 +29,19 @@ describe('UninstallApplicationConfirmationModal', () => { expect(wrapper.find(GlModal).attributes('ok-title')).toEqual(`Uninstall ${appTitle}`); }); - it('triggers confirm event when ok button is clicked', () => { - wrapper.find(GlModal).vm.$emit('ok'); + describe('when ok button is clicked', () => { + beforeEach(() => { + jest.spyOn(wrapper.vm, 'trackUninstallApplicationClick'); + wrapper.find(GlModal).vm.$emit('ok'); + }); + + it('triggers confirm event when ok button is clicked', () => { + expect(wrapper.emitted('confirm')).toBeTruthy(); + }); - expect(wrapper.emitted('confirm')).toBeTruthy(); + it('tracks event using stats package', () => { + expect(wrapper.vm.trackUninstallApplicationClick).toHaveBeenCalledWith(INGRESS); + }); }); it('displays a warning text indicating the app will be uninstalled', () => { -- cgit v1.2.1