2
0

🩹 Surround logs saving in a try catch block

It seems that in some particular set up the logs saving is failing.
This commit is contained in:
Baptiste Arnaud
2023-10-23 14:47:44 +02:00
parent 11186d8d29
commit b301174106
2 changed files with 14 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import { updateSession } from './queries/updateSession'
import { formatLogDetails } from './logs/helpers/formatLogDetails'
import { createSession } from './queries/createSession'
import { deleteSession } from './queries/deleteSession'
import * as Sentry from '@sentry/nextjs'
type Props = {
session: Pick<ChatSession, 'state'> & { id?: string }
@ -53,13 +54,18 @@ export const saveStateToDatabase = async ({
})
if (logs && logs.length > 0)
await saveLogs(
logs.map((log) => ({
...log,
resultId,
details: formatLogDetails(log.details),
}))
)
try {
await saveLogs(
logs.map((log) => ({
...log,
resultId,
details: formatLogDetails(log.details),
}))
)
} catch (e) {
console.error('Failed to save logs', e)
Sentry.captureException(e)
}
return session
}

View File

@ -19,6 +19,7 @@ const getUsage = async () => {
hasStarted: true,
createdAt: {
gte: '2023-09-18T00:00:00.000Z',
lt: '2023-10-18T00:00:00.000Z',
},
},
})