feat(metrics): Add timings
method to metrics (#12226)
This introduces a new method, metrics.timing()
, which can be used in two ways:
- With a numeric value, to simplify creating a distribution metric. This will default to
second
as unit:
Sentry.metrics.timing('myMetric', 100);
- With a callback, which will wrap the duration of the callback. This can accept a sync or async callback. It will
create an inactive span around the callback and at the end emit a metric with the duration of the span in seconds:
const returnValue = Sentry.metrics.timing('myMetric', measureThisFunction);
feat(react): Add Sentry.reactErrorHandler
(#12147)
This PR introduces Sentry.reactErrorHandler
, which you can use in React 19 as follows:
import * as Sentry from '@sentry/react';
import { hydrateRoot } from 'react-dom/client';
ReactDOM.hydrateRoot(
document.getElementById('root'),
<React.StrictMode>
<App />
</React.StrictMode>,
{
onUncaughtError: Sentry.reactErrorHandler(),
onCaughtError: Sentry.reactErrorHandler((error, errorInfo) => {
// optional callback if users want custom config.
}),
},
);
For more details, take a look at the PR. Our
documentation will be updated soon!