Skip to content

Commit ba01599

Browse files
Mohammed EmadMohammed Emad
authored andcommitted
fix(formbricks): correct error logging in onSetup handling
- Replaced unsafe error?.message access with String(error) to satisfy TS union types - Ensured onSetup only runs when setup succeeds - Improved error logging to preserve details and removed redundant catch
1 parent 8e18a5e commit ba01599

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/react-native/src/components/formbricks.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,22 @@ export function Formbricks({
2222
useEffect(() => {
2323
const setupFormbricks = async (): Promise<void> => {
2424
try {
25-
await setup({
25+
const result = await setup({
2626
environmentId,
2727
appUrl,
2828
});
2929

30-
onSetup?.();
31-
} catch {
32-
logger.debug("Initialization failed");
30+
if (result.ok) {
31+
onSetup?.();
32+
} else {
33+
logger.error(`Initialization failed: ${String(result.error)}`);
34+
}
35+
} catch (err) {
36+
logger.error(
37+
`Initialization threw: ${
38+
err instanceof Error ? err?.message : String(err)
39+
}`
40+
);
3341
}
3442
};
3543

0 commit comments

Comments
 (0)