Skip to content

Commit

Permalink
[ADD] #38 GA ios setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-Sunho committed Dec 1, 2024
1 parent 0ae566e commit 14b878e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,19 @@ function App(): React.JSX.Element {
};

const logInitialSession = async () => {
const token = await AsyncStorage.getItem('authToken');
try {
await analytics().logEvent('bv_session_start', {
timestamp: new Date().toISOString(),
is_logged_in: isLoggedIn,
is_logged_in: !!token,
});
} catch (error) {
console.error('Analytics error:', error);
}
};

const subscription = AppState.addEventListener('change', async nextAppState => {
const token = await AsyncStorage.getItem('authToken');
try {
const currentState = appStateRef.current;
appStateRef.current = nextAppState;
Expand All @@ -42,7 +44,7 @@ function App(): React.JSX.Element {
sessionStartTimeRef.current = Date.now();
await analytics().logEvent('bv_foreground', {
timestamp: new Date().toISOString(),
is_logged_in: isLoggedIn,
is_logged_in: !!token,
});
}

Expand All @@ -53,7 +55,7 @@ function App(): React.JSX.Element {
await analytics().logEvent('bv_background', {
timestamp: new Date().toISOString(),
session_duration_seconds: sessionDuration,
is_logged_in: isLoggedIn,
is_logged_in: !!token,
});
}
} catch (error) {
Expand Down

0 comments on commit 14b878e

Please sign in to comment.