sentry-dart
sentry-dart copied to clipboard
Add a way to remove an attachment from the scope
There should be a way to remove an attachment, which was previously added, from the scope. This prevents that the same attachment is sent for multiple crash reports. It's also the last missing piece needed for finishing https://github.com/getsentry/sentry-dart/pull/576
That depends on https://github.com/getsentry/sentry-dart/issues/510 by the way.
Discussed solutions are making it available on beforeSend via hints or adding a boolean to the add attachment method, sendOnlyOnce or a new method called removeAttachment(...), we're going to discuss it.
If the goal is to capture a single event with an attachment the solution is to capture an event with a local scope.
@ueman does https://docs.sentry.io/platforms/dart/enriching-events/scopes/#local-scopes help to add an attachment to a single scope?
I think so. That would make it possible to do
Sentry.captureException(
exception,
withScope: (scope) {
scope.addAttachment(ScreenshotAttachment());
},
);
#1136 is going to unblock this via hints
You can do https://github.com/getsentry/sentry-dart/issues/711#issuecomment-1106119591 or https://github.com/getsentry/sentry-dart/blob/fa16e53b4bb6d070a637610acb48612b82700d3c/dart/lib/src/scope.dart#L211-L213