2
0
Files
bot/packages/scripts/getUsage.ts
Baptiste Arnaud b301174106 🩹 Surround logs saving in a try catch block
It seems that in some particular set up the logs saving is failing.
2023-10-23 14:47:44 +02:00

31 lines
675 B
TypeScript

import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
const getUsage = async () => {
await promptAndSetEnvironment()
const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})
prisma.$on('query', (e) => {
console.log(e.query)
console.log(e.params)
console.log(e.duration, 'ms')
})
const count = await prisma.result.count({
where: {
typebot: { workspaceId: '' },
hasStarted: true,
createdAt: {
gte: '2023-09-18T00:00:00.000Z',
lt: '2023-10-18T00:00:00.000Z',
},
},
})
console.log(count)
}
getUsage()