fix: 🐛 Misc
This commit is contained in:
@ -142,11 +142,11 @@ export const executeWebhook =
|
|||||||
...basicAuth,
|
...basicAuth,
|
||||||
json:
|
json:
|
||||||
contentType !== 'x-www-form-urlencoded' && body
|
contentType !== 'x-www-form-urlencoded' && body
|
||||||
? JSON.parse(parseVariables(variables)(body))
|
? safeJsonParse(parseVariables(variables)(body))
|
||||||
: undefined,
|
: undefined,
|
||||||
form:
|
form:
|
||||||
contentType === 'x-www-form-urlencoded' && body
|
contentType === 'x-www-form-urlencoded' && body
|
||||||
? JSON.parse(parseVariables(variables)(body))
|
? safeJsonParse(parseVariables(variables)(body))
|
||||||
: undefined,
|
: undefined,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -240,4 +240,12 @@ const convertKeyValueTableToObject = (
|
|||||||
}, {})
|
}, {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const safeJsonParse = (json: string): any => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(json)
|
||||||
|
} catch (err) {
|
||||||
|
return json
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default withSentry(handler)
|
export default withSentry(handler)
|
||||||
|
@ -37,7 +37,7 @@ const saveLog = (
|
|||||||
message: string,
|
message: string,
|
||||||
details?: any
|
details?: any
|
||||||
) => {
|
) => {
|
||||||
if (!resultId) return
|
if (!resultId || resultId === 'undefined') return
|
||||||
return prisma.log.create({
|
return prisma.log.create({
|
||||||
data: {
|
data: {
|
||||||
resultId,
|
resultId,
|
||||||
|
@ -105,7 +105,7 @@ const getSampleValue = (step: InputStep) => {
|
|||||||
case InputStepType.CHOICE:
|
case InputStepType.CHOICE:
|
||||||
return step.options.isMultipleChoice
|
return step.options.isMultipleChoice
|
||||||
? step.items.map((i) => i.content).join(', ')
|
? step.items.map((i) => i.content).join(', ')
|
||||||
: step.items[0].content ?? 'Item'
|
: step.items[0]?.content ?? 'Item'
|
||||||
case InputStepType.DATE:
|
case InputStepType.DATE:
|
||||||
return new Date().toUTCString()
|
return new Date().toUTCString()
|
||||||
case InputStepType.EMAIL:
|
case InputStepType.EMAIL:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Log, Result } from 'db'
|
import { Result } from 'db'
|
||||||
import { sendRequest } from 'utils'
|
import { sendRequest } from 'utils'
|
||||||
|
|
||||||
export const createResult = async (typebotId: string) => {
|
export const createResult = async (typebotId: string) => {
|
||||||
|
Reference in New Issue
Block a user