Scale back sentry logs for trivial events (#2997)

* scale back sentry logs

* update migrate log tests
zio/stable
Hailey 2024-02-26 20:19:06 -08:00 committed by GitHub
parent 1a34921661
commit c8582924e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 24 additions and 24 deletions

View File

@ -104,18 +104,18 @@ export async function post(agent: BskyAgent, opts: PostOpts) {
// add image embed if present
if (opts.images?.length) {
logger.info(`Uploading images`, {
logger.debug(`Uploading images`, {
count: opts.images.length,
})
const images: AppBskyEmbedImages.Image[] = []
for (const image of opts.images) {
opts.onStateChange?.(`Uploading image #${images.length + 1}...`)
logger.info(`Compressing image`)
logger.debug(`Compressing image`)
await image.compress()
const path = image.compressed?.path ?? image.path
const {width, height} = image.compressed || image
logger.info(`Uploading image`)
logger.debug(`Uploading image`)
const res = await uploadBlob(agent, path, 'image/jpeg')
images.push({
image: res.data.blob,

View File

@ -232,7 +232,7 @@ export function reducer(
})
if (s.activeStep !== state.activeStep) {
logger.info(`onboarding: step changed`, {activeStep: state.activeStep})
logger.debug(`onboarding: step changed`, {activeStep: state.activeStep})
}
return state

View File

@ -26,7 +26,7 @@ test('migrate: fresh install', async () => {
expect(AsyncStorage.getItem).toHaveBeenCalledWith('root')
expect(read).toHaveBeenCalledTimes(1)
expect(logger.info).toHaveBeenCalledWith(
expect(logger.debug).toHaveBeenCalledWith(
'persisted state: no migration needed',
)
})
@ -38,7 +38,7 @@ test('migrate: fresh install, existing new storage', async () => {
expect(AsyncStorage.getItem).toHaveBeenCalledWith('root')
expect(read).toHaveBeenCalledTimes(1)
expect(logger.info).toHaveBeenCalledWith(
expect(logger.debug).toHaveBeenCalledWith(
'persisted state: no migration needed',
)
})
@ -68,7 +68,7 @@ test('migrate: has legacy data', async () => {
await migrate()
expect(write).toHaveBeenCalledWith(transform(fixtures.LEGACY_DATA_DUMP))
expect(logger.info).toHaveBeenCalledWith(
expect(logger.debug).toHaveBeenCalledWith(
'persisted state: migrated legacy storage',
)
})

View File

@ -19,7 +19,7 @@ const _emitter = new EventEmitter()
* the Provider.
*/
export async function init() {
logger.info('persisted state: initializing')
logger.debug('persisted state: initializing')
broadcast.onmessage = onBroadcastMessage
@ -27,11 +27,11 @@ export async function init() {
await migrate() // migrate old store
const stored = await store.read() // check for new store
if (!stored) {
logger.info('persisted state: initializing default storage')
logger.debug('persisted state: initializing default storage')
await store.write(defaults) // opt: init new store
}
_state = stored || defaults // return new store
logger.log('persisted state: initialized')
logger.debug('persisted state: initialized')
} catch (e) {
logger.error('persisted state: failed to load root state from storage', {
message: e,

View File

@ -121,7 +121,7 @@ export function transform(legacy: Partial<LegacySchema>): Schema {
* local storage AND old storage exists.
*/
export async function migrate() {
logger.info('persisted state: check need to migrate')
logger.debug('persisted state: check need to migrate')
try {
const rawLegacyData = await AsyncStorage.getItem(
@ -131,7 +131,7 @@ export async function migrate() {
const alreadyMigrated = Boolean(newData)
if (!alreadyMigrated && rawLegacyData) {
logger.info('persisted state: migrating legacy storage')
logger.debug('persisted state: migrating legacy storage')
const legacyData = JSON.parse(rawLegacyData)
const newData = transform(legacyData)
@ -139,14 +139,14 @@ export async function migrate() {
if (validate.success) {
await write(newData)
logger.info('persisted state: migrated legacy storage')
logger.debug('persisted state: migrated legacy storage')
} else {
logger.error('persisted state: legacy data failed validation', {
message: validate.error,
})
}
} else {
logger.info('persisted state: no migration needed')
logger.debug('persisted state: no migration needed')
}
} catch (e: any) {
logger.error(e, {

View File

@ -133,7 +133,7 @@ function createPersistSessionHandler(
accessJwt: session?.accessJwt,
}
logger.info(`session: persistSession`, {
logger.debug(`session: persistSession`, {
event,
deactivated: refreshedAccount.deactivated,
})
@ -320,7 +320,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
)
const logout = React.useCallback<ApiContext['logout']>(async () => {
logger.info(`session: logout`)
logger.debug(`session: logout`)
clearCurrentAccount()
setStateAndPersist(s => {
return {
@ -374,7 +374,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
}
if (canReusePrevSession) {
logger.info(`session: attempting to reuse previous session`)
logger.debug(`session: attempting to reuse previous session`)
agent.session = prevSession
__globalAgent = agent
@ -384,7 +384,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
if (prevSession.deactivated) {
// don't attempt to resume
// use will be taken to the deactivated screen
logger.info(`session: reusing session for deactivated account`)
logger.debug(`session: reusing session for deactivated account`)
return
}
@ -410,7 +410,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
__globalAgent = PUBLIC_BSKY_AGENT
})
} else {
logger.info(`session: attempting to resume using previous session`)
logger.debug(`session: attempting to resume using previous session`)
try {
const freshAccount = await resumeSessionWithFreshAccount()
@ -431,7 +431,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
}
async function resumeSessionWithFreshAccount(): Promise<SessionAccount> {
logger.info(`session: resumeSessionWithFreshAccount`)
logger.debug(`session: resumeSessionWithFreshAccount`)
await networkRetry(1, () => agent.resumeSession(prevSession))
@ -552,11 +552,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
return persisted.onUpdate(() => {
const session = persisted.get('session')
logger.info(`session: persisted onUpdate`, {})
logger.debug(`session: persisted onUpdate`, {})
if (session.currentAccount && session.currentAccount.refreshJwt) {
if (session.currentAccount?.did !== state.currentAccount?.did) {
logger.info(`session: persisted onUpdate, switching accounts`, {
logger.debug(`session: persisted onUpdate, switching accounts`, {
from: {
did: state.currentAccount?.did,
handle: state.currentAccount?.handle,
@ -569,7 +569,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
initSession(session.currentAccount)
} else {
logger.info(`session: persisted onUpdate, updating session`, {})
logger.debug(`session: persisted onUpdate, updating session`, {})
/*
* Use updated session in this tab's agent. Do not call

View File

@ -107,7 +107,7 @@ export const LoginForm = ({
const errMsg = e.toString()
setIsProcessing(false)
if (errMsg.includes('Authentication Required')) {
logger.info('Failed to login due to invalid credentials', {
logger.debug('Failed to login due to invalid credentials', {
error: errMsg,
})
setError(_(msg`Invalid username or password`))