@@ -6,6 +6,8 @@ import { Text, View } from '@/components/Themed';
66import { SENTRY_INTERNAL_DSN } from '@/utils/dsn' ;
77import { HttpClient } from '@sentry/integrations' ;
88import { setScopeProperties } from '@/utils/setScopeProperties' ;
9+ import { timestampInSeconds } from '@sentry/utils' ;
10+ import React from 'react' ;
911
1012const isRunningInExpoGo = Constants . appOwnership === 'expo'
1113
@@ -38,6 +40,7 @@ Sentry.init({
3840 // default: [/.*/]
3941 failedRequestTargets : [ / .* / ] ,
4042 } ) ,
43+ Sentry . metrics . metricsAggregatorIntegration ( ) ,
4144 ) ;
4245 return integrations . filter ( i => i . name !== 'Dedupe' ) ;
4346 } ,
@@ -66,6 +69,25 @@ Sentry.init({
6669} ) ;
6770
6871export default function TabOneScreen ( ) {
72+ const [ componentMountStartTimestamp ] = React . useState < number > ( ( ) => {
73+ return timestampInSeconds ( ) ;
74+ } ) ;
75+
76+ React . useEffect ( ( ) => {
77+ if ( componentMountStartTimestamp ) {
78+ // Distributions help you get the most insights from your data by allowing you to obtain aggregations such as p90, min, max, and avg.
79+ Sentry . metrics . distribution (
80+ 'tab_one_mount_time' ,
81+ timestampInSeconds ( ) - componentMountStartTimestamp ,
82+ {
83+ unit : "seconds" ,
84+ } ,
85+ ) ;
86+ }
87+ // We only want this to run once.
88+ // eslint-disable-next-line react-hooks/exhaustive-deps
89+ } , [ ] ) ;
90+
6991 return (
7092 < View style = { styles . container } >
7193 < Text > Welcome to Sentry Expo Sample App!</ Text >
@@ -78,6 +100,7 @@ export default function TabOneScreen() {
78100 < Button
79101 title = "Capture exception"
80102 onPress = { ( ) => {
103+ Sentry . metrics . increment ( 'tab_one.capture_exception_button_press' , 1 ) ;
81104 Sentry . captureException ( new Error ( 'Captured exception' ) ) ;
82105 } }
83106 />
0 commit comments