Skip to content

Commit d040c6c

Browse files
committed
Metrics for sample apps
1 parent 190a7ba commit d040c6c

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
### Features
1212

13-
- Adds metrics ([#5402](https://github.com/getsentry/sentry-react-native/pull/5402))
13+
- Adds Metrics Beta ([#5402](https://github.com/getsentry/sentry-react-native/pull/5402))
1414

1515
### Dependencies
1616

samples/react-native-macos/src/Screens/ErrorsScreen.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ const ErrorsScreen = (_props: Props) => {
8686
setScopeProperties();
8787
}}
8888
/>
89+
<Button
90+
title="Send count metric"
91+
onPress={() => {
92+
Sentry.metrics.count('count_metric', 1);
93+
}}
94+
/>
95+
<Button
96+
title="Send distribution metric"
97+
onPress={() => {
98+
Sentry.metrics.count('distribution_metric', 100);
99+
}}
100+
/>
101+
<Button
102+
title="Send distribution metric"
103+
onPress={() => {
104+
Sentry.metrics.count('distribution_metric', 100);
105+
}}
106+
/>
89107
<Button
90108
title="Flush"
91109
onPress={async () => {

samples/react-native/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Sentry.init({
171171
// This should be disabled when manually initializing the native SDK
172172
// Note that options from JS are not passed to the native SDKs when initialized manually
173173
autoInitializeNativeSdk: true,
174+
enableMetrics: true,
174175
});
175176

176177
function BottomTabsNavigator() {

samples/react-native/src/Screens/ErrorsScreen.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,24 @@ const ErrorsScreen = (_props: Props) => {
114114
setScopeProperties();
115115
}}
116116
/>
117+
<Button
118+
title="Send count metric"
119+
onPress={() => {
120+
Sentry.metrics.count('count_metric', 1);
121+
}}
122+
/>
123+
<Button
124+
title="Send distribution metric"
125+
onPress={() => {
126+
Sentry.metrics.count('distribution_metric', 100);
127+
}}
128+
/>
129+
<Button
130+
title="Send distribution metric"
131+
onPress={() => {
132+
Sentry.metrics.count('distribution_metric', 100);
133+
}}
134+
/>
117135
<Button
118136
title="Flush"
119137
onPress={async () => {

0 commit comments

Comments
 (0)