Merge branch 'session-event-twk' into session-stress

This commit is contained in:
Dan Abramov
2024-07-09 22:56:28 +01:00
2 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -12,7 +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 {addSessionErrorLog} from './logging'
import {
configureModerationForAccount,
configureModerationForGuest,
@@ -195,7 +195,9 @@ async function prepareAgent(
const account = agentToSessionAccountOrThrow(agent)
agent.setPersistSessionHandler(event => {
onSessionChange(agent, account.did, event)
addSessionEventLog(account.did, event)
if (event !== 'create' && event !== 'update') {
addSessionErrorLog(account.did, event)
}
})
return {agent, account}
}
+2 -2
View File
@@ -71,12 +71,12 @@ let nextMessageIndex = 0
const MAX_SLICE_LENGTH = 1000
// Not gated.
export function addSessionEventLog(did: string, event: AtpSessionEvent) {
export function addSessionErrorLog(did: string, event: AtpSessionEvent) {
try {
if (!Statsig.initializeCalled() || !Statsig.getStableID()) {
return
}
Statsig.logEvent('session:event', null, {did, event})
Statsig.logEvent('session:error', null, {did, event})
} catch (e) {
console.error(e)
}