Log session events unconditionally

This commit is contained in:
Dan Abramov
2024-07-09 20:07:37 +01:00
parent 2d0eefebc3
commit 1d8e954eff
2 changed files with 15 additions and 1 deletions
+2
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}
}
+13 -1
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()) {