2
0

fix: 🐛 Tiny bugs (Sentry)

This commit is contained in:
Baptiste Arnaud
2022-02-25 18:30:14 +01:00
parent d21b1722b5
commit 9e08ff574b
8 changed files with 38 additions and 26 deletions

View File

@@ -31,7 +31,7 @@ export const TypebotPage = ({
}, [])
const initializeResult = async (variables: VariableWithValue[]) => {
const resultIdFromSession = sessionStorage.getItem(sessionStorageKey)
const resultIdFromSession = getExistingResultFromSession()
if (resultIdFromSession) setResultId(resultIdFromSession)
else {
const { error, data: result } = await createResult(
@@ -41,7 +41,7 @@ export const TypebotPage = ({
if (error) setError(error)
if (result) {
setResultId(result.id)
sessionStorage.setItem(sessionStorageKey, result.id)
setResultInSession(result.id)
}
}
}
@@ -79,3 +79,15 @@ export const TypebotPage = ({
</div>
)
}
const getExistingResultFromSession = () => {
try {
return sessionStorage.getItem(sessionStorageKey)
} catch {}
}
const setResultInSession = (resultId: string) => {
try {
return sessionStorage.setItem(sessionStorageKey, resultId)
} catch {}
}

View File

@@ -1,5 +1,5 @@
import { NextApiRequest, NextApiResponse } from 'next'
import { initMiddleware, methodNotAllowed } from 'utils'
import { badRequest, initMiddleware, methodNotAllowed } from 'utils'
import { GoogleSpreadsheet } from 'google-spreadsheet'
import { getAuthenticatedGoogleClient } from 'libs/google-sheets'
import { Cell } from 'models'
@@ -17,7 +17,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
column: req.query['referenceCell[column]'],
value: req.query['referenceCell[value]'],
} as Cell
const extractingColumns = req.query.columns as string[]
const extractingColumns = req.query.columns as string[] | undefined
if (!Array.isArray(extractingColumns)) return badRequest(res)
const doc = new GoogleSpreadsheet(spreadsheetId)
doc.useOAuth2Client(await getAuthenticatedGoogleClient(credentialsId))
await doc.loadInfo()