Merge branch 'main' of github.com:bluesky-social/social-app into main
commit
832d5734b4
|
@ -10,7 +10,9 @@ export type LogEvents = {
|
||||||
logContext: 'SwitchAccount' | 'Settings' | 'Deactivated'
|
logContext: 'SwitchAccount' | 'Settings' | 'Deactivated'
|
||||||
}
|
}
|
||||||
'notifications:openApp': {}
|
'notifications:openApp': {}
|
||||||
'state:background': {}
|
'state:background': {
|
||||||
|
secondsActive: number
|
||||||
|
}
|
||||||
'state:foreground': {}
|
'state:foreground': {}
|
||||||
'feed:endReached': {
|
'feed:endReached': {
|
||||||
feedType: string
|
feedType: string
|
||||||
|
|
|
@ -67,15 +67,24 @@ function toStatsigUser(did: string | undefined) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastState: AppStateStatus = AppState.currentState
|
let lastState: AppStateStatus = AppState.currentState
|
||||||
|
let lastActive = lastState === 'active' ? performance.now() : null
|
||||||
AppState.addEventListener('change', (state: AppStateStatus) => {
|
AppState.addEventListener('change', (state: AppStateStatus) => {
|
||||||
if (state === lastState) {
|
if (state === lastState) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
lastState = state
|
lastState = state
|
||||||
if (state === 'active') {
|
if (state === 'active') {
|
||||||
|
lastActive = performance.now()
|
||||||
logEvent('state:foreground', {})
|
logEvent('state:foreground', {})
|
||||||
} else {
|
} else {
|
||||||
logEvent('state:background', {})
|
let secondsActive = 0
|
||||||
|
if (lastActive != null) {
|
||||||
|
secondsActive = Math.round((performance.now() - lastActive) / 1e3)
|
||||||
|
}
|
||||||
|
lastActive = null
|
||||||
|
logEvent('state:background', {
|
||||||
|
secondsActive,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue