diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index f930bd7b..f75ebbd9 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -178,10 +178,9 @@ export async function post(store: RootStoreModel, opts: PostOpts) { ) { encoding = 'image/jpeg' } else { - store.log.warn( - 'Unexpected image format for thumbnail, skipping', - opts.extLink.localThumb.path, - ) + store.log.warn('Unexpected image format for thumbnail, skipping', { + thumbnail: opts.extLink.localThumb.path, + }) } if (encoding) { const thumbUploadRes = await uploadBlob( diff --git a/src/lib/hooks/useOTAUpdate.ts b/src/lib/hooks/useOTAUpdate.ts index 5155a808..d7855b2d 100644 --- a/src/lib/hooks/useOTAUpdate.ts +++ b/src/lib/hooks/useOTAUpdate.ts @@ -34,18 +34,18 @@ export function useOTAUpdate() { // show a popup modal showUpdatePopup() } catch (e) { - console.error('useOTAUpdate: Error while checking for update', e) - store.log.error('useOTAUpdate: Error while checking for update', e) + store.log.error('useOTAUpdate: Error while checking for update', { + error: e, + }) } }, [showUpdatePopup, store.log]) const updateEventListener = useCallback( (event: Updates.UpdateEvent) => { store.log.debug('useOTAUpdate: Listening for update...') if (event.type === Updates.UpdateEventType.ERROR) { - store.log.error( - 'useOTAUpdate: Error while listening for update', - event.message, - ) + store.log.error('useOTAUpdate: Error while listening for update', { + message: event.message, + }) } else if (event.type === Updates.UpdateEventType.NO_UPDATE_AVAILABLE) { // Handle no update available // do nothing diff --git a/src/lib/notifications/notifications.ts b/src/lib/notifications/notifications.ts index dfc9a42b..01b0ba93 100644 --- a/src/lib/notifications/notifications.ts +++ b/src/lib/notifications/notifications.ts @@ -30,18 +30,18 @@ export function init(store: RootStoreModel) { appId: 'xyz.blueskyweb.app', }) store.log.debug('Notifications: Sent push token (init)', { - type: token.type, + tokenType: token.type, token: token.data, }) } catch (error) { - store.log.error('Notifications: Failed to set push token', error) + store.log.error('Notifications: Failed to set push token', {error}) } } // listens for new changes to the push token // In rare situations, a push token may be changed by the push notification service while the app is running. When a token is rolled, the old one becomes invalid and sending notifications to it will fail. A push token listener will let you handle this situation gracefully by registering the new token with your backend right away. Notifications.addPushTokenListener(async ({data: t, type}) => { - store.log.debug('Notifications: Push token changed', {t, type}) + store.log.debug('Notifications: Push token changed', {t, tokenType: type}) if (t) { try { await store.agent.api.app.bsky.notification.registerPush({ @@ -51,11 +51,11 @@ export function init(store: RootStoreModel) { appId: 'xyz.blueskyweb.app', }) store.log.debug('Notifications: Sent push token (event)', { - type, + tokenType: type, token: t, }) } catch (error) { - store.log.error('Notifications: Failed to set push token', error) + store.log.error('Notifications: Failed to set push token', {error}) } } }) @@ -63,7 +63,7 @@ export function init(store: RootStoreModel) { // handle notifications that are received, both in the foreground or background Notifications.addNotificationReceivedListener(event => { - store.log.debug('Notifications: received', event) + store.log.debug('Notifications: received', {event}) if (event.request.trigger.type === 'push') { // refresh notifications in the background store.me.notifications.syncQueue() @@ -84,10 +84,9 @@ export function init(store: RootStoreModel) { // handle notifications that are tapped on const sub = Notifications.addNotificationResponseReceivedListener( response => { - store.log.debug( - 'Notifications: response received', - response.actionIdentifier, - ) + store.log.debug('Notifications: response received', { + actionIdentifier: response.actionIdentifier, + }) if ( response.actionIdentifier === Notifications.DEFAULT_ACTION_IDENTIFIER ) { diff --git a/src/state/models/content/feed-source.ts b/src/state/models/content/feed-source.ts index 8dac9b56..d1b8fc9d 100644 --- a/src/state/models/content/feed-source.ts +++ b/src/state/models/content/feed-source.ts @@ -134,7 +134,7 @@ export class FeedSourceModel { try { await this.rootStore.preferences.addSavedFeed(this.uri) } catch (error) { - this.rootStore.log.error('Failed to save feed', error) + this.rootStore.log.error('Failed to save feed', {error}) } finally { track('CustomFeed:Save') } @@ -147,7 +147,7 @@ export class FeedSourceModel { try { await this.rootStore.preferences.removeSavedFeed(this.uri) } catch (error) { - this.rootStore.log.error('Failed to unsave feed', error) + this.rootStore.log.error('Failed to unsave feed', {error}) } finally { track('CustomFeed:Unsave') } @@ -157,7 +157,7 @@ export class FeedSourceModel { try { await this.rootStore.preferences.addPinnedFeed(this.uri) } catch (error) { - this.rootStore.log.error('Failed to pin feed', error) + this.rootStore.log.error('Failed to pin feed', {error}) } finally { track('CustomFeed:Pin', { name: this.displayName, @@ -194,7 +194,7 @@ export class FeedSourceModel { } catch (e: any) { this.likeUri = undefined this.likeCount = (this.likeCount || 1) - 1 - this.rootStore.log.error('Failed to like feed', e) + this.rootStore.log.error('Failed to like feed', {error: e}) } finally { track('CustomFeed:Like') } @@ -215,7 +215,7 @@ export class FeedSourceModel { } catch (e: any) { this.likeUri = uri this.likeCount = (this.likeCount || 0) + 1 - this.rootStore.log.error('Failed to unlike feed', e) + this.rootStore.log.error('Failed to unlike feed', {error: e}) } finally { track('CustomFeed:Unlike') } diff --git a/src/state/models/content/list.ts b/src/state/models/content/list.ts index 8fb9f4b5..985d8d82 100644 --- a/src/state/models/content/list.ts +++ b/src/state/models/content/list.ts @@ -339,7 +339,7 @@ export class ListModel { try { await this.rootStore.preferences.addPinnedFeed(this.uri) } catch (error) { - this.rootStore.log.error('Failed to pin feed', error) + this.rootStore.log.error('Failed to pin feed', {error}) } finally { track('CustomFeed:Pin', { name: this.data?.name || '', @@ -455,10 +455,12 @@ export class ListModel { this.error = cleanError(err) this.loadMoreError = cleanError(loadMoreErr) if (err) { - this.rootStore.log.error('Failed to fetch user items', err) + this.rootStore.log.error('Failed to fetch user items', {error: err}) } if (loadMoreErr) { - this.rootStore.log.error('Failed to fetch user items', loadMoreErr) + this.rootStore.log.error('Failed to fetch user items', { + error: loadMoreErr, + }) } } diff --git a/src/state/models/feeds/notifications.ts b/src/state/models/feeds/notifications.ts index 34f5d4ad..3f18c18d 100644 --- a/src/state/models/feeds/notifications.ts +++ b/src/state/models/feeds/notifications.ts @@ -220,7 +220,7 @@ export class NotificationsFeedItemModel { } this.rootStore.log.warn( 'app.bsky.notifications.list served an unsupported record type', - v, + {record: v}, ) } diff --git a/src/state/models/feeds/post.ts b/src/state/models/feeds/post.ts index d46cced7..3def5dce 100644 --- a/src/state/models/feeds/post.ts +++ b/src/state/models/feeds/post.ts @@ -42,10 +42,9 @@ export class PostsFeedItemModel { } else { this.postRecord = undefined this.richText = undefined - rootStore.log.warn( - 'Received an invalid app.bsky.feed.post record', - valid.error, - ) + rootStore.log.warn('Received an invalid app.bsky.feed.post record', { + error: valid.error, + }) } } else { this.postRecord = undefined @@ -133,7 +132,7 @@ export class PostsFeedItemModel { track('Post:Like') } } catch (error) { - this.rootStore.log.error('Failed to toggle like', error) + this.rootStore.log.error('Failed to toggle like', {error}) } } @@ -168,7 +167,7 @@ export class PostsFeedItemModel { track('Post:Repost') } } catch (error) { - this.rootStore.log.error('Failed to toggle repost', error) + this.rootStore.log.error('Failed to toggle repost', {error}) } } @@ -182,7 +181,7 @@ export class PostsFeedItemModel { track('Post:ThreadMute') } } catch (error) { - this.rootStore.log.error('Failed to toggle thread mute', error) + this.rootStore.log.error('Failed to toggle thread mute', {error}) } } @@ -191,7 +190,7 @@ export class PostsFeedItemModel { await this.rootStore.agent.deletePost(this.post.uri) this.rootStore.emitPostDeleted(this.post.uri) } catch (error) { - this.rootStore.log.error('Failed to delete post', error) + this.rootStore.log.error('Failed to delete post', {error}) } finally { track('Post:Delete') } diff --git a/src/state/models/invited-users.ts b/src/state/models/invited-users.ts index cd366706..995c4bfb 100644 --- a/src/state/models/invited-users.ts +++ b/src/state/models/invited-users.ts @@ -63,10 +63,9 @@ export class InvitedUsers { }) this.rootStore.me.follows.hydrateMany(this.profiles) } catch (e) { - this.rootStore.log.error( - 'Failed to fetch profiles for invited users', - e, - ) + this.rootStore.log.error('Failed to fetch profiles for invited users', { + error: e, + }) } } } diff --git a/src/state/models/me.ts b/src/state/models/me.ts index e7baf5bf..14b2ef84 100644 --- a/src/state/models/me.ts +++ b/src/state/models/me.ts @@ -110,13 +110,17 @@ export class MeModel { await this.fetchProfile() this.mainFeed.clear() /* dont await */ this.mainFeed.setup().catch(e => { - this.rootStore.log.error('Failed to setup main feed model', e) + this.rootStore.log.error('Failed to setup main feed model', {error: e}) }) /* dont await */ this.notifications.setup().catch(e => { - this.rootStore.log.error('Failed to setup notifications model', e) + this.rootStore.log.error('Failed to setup notifications model', { + error: e, + }) }) /* dont await */ this.notifications.setup().catch(e => { - this.rootStore.log.error('Failed to setup notifications model', e) + this.rootStore.log.error('Failed to setup notifications model', { + error: e, + }) }) this.myFeeds.clear() /* dont await */ this.myFeeds.saved.refresh() @@ -184,7 +188,9 @@ export class MeModel { }) }) } catch (e) { - this.rootStore.log.error('Failed to fetch user invite codes', e) + this.rootStore.log.error('Failed to fetch user invite codes', { + error: e, + }) } await this.rootStore.invitedUsers.fetch(this.invites) } @@ -199,7 +205,9 @@ export class MeModel { this.appPasswords = res.data.passwords }) } catch (e) { - this.rootStore.log.error('Failed to fetch user app passwords', e) + this.rootStore.log.error('Failed to fetch user app passwords', { + error: e, + }) } } } @@ -220,7 +228,7 @@ export class MeModel { }) return res.data } catch (e) { - this.rootStore.log.error('Failed to create app password', e) + this.rootStore.log.error('Failed to create app password', {error: e}) } } } @@ -235,7 +243,7 @@ export class MeModel { this.appPasswords = this.appPasswords.filter(p => p.name !== name) }) } catch (e) { - this.rootStore.log.error('Failed to delete app password', e) + this.rootStore.log.error('Failed to delete app password', {error: e}) } } } diff --git a/src/state/models/media/image.ts b/src/state/models/media/image.ts index c26f9b87..4ca0b47c 100644 --- a/src/state/models/media/image.ts +++ b/src/state/models/media/image.ts @@ -188,7 +188,7 @@ export class ImageModel implements Omit { this.cropped = cropped }) } catch (err) { - this.rootStore.log.error('Failed to crop photo', err) + this.rootStore.log.error('Failed to crop photo', {error: err}) } } diff --git a/src/view/com/lists/ListItems.tsx b/src/view/com/lists/ListItems.tsx index 855c07d1..76cd5e7c 100644 --- a/src/view/com/lists/ListItems.tsx +++ b/src/view/com/lists/ListItems.tsx @@ -94,7 +94,7 @@ export const ListItems = observer(function ListItemsImpl({ try { await list.refresh() } catch (err) { - list.rootStore.log.error('Failed to refresh lists', err) + list.rootStore.log.error('Failed to refresh lists', {error: err}) } setIsRefreshing(false) }, [list, track, setIsRefreshing]) @@ -104,7 +104,7 @@ export const ListItems = observer(function ListItemsImpl({ try { await list.loadMore() } catch (err) { - list.rootStore.log.error('Failed to load more lists', err) + list.rootStore.log.error('Failed to load more lists', {error: err}) } }, [list, track]) diff --git a/src/view/com/lists/ListsList.tsx b/src/view/com/lists/ListsList.tsx index efc874ef..c0acaa96 100644 --- a/src/view/com/lists/ListsList.tsx +++ b/src/view/com/lists/ListsList.tsx @@ -78,7 +78,7 @@ export const ListsList = observer(function ListsListImpl({ try { await listsList.refresh() } catch (err) { - listsList.rootStore.log.error('Failed to refresh lists', err) + listsList.rootStore.log.error('Failed to refresh lists', {error: err}) } setIsRefreshing(false) }, [listsList, track, setIsRefreshing]) @@ -88,7 +88,7 @@ export const ListsList = observer(function ListsListImpl({ try { await listsList.loadMore() } catch (err) { - listsList.rootStore.log.error('Failed to load more lists', err) + listsList.rootStore.log.error('Failed to load more lists', {error: err}) } }, [listsList, track]) diff --git a/src/view/com/notifications/Feed.tsx b/src/view/com/notifications/Feed.tsx index 4ca22282..ef16f598 100644 --- a/src/view/com/notifications/Feed.tsx +++ b/src/view/com/notifications/Feed.tsx @@ -61,7 +61,9 @@ export const Feed = observer(function Feed({ setIsPTRing(true) await view.refresh() } catch (err) { - view.rootStore.log.error('Failed to refresh notifications feed', err) + view.rootStore.log.error('Failed to refresh notifications feed', { + error: err, + }) } finally { setIsPTRing(false) } @@ -71,7 +73,9 @@ export const Feed = observer(function Feed({ try { await view.loadMore() } catch (err) { - view.rootStore.log.error('Failed to load more notifications', err) + view.rootStore.log.error('Failed to load more notifications', { + error: err, + }) } }, [view]) diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 378ef502..b0728a8a 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -119,7 +119,7 @@ export const PostThread = observer(function PostThread({ try { view?.refresh() } catch (err) { - view.rootStore.log.error('Failed to refresh posts thread', err) + view.rootStore.log.error('Failed to refresh posts thread', {error: err}) } setIsRefreshing(false) }, [view, setIsRefreshing]) diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 8976a7e2..43026916 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -111,13 +111,13 @@ export const PostThreadItem = observer(function PostThreadItem({ const onPressToggleRepost = React.useCallback(() => { return item .toggleRepost() - .catch(e => store.log.error('Failed to toggle repost', e)) + .catch(e => store.log.error('Failed to toggle repost', {error: e})) }, [item, store]) const onPressToggleLike = React.useCallback(() => { return item .toggleLike() - .catch(e => store.log.error('Failed to toggle like', e)) + .catch(e => store.log.error('Failed to toggle like', {error: e})) }, [item, store]) const onCopyPostText = React.useCallback(() => { @@ -138,7 +138,7 @@ export const PostThreadItem = observer(function PostThreadItem({ Toast.show('You will now receive notifications for this thread') } } catch (e) { - store.log.error('Failed to toggle thread mute', e) + store.log.error('Failed to toggle thread mute', {error: e}) } }, [item, store]) @@ -149,7 +149,7 @@ export const PostThreadItem = observer(function PostThreadItem({ Toast.show('Post deleted') }, e => { - store.log.error('Failed to delete post', e) + store.log.error('Failed to delete post', {error: e}) Toast.show('Failed to delete post, please try again') }, ) diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index e3c948e5..8f862f32 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -142,13 +142,13 @@ const PostLoaded = observer(function PostLoadedImpl({ const onPressToggleRepost = React.useCallback(() => { return item .toggleRepost() - .catch(e => store.log.error('Failed to toggle repost', e)) + .catch(e => store.log.error('Failed to toggle repost', {error: e})) }, [item, store]) const onPressToggleLike = React.useCallback(() => { return item .toggleLike() - .catch(e => store.log.error('Failed to toggle like', e)) + .catch(e => store.log.error('Failed to toggle like', {error: e})) }, [item, store]) const onCopyPostText = React.useCallback(() => { @@ -169,7 +169,7 @@ const PostLoaded = observer(function PostLoadedImpl({ Toast.show('You will now receive notifications for this thread') } } catch (e) { - store.log.error('Failed to toggle thread mute', e) + store.log.error('Failed to toggle thread mute', {error: e}) } }, [item, store]) @@ -180,7 +180,7 @@ const PostLoaded = observer(function PostLoadedImpl({ Toast.show('Post deleted') }, e => { - store.log.error('Failed to delete post', e) + store.log.error('Failed to delete post', {error: e}) Toast.show('Failed to delete post, please try again') }, ) diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 0578036d..7d54fd84 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -92,7 +92,7 @@ export const Feed = observer(function Feed({ try { await feed.refresh() } catch (err) { - feed.rootStore.log.error('Failed to refresh posts feed', err) + feed.rootStore.log.error('Failed to refresh posts feed', {error: err}) } setIsRefreshing(false) }, [feed, track, setIsRefreshing]) @@ -104,7 +104,7 @@ export const Feed = observer(function Feed({ try { await feed.loadMore() } catch (err) { - feed.rootStore.log.error('Failed to load more posts', err) + feed.rootStore.log.error('Failed to load more posts', {error: err}) } }, [feed, track]) diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 44162163..4d49eba6 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -94,14 +94,14 @@ export const FeedItem = observer(function FeedItemImpl({ track('FeedItem:PostRepost') return item .toggleRepost() - .catch(e => store.log.error('Failed to toggle repost', e)) + .catch(e => store.log.error('Failed to toggle repost', {error: e})) }, [track, item, store]) const onPressToggleLike = React.useCallback(() => { track('FeedItem:PostLike') return item .toggleLike() - .catch(e => store.log.error('Failed to toggle like', e)) + .catch(e => store.log.error('Failed to toggle like', {error: e})) }, [track, item, store]) const onCopyPostText = React.useCallback(() => { @@ -123,7 +123,7 @@ export const FeedItem = observer(function FeedItemImpl({ Toast.show('You will now receive notifications for this thread') } } catch (e) { - store.log.error('Failed to toggle thread mute', e) + store.log.error('Failed to toggle thread mute', {error: e}) } }, [track, item, store]) @@ -135,7 +135,7 @@ export const FeedItem = observer(function FeedItemImpl({ Toast.show('Post deleted') }, e => { - store.log.error('Failed to delete post', e) + store.log.error('Failed to delete post', {error: e}) Toast.show('Failed to delete post, please try again') }, ) diff --git a/src/view/screens/PostThread.tsx b/src/view/screens/PostThread.tsx index d4447f13..5f15adcc 100644 --- a/src/view/screens/PostThread.tsx +++ b/src/view/screens/PostThread.tsx @@ -38,7 +38,7 @@ export const PostThreadScreen = withAuthRequired( InteractionManager.runAfterInteractions(() => { if (!view.hasLoaded && !view.isLoading) { view.setup().catch(err => { - store.log.error('Failed to fetch thread', err) + store.log.error('Failed to fetch thread', {error: err}) }) } })