mirror of
				https://github.com/tooot-app/app
				synced 2025-06-05 22:19:13 +02:00 
			
		
		
		
	Update sentry reporting
This commit is contained in:
		| @@ -58,9 +58,9 @@ const apiGeneral = async <T = unknown>({ | ||||
|       }) | ||||
|     }) | ||||
|     .catch(error => { | ||||
|       if (sentry && Math.random() < 0.001) { | ||||
|       if (sentry && Math.random() < 0.01) { | ||||
|         Sentry.Native.setExtras({ | ||||
|           API: 'instance', | ||||
|           API: 'general', | ||||
|           ...(error.response && { response: error.response }), | ||||
|           ...(error.request && { request: error.request }) | ||||
|         }) | ||||
|   | ||||
| @@ -61,7 +61,7 @@ const apiTooot = async <T = unknown>({ | ||||
|       }) | ||||
|     }) | ||||
|     .catch(error => { | ||||
|       if (sentry && Math.random() < 0.005) { | ||||
|       if (sentry && Math.random() < 0.01) { | ||||
|         Sentry.Native.setExtras({ | ||||
|           API: 'tooot', | ||||
|           ...(error.response && { response: error.response }), | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import { findIndex } from 'lodash' | ||||
| import React, { useCallback, useEffect, useRef, useState } from 'react' | ||||
| import { FlatList } from 'react-native' | ||||
| import { InfiniteQueryObserver, useQueryClient } from 'react-query' | ||||
| import * as Sentry from 'sentry-expo' | ||||
|  | ||||
| const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({ | ||||
|   route: { | ||||
| @@ -40,30 +41,56 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({ | ||||
|         if (!scrolled.current) { | ||||
|           scrolled.current = true | ||||
|           const pointer = findIndex(flattenData, ['id', toot.id]) | ||||
|           pointer < flattenData.length && | ||||
|             setTimeout(() => { | ||||
|               flRef.current?.scrollToIndex({ | ||||
|           try { | ||||
|             pointer < flattenData.length && | ||||
|               setTimeout(() => { | ||||
|                 flRef.current?.scrollToIndex({ | ||||
|                   index: pointer, | ||||
|                   viewOffset: 100 | ||||
|                 }) | ||||
|               }, 500) | ||||
|           } catch (err) { | ||||
|             if (Math.random() < 0.1) { | ||||
|               Sentry.Native.setExtras({ | ||||
|                 type: 'original', | ||||
|                 index: pointer, | ||||
|                 viewOffset: 100 | ||||
|                 itemsLength: flattenData.length, | ||||
|                 flattenData | ||||
|               }) | ||||
|             }, 500) | ||||
|               Sentry.Native.captureException(err) | ||||
|             } | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }) | ||||
|     return () => unsubscribe() | ||||
|   }, []) | ||||
|   }, [scrolled.current]) | ||||
|  | ||||
|   // Toot page auto scroll to selected toot | ||||
|   const onScrollToIndexFailed = useCallback( | ||||
|     error => { | ||||
|       const offset = error.averageItemLength * error.index | ||||
|       flRef.current?.scrollToOffset({ offset }) | ||||
|       setTimeout( | ||||
|         () => | ||||
|           error.index < itemsLength && | ||||
|           flRef.current?.scrollToIndex({ index: error.index, viewOffset: 100 }), | ||||
|         500 | ||||
|       ) | ||||
|       try { | ||||
|         error.index < itemsLength && | ||||
|           setTimeout( | ||||
|             () => | ||||
|               flRef.current?.scrollToIndex({ | ||||
|                 index: error.index, | ||||
|                 viewOffset: 100 | ||||
|               }), | ||||
|             500 | ||||
|           ) | ||||
|       } catch (err) { | ||||
|         if (Math.random() < 0.1) { | ||||
|           Sentry.Native.setExtras({ | ||||
|             type: 'onScrollToIndexFailed', | ||||
|             index: error.index, | ||||
|             itemsLength | ||||
|           }) | ||||
|           Sentry.Native.captureException(err) | ||||
|         } | ||||
|       } | ||||
|     }, | ||||
|     [itemsLength] | ||||
|   ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user