Skip to content

Commit 27ad2b8

Browse files
authored
Merge pull request #979 from techmatters/CHI-3592-fix_broken_scrubber_error_handling
CHI-3592: Provide correct details in transcript scrubber errors.
2 parents 5f65168 + 5b986ce commit 27ad2b8

File tree

1 file changed

+6
-5
lines changed
  • hrm-domain/scheduled-tasks/transcript-scrubber

1 file changed

+6
-5
lines changed

hrm-domain/scheduled-tasks/transcript-scrubber/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const waitForPrivateAiToBeReady = async () => {
4545
if (Date.now() > timeoutTime) {
4646
throw new Error('Private AI did not start in time');
4747
}
48-
console.log(
48+
console.debug(
4949
`Waiting for ${Math.round(
5050
(Date.now() - timeoutTime) / 1000,
5151
)} more seconds for Private AI to be ready...`,
@@ -71,7 +71,7 @@ const scrubS3Transcript = async (bucket: string, key: string) => {
7171
}),
7272
});
7373
const responsePayload = await response.json();
74-
console.log('Response from PrivateAI:', response.status);
74+
console.debug('Response from PrivateAI:', response.status);
7575
const results = responsePayload as { processed_text: string }[];
7676
const scrubbedKey = key.replace('transcripts', 'scrubbed-transcripts');
7777
const scrubbedMessages = transcript.messages.map((m, idx) => ({
@@ -93,7 +93,7 @@ const scrubS3Transcript = async (bucket: string, key: string) => {
9393
};
9494

9595
const pollQueue = async (): Promise<boolean> => {
96-
console.log('Polling queue', PENDING_TRANSCRIPT_SQS_QUEUE_URL);
96+
console.info('Polling queue', PENDING_TRANSCRIPT_SQS_QUEUE_URL);
9797
const messagesPayload = await receiveSqsMessage({
9898
queueUrl: PENDING_TRANSCRIPT_SQS_QUEUE_URL,
9999
});
@@ -135,7 +135,7 @@ const pollQueue = async (): Promise<boolean> => {
135135
attemptResult: ContactJobAttemptResult.SUCCESS,
136136
}),
137137
});
138-
console.log(
138+
console.info(
139139
`Successfully scrubbed transcript: ${key}, scrubbed version at ${scrubbedKey}${key}, jobId: ${jobId} (attempt ${attemptNumber}), contact ${accountSid}/${contactId}`,
140140
);
141141
} catch (error) {
@@ -144,6 +144,7 @@ const pollQueue = async (): Promise<boolean> => {
144144
await sendSqsMessage({
145145
queueUrl: COMPLETED_TRANSCRIPT_SQS_QUEUE_URL,
146146
message: JSON.stringify({
147+
...parsedPendingMessage,
147148
attemptPayload: errorMessage,
148149
attemptResult: ContactJobAttemptResult.FAILURE,
149150
}),
@@ -168,7 +169,7 @@ export const executeTask = async () => {
168169
break;
169170
}
170171
}
171-
console.log(`Processed ${processedMessages} messages this run`);
172+
console.info(`Processed ${processedMessages} messages this run`);
172173
};
173174

174175
executeTask().catch(console.error);

0 commit comments

Comments
 (0)