2
0

🔊 Improve invalid typebot update detection

This commit is contained in:
Baptiste Arnaud
2023-01-02 14:44:08 +01:00
parent 7c3b432af5
commit ca2c15dbab
2 changed files with 33 additions and 15 deletions

View File

@ -57,7 +57,11 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
}
if (req.method === 'PUT') {
const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body
const parser = typebotSchema.safeParse(data)
const parser = typebotSchema.safeParse({
...data,
updatedAt: new Date(data.updatedAt),
createdAt: new Date(data.createdAt),
})
if ('error' in parser) {
captureEvent({
message: 'Typebot schema validation failed',