Skip to content

Commit

Permalink
fix: 🐛 Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed May 12, 2022
1 parent 9213dd3 commit 092f16d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ export const executeWebhook =
...basicAuth,
json:
contentType !== 'x-www-form-urlencoded' && body
? JSON.parse(parseVariables(variables)(body))
? safeJsonParse(parseVariables(variables)(body))
: undefined,
form:
contentType === 'x-www-form-urlencoded' && body
? JSON.parse(parseVariables(variables)(body))
? safeJsonParse(parseVariables(variables)(body))
: undefined,
}
try {
Expand Down Expand Up @@ -240,4 +240,12 @@ const convertKeyValueTableToObject = (
}, {})
}

const safeJsonParse = (json: string): any => {
try {
return JSON.parse(json)
} catch (err) {
return json
}
}

export default withSentry(handler)
2 changes: 1 addition & 1 deletion apps/viewer/services/api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const saveLog = (
message: string,
details?: any
) => {
if (!resultId) return
if (!resultId || resultId === 'undefined') return
return prisma.log.create({
data: {
resultId,
Expand Down
2 changes: 1 addition & 1 deletion apps/viewer/services/api/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const getSampleValue = (step: InputStep) => {
case InputStepType.CHOICE:
return step.options.isMultipleChoice
? step.items.map((i) => i.content).join(', ')
: step.items[0].content ?? 'Item'
: step.items[0]?.content ?? 'Item'
case InputStepType.DATE:
return new Date().toUTCString()
case InputStepType.EMAIL:
Expand Down
2 changes: 1 addition & 1 deletion apps/viewer/services/result.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Log, Result } from 'db'
import { Result } from 'db'
import { sendRequest } from 'utils'

export const createResult = async (typebotId: string) => {
Expand Down

4 comments on commit 092f16d

@vercel
Copy link

@vercel vercel bot commented on 092f16d May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 092f16d May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 092f16d May 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

Please sign in to comment.