This commit is contained in:
Zhiyuan Zheng 2022-02-14 22:10:07 +01:00
parent e388ce7626
commit 06db0580cd
6 changed files with 24 additions and 22 deletions

View File

@ -1,3 +1,4 @@
import analytics from '@components/analytics'
import { HeaderLeft } from '@components/Header' import { HeaderLeft } from '@components/Header'
import { displayMessage, Message } from '@components/Message' import { displayMessage, Message } from '@components/Message'
import navigationRef from '@helpers/navigationRef' import navigationRef from '@helpers/navigationRef'
@ -21,7 +22,6 @@ import { updateFilters } from '@utils/slices/instances/updateFilters'
import { getInstanceActive, getInstances } from '@utils/slices/instancesSlice' import { getInstanceActive, getInstances } from '@utils/slices/instancesSlice'
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import { themes } from '@utils/styles/themes' import { themes } from '@utils/styles/themes'
import * as Analytics from 'expo-firebase-analytics'
import * as Linking from 'expo-linking' import * as Linking from 'expo-linking'
import { addScreenshotListener } from 'expo-screen-capture' import { addScreenshotListener } from 'expo-screen-capture'
import React, { useCallback, useEffect, useRef, useState } from 'react' import React, { useCallback, useEffect, useRef, useState } from 'react'
@ -118,7 +118,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
} }
if (previousRoute?.name !== currentRoute?.name) { if (previousRoute?.name !== currentRoute?.name) {
Analytics.logEvent('screen_view', { screen_name: currentRoute?.name }) analytics('screen_view', { screen_name: currentRoute?.name })
Sentry.Native.setContext('page', { Sentry.Native.setContext('page', {
previous: previousRoute, previous: previousRoute,
current: currentRoute current: currentRoute

View File

@ -58,14 +58,14 @@ const apiGeneral = async <T = unknown>({
}) })
}) })
.catch(error => { .catch(error => {
if (sentry && Math.random() < 0.01) { // if (sentry && Math.random() < 0.01) {
Sentry.Native.setExtras({ // Sentry.Native.setExtras({
API: 'general', // API: 'general',
...(error.response && { response: error.response }), // ...(error.response && { response: error.response }),
...(error.request && { request: error.request }) // ...(error.request && { request: error.request })
}) // })
Sentry.Native.captureException(error) // Sentry.Native.captureException(error)
} // }
if (error.response) { if (error.response) {
// The request was made and the server responded with a status code // The request was made and the server responded with a status code

View File

@ -98,14 +98,14 @@ const apiInstance = async <T = unknown>({
}) })
}) })
.catch(error => { .catch(error => {
if (Math.random() < 0.001) { // if (Math.random() < 0.001) {
Sentry.Native.setExtras({ // Sentry.Native.setExtras({
API: 'instance', // API: 'instance',
...(error.response && { response: error.response }), // ...(error.response && { response: error.response }),
...(error.request && { request: error.request }) // ...(error.request && { request: error.request })
}) // })
Sentry.Native.captureException(error) // Sentry.Native.captureException(error)
} // }
if (error.response) { if (error.response) {
// The request was made and the server responded with a status code // The request was made and the server responded with a status code

View File

@ -41,7 +41,7 @@ export const shouldFilter = ({
}) => { }) => {
const instance = getInstance(store.getState()) const instance = getInstance(store.getState())
const ownAccount = const ownAccount =
getInstanceAccount(store.getState())?.id === status.account.id getInstanceAccount(store.getState())?.id === status.account?.id
let shouldFilter = false let shouldFilter = false
if (!ownAccount) { if (!ownAccount) {

View File

@ -1,7 +1,7 @@
import * as Analytics from 'expo-firebase-analytics' import * as Analytics from 'expo-firebase-analytics'
const analytics = (event: string, params?: { [key: string]: any }) => { const analytics = (event: string, params?: { [key: string]: any }) => {
Analytics.logEvent(event, params) Analytics.logEvent(event, params).catch(() => {})
} }
export default analytics export default analytics

View File

@ -91,8 +91,10 @@ const AccountAttachments = React.memo(
return ( return (
<GracefullyImage <GracefullyImage
uri={{ uri={{
original: item.media_attachments[0].preview_url, original:
remote: item.media_attachments[0].remote_url item.media_attachments[0]?.preview_url ||
item.media_attachments[0]?.url,
remote: item.media_attachments[0]?.remote_url
}} }}
blurhash={item.media_attachments[0].blurhash} blurhash={item.media_attachments[0].blurhash}
dimension={{ width: width, height: width }} dimension={{ width: width, height: width }}