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 {}
}