From 9637c80dd79fb08c5eda2a203769c144f5156d2a Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Mon, 30 Mar 2026 20:15:46 +0200 Subject: [PATCH] Add Sentry error handling --- web/components/optional-profile-form.tsx | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/web/components/optional-profile-form.tsx b/web/components/optional-profile-form.tsx index b1201fe4..c85e5e5a 100644 --- a/web/components/optional-profile-form.tsx +++ b/web/components/optional-profile-form.tsx @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/node' import {Editor} from '@tiptap/react' import clsx from 'clsx' import { @@ -96,13 +97,12 @@ export const OptionalProfileUserForm = (props: { return } setIsExtracting(true) + const isInputUrl = isUrl(llmContent) + const payload = { + locale, + ...(isInputUrl ? {url: urlize(llmContent).trim()} : {content: llmContent.trim()}), + } try { - const isInputUrl = isUrl(llmContent) - const payload = { - locale, - ...(isInputUrl ? {url: urlize(llmContent).trim()} : {content: llmContent.trim()}), - } - const extracted = await api('llm-extract-profile', payload) for (const data of Object.entries(removeNullOrUndefinedProps(extracted))) { const key = data[0] @@ -148,7 +148,17 @@ export const OptionalProfileUserForm = (props: { ) } catch (error) { console.error(error) - toast.error(t('profile.llm.extract.error', 'Failed to extract profile data')) + toast.error( + t( + 'profile.llm.extract.error', + 'Failed to extract profile data. Try again later or contact support.', + ), + ) + Sentry.captureException(error, { + user, // shows in the User section + // contexts: {'Error Info': {}}, // only strings as values (not nested objects) + extra: {payload}, // for the rest (nested, etc.) + }) } finally { setIsExtracting(false) }