Files
bsky-social-app/src/state/session/logging.ts
T
Samuel Newman e7d349bc30 finish phase 3: type-only codemod and zero non-bridge @atproto/api imports
Task 8: codemod repointed 150 namespace-type files to #/lexicons
(AppBskyFeedDefs.PostView -> app.bsky.feed.defs.PostView, .Record -> .Main)
plus ~105 hand-fixed consumers (composer/video state, DebugMod, Profile,
onboarding, dialogs). DM_SERVICE_HEADERS deleted; last chat call sites on
the chat client. RichText.tsx flipped to SDK-only. Remaining @atproto/api
importers: the three session bridge files, the deliberate dual-world
matcher in lib/xrpc-error.ts, and test fixtures. toLex boundary casts are
TODO(phase4)-tagged for bridge removal.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-30 18:15:22 +03:00

75 lines
1.8 KiB
TypeScript

import {type SessionData} from '@atproto/lex-password-session'
import {type Schema} from '../persisted'
import {type Action, type State} from './reducer'
import {type AtpSessionEvent} from './session-core'
import {type SessionAccount} from './types'
type Reducer = (state: State, action: Action) => State
type Log =
| {
type: 'reducer:init'
state: State
}
| {
type: 'reducer:call'
action: Action
prevState: State
nextState: State
}
| {
type: 'method:start'
method:
| 'createAccount'
| 'login'
| 'logout'
| 'resumeSession'
| 'removeAccount'
account?: SessionAccount
}
| {
type: 'method:end'
method:
| 'createAccount'
| 'login'
| 'logout'
| 'resumeSession'
| 'removeAccount'
account?: SessionAccount
}
| {
type: 'persisted:broadcast'
data: Schema['session']
}
| {
type: 'persisted:receive'
data: Schema['session']
}
| {
type: 'agent:switch'
prevAgent: object
nextAgent: object
}
| {
type: 'agent:patch'
agent: object
prevSession: SessionData | undefined
nextSession: SessionData | undefined
}
export function wrapSessionReducerForLogging(reducer: Reducer): Reducer {
return function loggingWrapper(prevState: State, action: Action): State {
const nextState = reducer(prevState, action)
addSessionDebugLog({type: 'reducer:call', prevState, action, nextState})
return nextState
}
}
/**
* Stubs, previously used to log session errors to Statsig. We may revive this
* using Sentry or Bitdrift in the future.
*/
export function addSessionErrorLog(_did: string, _event: AtpSessionEvent) {}
export function addSessionDebugLog(_log: Log) {}