sentry-react-native: Duplicate Breadcrumbs
Environment
How do you use Sentry? sentry.io
Which SDK and version?
- react native 0.61.5
- @sentry/react-native: ^2.3.0
Steps to Reproduce
const dsn = Config.SENTRY_DSN;
const debug = false;
const release = `${DeviceInfo.getBundleId()}@${versionName}@${versionCode}+codepush:${codepushDist}`;
const dist = `${versionName}.${codepushDist}`;
const environment = isProductionEnv ? 'production' : 'staging';
const sampleRate = debug ? 1 : 0.5;
const tracesSampleRate = 0.2;
const maxBreadcrumbs = 150;
Sentry.init({
dsn,
debug,
release,
dist,
environment,
sampleRate,
tracesSampleRate,
maxBreadcrumbs,
});
Set those initialization and surfing on my app normally until I get some errors.
Expected Result
breadcrumb data is not logged twice.
Actual Result
Looking at Breadcrumb section, I found that each breadcrumb data logged twice. xhr
breadcrumb is logged by default by Sentry SDK. btn_clicked
and navigate
is manually logged, I mean, my code that logged it. Both of them logged twice.
this is how I add a breadcrumb.
export function recordBreadcrumb(key, message, level = Sentry.Severity.Info) {
Sentry.addBreadcrumb({
category: key,
message,
level,
});
}
...
function logButtonClicked(buttonOrFunctionName, value = {}){
...
CrashLoggingUtils.recordBreadcrumb('btn_clicked', buttonOrFunctionName);
}
I’ve ensured that logButtonClicked()
only called once a time.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 22 (11 by maintainers)
https://github.com/getsentry/sentry-react-native/blob/a085ec4ef6e9506cca568d8841e1e1bc8dfb63a2/src/js/wrapper.ts#L108-L110 Messages get duplicated breadcrumbs because it doesn’t have an exception so the above condition gets skipped. Perhaps we should also delete all the breadcrumbs if there isnt an exception or the exception was handled, or
Found the same problem on Android Platform.
The next line fix it.
Maybe the reason is:
The sortedBreadcrumbs come from:
And the breadcrumbs come from:
could be, breadcrumbs are merged so it’s likely this