Rename session event, scope to errors (#4761)

zio/stable
dan 2024-07-09 23:03:59 +01:00 committed by GitHub
parent 7a47656816
commit ce0bf867ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

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

View File

@ -71,12 +71,12 @@ let nextMessageIndex = 0
const MAX_SLICE_LENGTH = 1000 const MAX_SLICE_LENGTH = 1000
// Not gated. // Not gated.
export function addSessionEventLog(did: string, event: AtpSessionEvent) { export function addSessionErrorLog(did: string, event: AtpSessionEvent) {
try { try {
if (!Statsig.initializeCalled() || !Statsig.getStableID()) { if (!Statsig.initializeCalled() || !Statsig.getStableID()) {
return return
} }
Statsig.logEvent('session:event', null, {did, event}) Statsig.logEvent('session:error', null, {did, event})
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} }