Log session events unconditionally (#4758)
parent
2d0eefebc3
commit
7a47656816
|
@ -12,6 +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 {
|
import {
|
||||||
configureModerationForAccount,
|
configureModerationForAccount,
|
||||||
configureModerationForGuest,
|
configureModerationForGuest,
|
||||||
|
@ -194,6 +195,7 @@ 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)
|
||||||
})
|
})
|
||||||
return {agent, account}
|
return {agent, account}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {AtpSessionData} from '@atproto/api'
|
import {AtpSessionData, AtpSessionEvent} from '@atproto/api'
|
||||||
import {sha256} from 'js-sha256'
|
import {sha256} from 'js-sha256'
|
||||||
import {Statsig} from 'statsig-react-native-expo'
|
import {Statsig} from 'statsig-react-native-expo'
|
||||||
|
|
||||||
|
@ -70,6 +70,18 @@ export function wrapSessionReducerForLogging(reducer: Reducer): Reducer {
|
||||||
let nextMessageIndex = 0
|
let nextMessageIndex = 0
|
||||||
const MAX_SLICE_LENGTH = 1000
|
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) {
|
export function addSessionDebugLog(log: Log) {
|
||||||
try {
|
try {
|
||||||
if (!Statsig.initializeCalled() || !Statsig.getStableID()) {
|
if (!Statsig.initializeCalled() || !Statsig.getStableID()) {
|
||||||
|
|
Loading…
Reference in New Issue