diff --git a/src/lib/hooks/useNotificationHandler.ts b/src/lib/hooks/useNotificationHandler.ts index fbf5453578..764b2f4405 100644 --- a/src/lib/hooks/useNotificationHandler.ts +++ b/src/lib/hooks/useNotificationHandler.ts @@ -188,7 +188,7 @@ export function useNotificationsHandler() { return DEFAULT_HANDLER_OPTIONS } - logger.debug('received', {e}) + logger.debug('Notifications: received', {e}) const payload = e.request.trigger.payload as NotificationPayload if ( @@ -215,7 +215,7 @@ export function useNotificationsHandler() { } prevDate = e.notification.date - logger.debug('response received', { + logger.debug('Notifications: response received', { actionIdentifier: e.actionIdentifier, }) @@ -242,7 +242,7 @@ export function useNotificationsHandler() { ) { truncateAndInvalidate(queryClient, RQKEY_NOTIFS('mentions')) } - logger.debug('handleNotification', { + logger.debug('Notifications: handleNotification', { content: e.notification.request.content, payload: e.notification.request.trigger.payload, }) diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index 05220fbb1d..d394b39803 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -9,13 +9,13 @@ import {devicePlatform, isAndroid, isNative} from '#/platform/detection' import {SessionAccount, useAgent, useSession} from '#/state/session' import BackgroundNotificationHandler from '../../../modules/expo-background-notification-handler' -const logger = Logger.create(Logger.Context.notifications) - const SERVICE_DID = (serviceUrl?: string) => serviceUrl?.includes('staging') ? 'did:web:api.staging.bsky.dev' : 'did:web:api.bsky.app' +const logger = Logger.create(Logger.Context.notifications) + async function registerPushToken( agent: BskyAgent, account: SessionAccount, @@ -28,7 +28,7 @@ async function registerPushToken( token: token.data, appId: 'xyz.blueskyweb.app', }) - logger.debug('sent push token (init)', { + logger.debug('Notifications: Sent push token (init)', { tokenType: token.type, token: token.data, }) diff --git a/src/state/messages/convo/agent.ts b/src/state/messages/convo/agent.ts index c7fd9530a3..473fccd1a5 100644 --- a/src/state/messages/convo/agent.ts +++ b/src/state/messages/convo/agent.ts @@ -127,7 +127,7 @@ export class Convo { getSnapshot(): ConvoState { if (!this.snapshot) this.snapshot = this.generateSnapshot() - // logger.debug('snapshotted', {}) + // logger.debug('Convo: snapshotted', {}) return this.snapshot } @@ -377,7 +377,7 @@ export class Convo { break } - logger.debug(`dispatch '${action.event}'`, { + logger.debug(`Convo: dispatch '${action.event}'`, { id: this.id, prev: prevStatus, next: this.status, @@ -452,13 +452,13 @@ export class Convo { * Some validation prior to `Ready` status */ if (!this.convo) { - throw new Error('could not find convo') + throw new Error('Convo: could not find convo') } if (!this.sender) { - throw new Error('could not find sender in convo') + throw new Error('Convo: could not find sender in convo') } if (!this.recipients) { - throw new Error('could not find recipients in convo') + throw new Error('Convo: could not find recipients in convo') } const userIsDisabled = Boolean(this.sender.chatDisabled) @@ -469,7 +469,7 @@ export class Convo { this.dispatch({event: ConvoDispatchEvent.Ready}) } } catch (e: any) { - logger.error(e, {context: 'setup failed'}) + logger.error(e, {context: 'Convo: setup failed'}) this.dispatch({ event: ConvoDispatchEvent.Error, @@ -574,7 +574,7 @@ export class Convo { this.sender = sender || this.sender this.recipients = recipients || this.recipients } catch (e: any) { - logger.error(e, {context: `failed to refresh convo`}) + logger.error(e, {context: `Convo: failed to refresh convo`}) } } @@ -584,7 +584,7 @@ export class Convo { } | undefined async fetchMessageHistory() { - logger.debug('fetch message history', {}) + logger.debug('Convo: fetch message history', {}) /* * If oldestRev is null, we've fetched all history. @@ -638,7 +638,7 @@ export class Convo { } } } catch (e: any) { - logger.error('failed to fetch message history') + logger.error('Convo: failed to fetch message history') this.fetchMessageHistoryError = { retry: () => { @@ -771,7 +771,7 @@ export class Convo { // Ignore empty messages for now since they have no other purpose atm if (!message.text.trim() && !message.embed) return - logger.debug('send message', {}) + logger.debug('Convo: send message', {}) const tempId = nanoid() @@ -789,7 +789,7 @@ export class Convo { async processPendingMessages() { logger.debug( - `processing messages (${this.pendingMessages.size} remaining)`, + `Convo: processing messages (${this.pendingMessages.size} remaining)`, {}, ) @@ -834,7 +834,7 @@ export class Convo { // continue queue processing await this.processPendingMessages() } catch (e: any) { - logger.error(e, {context: `failed to send message`}) + logger.error(e, {context: `Convo: failed to send message`}) this.handleSendMessageFailure(e) this.isProcessingPendingMessages = false } @@ -897,7 +897,7 @@ export class Convo { this.commit() logger.debug( - `batch retrying ${this.pendingMessages.size} pending messages`, + `Convo: batch retrying ${this.pendingMessages.size} pending messages`, {}, ) @@ -930,15 +930,18 @@ export class Convo { this.commit() - logger.debug(`sent ${this.pendingMessages.size} pending messages`, {}) + logger.debug( + `Convo: sent ${this.pendingMessages.size} pending messages`, + {}, + ) } catch (e: any) { - logger.error(e, {context: `failed to batch retry messages`}) + logger.error(e, {context: `Convo: failed to batch retry messages`}) this.handleSendMessageFailure(e) } } async deleteMessage(messageId: string) { - logger.debug('delete message', {}) + logger.debug('Convo: delete message', {}) this.deletedMessages.add(messageId) this.commit() @@ -954,7 +957,7 @@ export class Convo { ) }) } catch (e: any) { - logger.error(e, {context: `failed to delete message`}) + logger.error(e, {context: `Convo: failed to delete message`}) this.deletedMessages.delete(messageId) this.commit() throw e diff --git a/src/state/messages/events/agent.ts b/src/state/messages/events/agent.ts index 6e288dfd2d..09363b4b28 100644 --- a/src/state/messages/events/agent.ts +++ b/src/state/messages/events/agent.ts @@ -18,6 +18,7 @@ import { } from '#/state/messages/events/types' import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' +const LOGGER_CONTEXT = 'MessagesEventBus' const logger = Logger.create(Logger.Context.convo) export class MessagesEventBus { @@ -90,17 +91,17 @@ export class MessagesEventBus { } background() { - logger.debug(`background`, {}) + logger.debug(`${LOGGER_CONTEXT}: background`, {}) this.dispatch({event: MessagesEventBusDispatchEvent.Background}) } suspend() { - logger.debug(`suspend`, {}) + logger.debug(`${LOGGER_CONTEXT}: suspend`, {}) this.dispatch({event: MessagesEventBusDispatchEvent.Suspend}) } resume() { - logger.debug(`resume`, {}) + logger.debug(`${LOGGER_CONTEXT}: resume`, {}) this.dispatch({event: MessagesEventBusDispatchEvent.Resume}) } @@ -222,7 +223,7 @@ export class MessagesEventBus { break } - logger.debug(`dispatch '${action.event}'`, { + logger.debug(`${LOGGER_CONTEXT}: dispatch '${action.event}'`, { id: this.id, prev: prevStatus, next: this.status, @@ -230,7 +231,7 @@ export class MessagesEventBus { } private async init() { - logger.debug(`init`, {}) + logger.debug(`${LOGGER_CONTEXT}: init`, {}) try { const response = await networkRetry(2, () => { @@ -254,7 +255,7 @@ export class MessagesEventBus { this.dispatch({event: MessagesEventBusDispatchEvent.Ready}) } catch (e: any) { logger.error(e, { - context: `init failed`, + context: `${LOGGER_CONTEXT}: init failed`, }) this.dispatch({ @@ -317,13 +318,12 @@ export class MessagesEventBus { this.isPolling = true // logger.debug( - // `poll`, + // `${LOGGER_CONTEXT}: poll`, // { // requestedPollIntervals: Array.from( // this.requestedPollIntervals.values(), // ), // }, - // logger.DebugContext.convo, // ) try { @@ -368,12 +368,12 @@ export class MessagesEventBus { this.emitter.emit('event', {type: 'logs', logs: batch}) } catch (e: any) { logger.error(e, { - context: `process latest events`, + context: `${LOGGER_CONTEXT}: process latest events`, }) } } } catch (e: any) { - logger.error(e, {context: `poll events failed`}) + logger.error(e, {context: `${LOGGER_CONTEXT}: poll events failed`}) this.dispatch({ event: MessagesEventBusDispatchEvent.Error,