Skip to content

Commit 5f655cd

Browse files
authored
Add more logs to the slack integration (#1000)
1 parent 582d73c commit 5f655cd

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.changeset/sharp-windows-grin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/integration-slack': patch
3+
---
4+
5+
Add more logs to the slack integration

integrations/slack/src/actions/queryAskAI.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export async function queryAskAI({
165165
const { environment, api } = context;
166166

167167
const askText = `_Asking: ${stripMarkdown(text)}_`;
168-
logger.info(`${{ channelId, teamId, threadId }} -> ${askText}`);
168+
logger.info(`${askText} (channelId: ${channelId}, teamId: ${teamId}, userId: ${userId})`);
169169

170170
const { client, installation } = await getInstallationApiClient(api, teamId);
171171
if (!installation) {
@@ -216,6 +216,8 @@ export async function queryAskAI({
216216
throw new Error('Answer is not in markdown format');
217217
}
218218

219+
logger.debug(`Answer has ${answer.answer.markdown.length} characters`);
220+
219221
const answerText = capitalizeFirstLetter(answer.answer.markdown);
220222

221223
const relatedSources = await getRelatedSources({

integrations/slack/src/slack.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export async function slackAPI<Result>(
143143
});
144144

145145
if (!response.ok) {
146-
logger.error(`slack returned an error ${response.status}: ${response.statusText}`);
146+
logger.error(`API error ${response.status}: ${response.statusText}`);
147147
throw new Error(`${response.status} ${response.statusText}`);
148148
}
149149

@@ -177,6 +177,7 @@ export async function slackAPI<Result>(
177177
}
178178
}
179179

180+
logger.error(`Result error: ${result.error}`);
180181
throw new Error(`${request.method} ${url.toString()}: ${result.error}`);
181182
}
182183

0 commit comments

Comments
 (0)