Log session events unconditionally (#4758)

zio/stable
dan 2024-07-09 21:13:32 +01:00 committed by GitHub
parent 2d0eefebc3
commit 7a47656816
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import {tryFetchGates} from '#/lib/statsig/statsig'
import {getAge} from '#/lib/strings/time'
import {logger} from '#/logger'
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
import {addSessionEventLog} from './logging'
import {
configureModerationForAccount,
configureModerationForGuest,
@ -194,6 +195,7 @@ async function prepareAgent(
const account = agentToSessionAccountOrThrow(agent)
agent.setPersistSessionHandler(event => {
onSessionChange(agent, account.did, event)
addSessionEventLog(account.did, event)
})
return {agent, account}
}

View File

@ -1,4 +1,4 @@
import {AtpSessionData} from '@atproto/api'
import {AtpSessionData, AtpSessionEvent} from '@atproto/api'
import {sha256} from 'js-sha256'
import {Statsig} from 'statsig-react-native-expo'
@ -70,6 +70,18 @@ export function wrapSessionReducerForLogging(reducer: Reducer): Reducer {
let nextMessageIndex = 0
const MAX_SLICE_LENGTH = 1000
// Not gated.
export function addSessionEventLog(did: string, event: AtpSessionEvent) {
try {
if (!Statsig.initializeCalled() || !Statsig.getStableID()) {
return
}
Statsig.logEvent('session:event', null, {did, event})
} catch (e) {
console.error(e)
}
}
export function addSessionDebugLog(log: Log) {
try {
if (!Statsig.initializeCalled() || !Statsig.getStableID()) {