Skip to content

Commit

Permalink
fix(telemtery): dispatch thunk actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcMcIntosh committed Dec 11, 2024
1 parent 352b4c4 commit 6349fcc
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/app/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,6 @@ startListening({

// Telemetry
startListening({
// actionCreator: chatAskQuestionThunk.rejected,
// matcher: chatAskQuestionThunk.rejected.match,
matcher: isAnyOf(
chatAskQuestionThunk.rejected.match,
chatAskQuestionThunk.fulfilled.match,
Expand All @@ -283,11 +281,13 @@ startListening({
: state.chat.thread;
const scope = `sendChat_${thread.model}_${mode}`;

telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
const thunk = telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
scope,
success: false,
error_message: action.error.message ?? JSON.stringify(action.error),
});

void listenerApi.dispatch(thunk);
}

if (chatAskQuestionThunk.fulfilled.match(action)) {
Expand All @@ -297,32 +297,39 @@ startListening({
? state.chat.cache[chatId]
: state.chat.thread;
const scope = `sendChat_${thread.model}_${mode}`;
telemetryApi.endpoints.sendTelemetryChatEvent.initiate({

const thunk = telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
scope,
success: true,
error_message: "",
});

void listenerApi.dispatch(thunk);
}

if (diffApi.endpoints.patchSingleFileFromTicket.matchFulfilled(action)) {
const success = !action.payload.results.every(
(result) => result.already_applied,
);
telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
const thunk = telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
scope: "handleShow",
success: success,
error_message: success
? ""
: "Already applied, no significant changes generated.",
});

void listenerApi.dispatch(thunk);
}

if (diffApi.endpoints.patchSingleFileFromTicket.matchRejected(action)) {
telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
const thunk = telemetryApi.endpoints.sendTelemetryChatEvent.initiate({
scope: "handleShow",
success: false,
error_message: action.error.message ?? JSON.stringify(action.error),
});

void listenerApi.dispatch(thunk);
}
},
});

0 comments on commit 6349fcc

Please sign in to comment.