🩹 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:
@ -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
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ const getUsage = async () => {
|
||||
hasStarted: true,
|
||||
createdAt: {
|
||||
gte: '2023-09-18T00:00:00.000Z',
|
||||
lt: '2023-10-18T00:00:00.000Z',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user