Skip to content

Commit

Permalink
misc: Removes deprecated Sentry.metrics API (#4278)
Browse files Browse the repository at this point in the history
* Remove metric from the Expo app

* Remove metric from the MacOS app

* Remove metric from the RN app

---------

Co-authored-by: LucasZF <[email protected]>
  • Loading branch information
antonis and lucas-zimerman authored Nov 18, 2024
1 parent c686700 commit b53dbe6
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 67 deletions.
21 changes: 0 additions & 21 deletions samples/expo/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,11 @@ import * as Sentry from '@sentry/react-native';

import { Text, View } from '@/components/Themed';
import { setScopeProperties } from '@/utils/setScopeProperties';
import { timestampInSeconds } from '@sentry/utils';
import React from 'react';

const isRunningInExpoGo = Constants.appOwnership === 'expo'

export default function TabOneScreen() {
const [componentMountStartTimestamp] = React.useState<number>(() => {
return timestampInSeconds();
});

React.useEffect(() => {
if (componentMountStartTimestamp) {
// Distributions help you get the most insights from your data by allowing you to obtain aggregations such as p90, min, max, and avg.
Sentry.metrics.distribution(
'tab_one_mount_time',
timestampInSeconds() - componentMountStartTimestamp,
{
unit: "seconds",
},
);
}
// We only want this to run once.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<View style={styles.container}>
<Sentry.TimeToInitialDisplay record />
Expand All @@ -42,7 +22,6 @@ export default function TabOneScreen() {
<Button
title="Capture exception"
onPress={() => {
Sentry.metrics.increment('tab_one.capture_exception_button_press', 1);
Sentry.captureException(new Error('Captured exception'));
}}
/>
Expand Down
20 changes: 0 additions & 20 deletions samples/react-native-macos/src/Screens/ErrorsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,12 @@ import { setScopeProperties } from '../setScopeProperties';
import { StackNavigationProp } from '@react-navigation/stack';
import { UserFeedbackModal } from '../components/UserFeedbackModal';
import { FallbackRender } from '@sentry/react';
import { timestampInSeconds } from '@sentry/utils';

interface Props {
navigation: StackNavigationProp<any, 'HomeScreen'>;
}

const ErrorsScreen = (_props: Props) => {
const [componentMountStartTimestamp] = React.useState<number>(() => {
return timestampInSeconds();
});

React.useEffect(() => {
if (componentMountStartTimestamp) {
// Distributions help you get the most insights from your data by allowing you to obtain aggregations such as p90, min, max, and avg.
Sentry.metrics.distribution(
'home_mount_time',
timestampInSeconds() - componentMountStartTimestamp,
{
unit: 'seconds',
},
);
}
// We only want this to run once.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

// Show bad code inside error boundary to trigger it.
const [showBadCode, setShowBadCode] = React.useState(false);
const [isFeedbackVisible, setFeedbackVisible] = React.useState(false);
Expand Down
3 changes: 0 additions & 3 deletions samples/react-native-macos/src/Screens/TrackerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ const TrackerScreen = () => {
};

const onRefreshButtonPress = () => {
Sentry.metrics.increment('tracker_screen.refresh_button_press', 1, {
tags: { graph: 'none', public_data: true },
});
loadData();
};

Expand Down
20 changes: 0 additions & 20 deletions samples/react-native/src/Screens/ErrorsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { UserFeedbackModal } from '../components/UserFeedbackModal';
import { FallbackRender } from '@sentry/react';
import NativeSampleModule from '../../tm/NativeSampleModule';
import NativePlatformSampleModule from '../../tm/NativePlatformSampleModule';
import { timestampInSeconds } from '@sentry/utils';

const { AssetsModule, CppModule, CrashModule } = NativeModules;

Expand All @@ -28,25 +27,6 @@ interface Props {
}

const ErrorsScreen = (_props: Props) => {
const [componentMountStartTimestamp] = React.useState<number>(() => {
return timestampInSeconds();
});

React.useEffect(() => {
if (componentMountStartTimestamp) {
// Distributions help you get the most insights from your data by allowing you to obtain aggregations such as p90, min, max, and avg.
Sentry.metrics.distribution(
'home_mount_time',
timestampInSeconds() - componentMountStartTimestamp,
{
unit: 'seconds',
},
);
}
// We only want this to run once.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

// Show bad code inside error boundary to trigger it.
const [showBadCode, setShowBadCode] = React.useState(false);
const [isFeedbackVisible, setFeedbackVisible] = React.useState(false);
Expand Down
3 changes: 0 additions & 3 deletions samples/react-native/src/Screens/TrackerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ const TrackerScreen = () => {
};

const onRefreshButtonPress = () => {
Sentry.metrics.increment('tracker_screen.refresh_button_press', 1, {
tags: { graph: 'none', public_data: true },
});
loadData();
};

Expand Down

0 comments on commit b53dbe6

Please sign in to comment.