This commit is contained in:
Jamie Brunton committed 2025-12-31 09:43:10 +00:00
1 parent dfcf0ba289
commit 71667d6104
3 files changed
+22 -3

No files matched your search

+1
View File
@@ -159,6 +159,7 @@ export default function OnboardingScreen() {
console.log('[Onboarding] Profile updated successfully, fetching user...'); console.log('[Onboarding] Profile updated successfully, fetching user...');
await fetchUser(); await fetchUser();
console.log('[Onboarding] User fetched, navigating to home...'); console.log('[Onboarding] User fetched, navigating to home...');
Events.profileUpdated(["name", "gender", "usage_reason", "show_explicit_content"]);
Events.onboardingComplete(); Events.onboardingComplete();
router.replace('/'); router.replace('/');
} catch (err: any) { } catch (err: any) {
+2
View File
@@ -121,6 +121,7 @@ export default function ProfileScreen() {
// Refresh user data and packs to reflect the change // Refresh user data and packs to reflect the change
await fetchUser(); await fetchUser();
await fetchPacks(); await fetchPacks();
Events.profileUpdated(["show_explicit_content"]);
} catch (error) { } catch (error) {
// Revert on error // Revert on error
setShowExplicit(!value); setShowExplicit(!value);
@@ -174,6 +175,7 @@ export default function ProfileScreen() {
await fetchUser(); await fetchUser();
setIsEditingName(false); setIsEditingName(false);
Events.profileUpdated(["name"]);
} catch (error) { } catch (error) {
Alert.alert("Error", "Failed to update name. Please try again."); Alert.alert("Error", "Failed to update name. Please try again.");
setNewName(user.name || ""); setNewName(user.name || "");
+19 -3
View File
@@ -6,9 +6,12 @@ import { initSentry, setUserContext, clearUserContext } from "../src/lib/sentry"
initSentry(); initSentry();
// Initialize Analytics // Initialize Analytics
import { initAnalytics, setUserId, clearUserId, logScreenView } from "../src/lib/analytics"; import { initAnalytics, setUserId, clearUserId, logScreenView, Events } from "../src/lib/analytics";
initAnalytics(); initAnalytics();
// Track cold start immediately
Events.appOpened("cold");
// Import push notification utilities // Import push notification utilities
import { import {
clearPushToken, clearPushToken,
@@ -17,8 +20,8 @@ import {
handleNotificationResponse, handleNotificationResponse,
} from "../src/lib/notifications"; } from "../src/lib/notifications";
import React, { useEffect } from "react"; import React, { useEffect, useRef } from "react";
import { Platform, View } from "react-native"; import { Platform, View, AppState, AppStateStatus } from "react-native";
// Suppress useLayoutEffect warning on server-side rendering // Suppress useLayoutEffect warning on server-side rendering
if (Platform.OS === "web" && typeof window === "undefined") { if (Platform.OS === "web" && typeof window === "undefined") {
@@ -50,6 +53,7 @@ const queryClient = new QueryClient();
export default function RootLayout() { export default function RootLayout() {
const { fetchUser, setUser } = useAuthStore(); const { fetchUser, setUser } = useAuthStore();
const pathname = usePathname(); const pathname = usePathname();
const appState = useRef(AppState.currentState);
// Track screen views // Track screen views
useEffect(() => { useEffect(() => {
@@ -58,6 +62,18 @@ export default function RootLayout() {
} }
}, [pathname]); }, [pathname]);
// Track warm starts when app comes back from background
useEffect(() => {
const subscription = AppState.addEventListener("change", (nextAppState: AppStateStatus) => {
if (appState.current.match(/inactive|background/) && nextAppState === "active") {
Events.appOpened("warm");
}
appState.current = nextAppState;
});
return () => subscription.remove();
}, []);
useEffect(() => { useEffect(() => {
// Fetch user on mount // Fetch user on mount
fetchUser(); fetchUser();