2
0

feat(editor): Code step

This commit is contained in:
Baptiste Arnaud
2022-03-07 17:39:57 +01:00
parent b2784f19fd
commit e3e07ddd4d
13 changed files with 239 additions and 16 deletions

View File

@ -21,8 +21,6 @@ import { sendRequest } from 'utils'
import { sendGaEvent } from '../../lib/gtag'
import { parseVariables, parseVariablesInObject } from './variable'
const safeEval = eval
type IntegrationContext = {
apiHost: string
typebotId: string
@ -222,7 +220,9 @@ const executeWebhook = async (
})
step.options.responseVariableMapping.forEach((varMapping) => {
if (!varMapping?.bodyPath || !varMapping.variableId) return
const value = safeEval(`(${JSON.stringify(data)}).${varMapping?.bodyPath}`)
const value = Function(
`return (${JSON.stringify(data)}).${varMapping?.bodyPath}`
)()
updateVariableValue(varMapping.variableId, value)
})
return step.outgoingEdgeId