Scale back sentry logs for trivial events (#2997)
* scale back sentry logs * update migrate log testszio/stable
parent
1a34921661
commit
c8582924e2
|
@ -104,18 +104,18 @@ export async function post(agent: BskyAgent, opts: PostOpts) {
|
||||||
|
|
||||||
// add image embed if present
|
// add image embed if present
|
||||||
if (opts.images?.length) {
|
if (opts.images?.length) {
|
||||||
logger.info(`Uploading images`, {
|
logger.debug(`Uploading images`, {
|
||||||
count: opts.images.length,
|
count: opts.images.length,
|
||||||
})
|
})
|
||||||
|
|
||||||
const images: AppBskyEmbedImages.Image[] = []
|
const images: AppBskyEmbedImages.Image[] = []
|
||||||
for (const image of opts.images) {
|
for (const image of opts.images) {
|
||||||
opts.onStateChange?.(`Uploading image #${images.length + 1}...`)
|
opts.onStateChange?.(`Uploading image #${images.length + 1}...`)
|
||||||
logger.info(`Compressing image`)
|
logger.debug(`Compressing image`)
|
||||||
await image.compress()
|
await image.compress()
|
||||||
const path = image.compressed?.path ?? image.path
|
const path = image.compressed?.path ?? image.path
|
||||||
const {width, height} = image.compressed || image
|
const {width, height} = image.compressed || image
|
||||||
logger.info(`Uploading image`)
|
logger.debug(`Uploading image`)
|
||||||
const res = await uploadBlob(agent, path, 'image/jpeg')
|
const res = await uploadBlob(agent, path, 'image/jpeg')
|
||||||
images.push({
|
images.push({
|
||||||
image: res.data.blob,
|
image: res.data.blob,
|
||||||
|
|
|
@ -232,7 +232,7 @@ export function reducer(
|
||||||
})
|
})
|
||||||
|
|
||||||
if (s.activeStep !== state.activeStep) {
|
if (s.activeStep !== state.activeStep) {
|
||||||
logger.info(`onboarding: step changed`, {activeStep: state.activeStep})
|
logger.debug(`onboarding: step changed`, {activeStep: state.activeStep})
|
||||||
}
|
}
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|
|
@ -26,7 +26,7 @@ test('migrate: fresh install', async () => {
|
||||||
|
|
||||||
expect(AsyncStorage.getItem).toHaveBeenCalledWith('root')
|
expect(AsyncStorage.getItem).toHaveBeenCalledWith('root')
|
||||||
expect(read).toHaveBeenCalledTimes(1)
|
expect(read).toHaveBeenCalledTimes(1)
|
||||||
expect(logger.info).toHaveBeenCalledWith(
|
expect(logger.debug).toHaveBeenCalledWith(
|
||||||
'persisted state: no migration needed',
|
'persisted state: no migration needed',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -38,7 +38,7 @@ test('migrate: fresh install, existing new storage', async () => {
|
||||||
|
|
||||||
expect(AsyncStorage.getItem).toHaveBeenCalledWith('root')
|
expect(AsyncStorage.getItem).toHaveBeenCalledWith('root')
|
||||||
expect(read).toHaveBeenCalledTimes(1)
|
expect(read).toHaveBeenCalledTimes(1)
|
||||||
expect(logger.info).toHaveBeenCalledWith(
|
expect(logger.debug).toHaveBeenCalledWith(
|
||||||
'persisted state: no migration needed',
|
'persisted state: no migration needed',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -68,7 +68,7 @@ test('migrate: has legacy data', async () => {
|
||||||
await migrate()
|
await migrate()
|
||||||
|
|
||||||
expect(write).toHaveBeenCalledWith(transform(fixtures.LEGACY_DATA_DUMP))
|
expect(write).toHaveBeenCalledWith(transform(fixtures.LEGACY_DATA_DUMP))
|
||||||
expect(logger.info).toHaveBeenCalledWith(
|
expect(logger.debug).toHaveBeenCalledWith(
|
||||||
'persisted state: migrated legacy storage',
|
'persisted state: migrated legacy storage',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -19,7 +19,7 @@ const _emitter = new EventEmitter()
|
||||||
* the Provider.
|
* the Provider.
|
||||||
*/
|
*/
|
||||||
export async function init() {
|
export async function init() {
|
||||||
logger.info('persisted state: initializing')
|
logger.debug('persisted state: initializing')
|
||||||
|
|
||||||
broadcast.onmessage = onBroadcastMessage
|
broadcast.onmessage = onBroadcastMessage
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ export async function init() {
|
||||||
await migrate() // migrate old store
|
await migrate() // migrate old store
|
||||||
const stored = await store.read() // check for new store
|
const stored = await store.read() // check for new store
|
||||||
if (!stored) {
|
if (!stored) {
|
||||||
logger.info('persisted state: initializing default storage')
|
logger.debug('persisted state: initializing default storage')
|
||||||
await store.write(defaults) // opt: init new store
|
await store.write(defaults) // opt: init new store
|
||||||
}
|
}
|
||||||
_state = stored || defaults // return new store
|
_state = stored || defaults // return new store
|
||||||
logger.log('persisted state: initialized')
|
logger.debug('persisted state: initialized')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('persisted state: failed to load root state from storage', {
|
logger.error('persisted state: failed to load root state from storage', {
|
||||||
message: e,
|
message: e,
|
||||||
|
|
|
@ -121,7 +121,7 @@ export function transform(legacy: Partial<LegacySchema>): Schema {
|
||||||
* local storage AND old storage exists.
|
* local storage AND old storage exists.
|
||||||
*/
|
*/
|
||||||
export async function migrate() {
|
export async function migrate() {
|
||||||
logger.info('persisted state: check need to migrate')
|
logger.debug('persisted state: check need to migrate')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const rawLegacyData = await AsyncStorage.getItem(
|
const rawLegacyData = await AsyncStorage.getItem(
|
||||||
|
@ -131,7 +131,7 @@ export async function migrate() {
|
||||||
const alreadyMigrated = Boolean(newData)
|
const alreadyMigrated = Boolean(newData)
|
||||||
|
|
||||||
if (!alreadyMigrated && rawLegacyData) {
|
if (!alreadyMigrated && rawLegacyData) {
|
||||||
logger.info('persisted state: migrating legacy storage')
|
logger.debug('persisted state: migrating legacy storage')
|
||||||
|
|
||||||
const legacyData = JSON.parse(rawLegacyData)
|
const legacyData = JSON.parse(rawLegacyData)
|
||||||
const newData = transform(legacyData)
|
const newData = transform(legacyData)
|
||||||
|
@ -139,14 +139,14 @@ export async function migrate() {
|
||||||
|
|
||||||
if (validate.success) {
|
if (validate.success) {
|
||||||
await write(newData)
|
await write(newData)
|
||||||
logger.info('persisted state: migrated legacy storage')
|
logger.debug('persisted state: migrated legacy storage')
|
||||||
} else {
|
} else {
|
||||||
logger.error('persisted state: legacy data failed validation', {
|
logger.error('persisted state: legacy data failed validation', {
|
||||||
message: validate.error,
|
message: validate.error,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.info('persisted state: no migration needed')
|
logger.debug('persisted state: no migration needed')
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.error(e, {
|
logger.error(e, {
|
||||||
|
|
|
@ -133,7 +133,7 @@ function createPersistSessionHandler(
|
||||||
accessJwt: session?.accessJwt,
|
accessJwt: session?.accessJwt,
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`session: persistSession`, {
|
logger.debug(`session: persistSession`, {
|
||||||
event,
|
event,
|
||||||
deactivated: refreshedAccount.deactivated,
|
deactivated: refreshedAccount.deactivated,
|
||||||
})
|
})
|
||||||
|
@ -320,7 +320,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
)
|
)
|
||||||
|
|
||||||
const logout = React.useCallback<ApiContext['logout']>(async () => {
|
const logout = React.useCallback<ApiContext['logout']>(async () => {
|
||||||
logger.info(`session: logout`)
|
logger.debug(`session: logout`)
|
||||||
clearCurrentAccount()
|
clearCurrentAccount()
|
||||||
setStateAndPersist(s => {
|
setStateAndPersist(s => {
|
||||||
return {
|
return {
|
||||||
|
@ -374,7 +374,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canReusePrevSession) {
|
if (canReusePrevSession) {
|
||||||
logger.info(`session: attempting to reuse previous session`)
|
logger.debug(`session: attempting to reuse previous session`)
|
||||||
|
|
||||||
agent.session = prevSession
|
agent.session = prevSession
|
||||||
__globalAgent = agent
|
__globalAgent = agent
|
||||||
|
@ -384,7 +384,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
if (prevSession.deactivated) {
|
if (prevSession.deactivated) {
|
||||||
// don't attempt to resume
|
// don't attempt to resume
|
||||||
// use will be taken to the deactivated screen
|
// 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
__globalAgent = PUBLIC_BSKY_AGENT
|
__globalAgent = PUBLIC_BSKY_AGENT
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.info(`session: attempting to resume using previous session`)
|
logger.debug(`session: attempting to resume using previous session`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const freshAccount = await resumeSessionWithFreshAccount()
|
const freshAccount = await resumeSessionWithFreshAccount()
|
||||||
|
@ -431,7 +431,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resumeSessionWithFreshAccount(): Promise<SessionAccount> {
|
async function resumeSessionWithFreshAccount(): Promise<SessionAccount> {
|
||||||
logger.info(`session: resumeSessionWithFreshAccount`)
|
logger.debug(`session: resumeSessionWithFreshAccount`)
|
||||||
|
|
||||||
await networkRetry(1, () => agent.resumeSession(prevSession))
|
await networkRetry(1, () => agent.resumeSession(prevSession))
|
||||||
|
|
||||||
|
@ -552,11 +552,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
return persisted.onUpdate(() => {
|
return persisted.onUpdate(() => {
|
||||||
const session = persisted.get('session')
|
const session = persisted.get('session')
|
||||||
|
|
||||||
logger.info(`session: persisted onUpdate`, {})
|
logger.debug(`session: persisted onUpdate`, {})
|
||||||
|
|
||||||
if (session.currentAccount && session.currentAccount.refreshJwt) {
|
if (session.currentAccount && session.currentAccount.refreshJwt) {
|
||||||
if (session.currentAccount?.did !== state.currentAccount?.did) {
|
if (session.currentAccount?.did !== state.currentAccount?.did) {
|
||||||
logger.info(`session: persisted onUpdate, switching accounts`, {
|
logger.debug(`session: persisted onUpdate, switching accounts`, {
|
||||||
from: {
|
from: {
|
||||||
did: state.currentAccount?.did,
|
did: state.currentAccount?.did,
|
||||||
handle: state.currentAccount?.handle,
|
handle: state.currentAccount?.handle,
|
||||||
|
@ -569,7 +569,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
|
|
||||||
initSession(session.currentAccount)
|
initSession(session.currentAccount)
|
||||||
} else {
|
} 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
|
* Use updated session in this tab's agent. Do not call
|
||||||
|
|
|
@ -107,7 +107,7 @@ export const LoginForm = ({
|
||||||
const errMsg = e.toString()
|
const errMsg = e.toString()
|
||||||
setIsProcessing(false)
|
setIsProcessing(false)
|
||||||
if (errMsg.includes('Authentication Required')) {
|
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,
|
error: errMsg,
|
||||||
})
|
})
|
||||||
setError(_(msg`Invalid username or password`))
|
setError(_(msg`Invalid username or password`))
|
||||||
|
|
Loading…
Reference in New Issue