Skip to content
代码片段 群组 项目
未验证 提交 bb95dec6 编辑于 作者: Alejandro Rodríguez's avatar Alejandro Rodríguez
浏览文件

Switch Duo Chat feedback event sending to the backend

上级 c05b7ea7
无相关合并请求
...@@ -172,17 +172,6 @@ export default { ...@@ -172,17 +172,6 @@ export default {
this.helpCenterState.showTanukiBotChatDrawer = true; this.helpCenterState.showTanukiBotChatDrawer = true;
}, },
onTrackFeedback({ feedbackChoices, didWhat, improveWhat, message } = {}) { 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) { if (message) {
const { id, requestId, extras, role, content } = message; const { id, requestId, extras, role, content } = message;
this.$apollo this.$apollo
...@@ -191,6 +180,17 @@ export default { ...@@ -191,6 +180,17 @@ export default {
variables: { variables: {
input: { input: {
aiMessageId: id, 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',
},
},
}, },
}, },
}) })
......
...@@ -285,37 +285,6 @@ describe('GitLab Duo Chat', () => { ...@@ -285,37 +285,6 @@ describe('GitLab Duo Chat', () => {
}); });
describe('@track-feedback', () => { 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 () => { it('calls the feedback GraphQL mutation when message is passed', async () => {
createComponent(); createComponent();
findGlDuoChat().vm.$emit('track-feedback', feedbackData); findGlDuoChat().vm.$emit('track-feedback', feedbackData);
...@@ -324,6 +293,17 @@ describe('GitLab Duo Chat', () => { ...@@ -324,6 +293,17 @@ describe('GitLab Duo Chat', () => {
expect(duoUserFeedbackMutationHandlerMock).toHaveBeenCalledWith({ expect(duoUserFeedbackMutationHandlerMock).toHaveBeenCalledWith({
input: { input: {
aiMessageId: feedbackData.message.id, 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',
},
},
}, },
}); });
}); });
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册