@@ -6,6 +6,8 @@ import { Text, View } from '@/components/Themed';
6
6
import { SENTRY_INTERNAL_DSN } from '@/utils/dsn' ;
7
7
import { HttpClient } from '@sentry/integrations' ;
8
8
import { setScopeProperties } from '@/utils/setScopeProperties' ;
9
+ import { timestampInSeconds } from '@sentry/utils' ;
10
+ import React from 'react' ;
9
11
10
12
const isRunningInExpoGo = Constants . appOwnership === 'expo'
11
13
@@ -38,6 +40,7 @@ Sentry.init({
38
40
// default: [/.*/]
39
41
failedRequestTargets : [ / .* / ] ,
40
42
} ) ,
43
+ Sentry . metrics . metricsAggregatorIntegration ( ) ,
41
44
) ;
42
45
return integrations . filter ( i => i . name !== 'Dedupe' ) ;
43
46
} ,
@@ -66,6 +69,25 @@ Sentry.init({
66
69
} ) ;
67
70
68
71
export 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
+
69
91
return (
70
92
< View style = { styles . container } >
71
93
< Text > Welcome to Sentry Expo Sample App!</ Text >
@@ -78,6 +100,7 @@ export default function TabOneScreen() {
78
100
< Button
79
101
title = "Capture exception"
80
102
onPress = { ( ) => {
103
+ Sentry . metrics . increment ( 'tab_one.capture_exception_button_press' , 1 ) ;
81
104
Sentry . captureException ( new Error ( 'Captured exception' ) ) ;
82
105
} }
83
106
/>
0 commit comments