Skip to content

Commit 67b0728

Browse files
committed
Wrap lifecycle init in try-catch to prevent SDK init failure
A transient AsyncStorage write failure in lifecycle tracking (e.g., storage full, permission error) would reject the init() promise and leave the SDK uninitialized with no-op methods for the entire session. Lifecycle tracking is non-critical — it should not block the core analytics SDK from functioning. https://claude.ai/code/session_0117WwRELH1nzVbxRj7Kmm5N
1 parent d0c2623 commit 67b0728

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/FormoAnalytics.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,14 @@ export class FormoAnalytics implements IFormoAnalytics {
129129
const analytics = new FormoAnalytics(writeKey, options);
130130

131131
// Initialize lifecycle tracking if enabled
132+
// Wrapped in try-catch so a transient storage failure doesn't prevent SDK init
132133
if (analytics.isAutocaptureEnabled("lifecycle")) {
133-
analytics.lifecycleManager = new AppLifecycleManager(analytics);
134-
await analytics.lifecycleManager.start(options?.app);
134+
try {
135+
analytics.lifecycleManager = new AppLifecycleManager(analytics);
136+
await analytics.lifecycleManager.start(options?.app);
137+
} catch (error) {
138+
logger.error("FormoAnalytics: Failed to initialize lifecycle tracking", error);
139+
}
135140
}
136141

137142
// Call ready callback

0 commit comments

Comments
 (0)