🩹 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 { formatLogDetails } from './logs/helpers/formatLogDetails'
|
||||||
import { createSession } from './queries/createSession'
|
import { createSession } from './queries/createSession'
|
||||||
import { deleteSession } from './queries/deleteSession'
|
import { deleteSession } from './queries/deleteSession'
|
||||||
|
import * as Sentry from '@sentry/nextjs'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
session: Pick<ChatSession, 'state'> & { id?: string }
|
session: Pick<ChatSession, 'state'> & { id?: string }
|
||||||
@ -53,6 +54,7 @@ export const saveStateToDatabase = async ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (logs && logs.length > 0)
|
if (logs && logs.length > 0)
|
||||||
|
try {
|
||||||
await saveLogs(
|
await saveLogs(
|
||||||
logs.map((log) => ({
|
logs.map((log) => ({
|
||||||
...log,
|
...log,
|
||||||
@ -60,6 +62,10 @@ export const saveStateToDatabase = async ({
|
|||||||
details: formatLogDetails(log.details),
|
details: formatLogDetails(log.details),
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to save logs', e)
|
||||||
|
Sentry.captureException(e)
|
||||||
|
}
|
||||||
|
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ const getUsage = async () => {
|
|||||||
hasStarted: true,
|
hasStarted: true,
|
||||||
createdAt: {
|
createdAt: {
|
||||||
gte: '2023-09-18T00:00:00.000Z',
|
gte: '2023-09-18T00:00:00.000Z',
|
||||||
|
lt: '2023-10-18T00:00:00.000Z',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user