diff --git a/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue b/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue index 9619d97628cd968c95cb0a2250576c5d29d8c929..89c6194fb3d4cd4734da1606548386016dfc323b 100644 --- a/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue +++ b/ee/app/assets/javascripts/ai/tanuki_bot/components/app.vue @@ -172,17 +172,6 @@ export default { this.helpCenterState.showTanukiBotChatDrawer = true; }, onTrackFeedback({ feedbackChoices, didWhat, improveWhat, message } = {}) { - this.track(TANUKI_BOT_TRACKING_EVENT_NAME, { - action: 'click_button', - label: 'response_feedback', - property: feedbackChoices, - extra: { - improveWhat, - didWhat, - prompt_location: 'after_content', - }, - }); - if (message) { const { id, requestId, extras, role, content } = message; this.$apollo @@ -191,6 +180,17 @@ export default { variables: { input: { aiMessageId: id, + trackingEvent: { + category: TANUKI_BOT_TRACKING_EVENT_NAME, + action: 'click_button', + label: 'response_feedback', + property: feedbackChoices.join(','), + extra: { + improveWhat, + didWhat, + prompt_location: 'after_content', + }, + }, }, }, }) diff --git a/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js b/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js index e232f2c0a668a4ba60283622c78b352da132c608..577c4952420ac91f466358aee0e8186b1cf49471 100644 --- a/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js +++ b/ee/spec/frontend/ai/tanuki_bot/components/app_spec.js @@ -285,37 +285,6 @@ describe('GitLab Duo Chat', () => { }); describe('@track-feedback', () => { - let trackingSpy; - - beforeEach(() => { - trackingSpy = mockTracking(undefined, wrapper.element, jest.spyOn); - }); - - afterEach(() => { - unmockTracking(); - }); - - it('tracks the snowplow event on successful mutation for chat', async () => { - createComponent(); - findGlDuoChat().vm.$emit('track-feedback', { - feedbackChoices: ['foo', 'bar'], - improveWhat: 'improveWhat', - didWhat: 'didWhat', - }); - - await waitForPromises(); - expect(trackingSpy).toHaveBeenCalledWith(undefined, TANUKI_BOT_TRACKING_EVENT_NAME, { - action: 'click_button', - label: 'response_feedback', - property: ['foo', 'bar'], - extra: { - improveWhat: 'improveWhat', - didWhat: 'didWhat', - prompt_location: 'after_content', - }, - }); - }); - it('calls the feedback GraphQL mutation when message is passed', async () => { createComponent(); findGlDuoChat().vm.$emit('track-feedback', feedbackData); @@ -324,6 +293,17 @@ describe('GitLab Duo Chat', () => { expect(duoUserFeedbackMutationHandlerMock).toHaveBeenCalledWith({ input: { aiMessageId: feedbackData.message.id, + trackingEvent: { + category: TANUKI_BOT_TRACKING_EVENT_NAME, + action: 'click_button', + label: 'response_feedback', + property: 'useful,not_relevant', + extra: { + improveWhat: 'more examples', + didWhat: 'provided clarity', + prompt_location: 'after_content', + }, + }, }, }); });