New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
beforeSend callback is not called for cached events after going from offline mode to online mode #2034
Comments
hi thanks for raising this, we'll have a look |
The On Flutter event is sent through the iOS & Android native SDKs. To my knowledge, we will drop an event if it fails to send due to a lack of connection. Maybe @philipphofmann has some insight into how iOS is handling connection failures? In any case, calling |
That is intended behavior. SDKs only call the beforeSend callback once. It's meant to modify the event before the SDKs send it to Sentry. Users don't have to worry about their apps being online or offline. SDKs ensure to send events to sentry once apps are online again. Why do you expect the SDK to call beforeSend again when the device is online again @hgadalrab? |
@philipphofmann Due to this issue #1753, I had so many cached events which are also too old. I couldn't find another way to drop these events except for this callback, which, I think, should be called before sending to Sentry for the second time. |
I believe you can have a one-time code to empty the cache directory from within your app code (you can check file times). The linked issue should be fixed since v8. |
The linked issue is fixed in v8, yes, but the fix doesn't apply to the old events. So, if I had 100 events, and updated to v8, the 100 events will be kept in the cache. If there is no other solution provided by Sentry, I will have to do this, but I expected a better solution e.g, the beforeSend callback or providing access to the existing events. |
Unfortunately I believe this is the only solution we can currently offer currently |
@buenaflor, can't we do some simple logic to check for old events in that cache and delete them? I guess more people could run into that problem. |
@buenaflor Although it would be good to have a callback every time the event is sent to Sentry, but it would also be nice to have what you suggested. @philipphofmann |
Would you have an idea of the size of scope of this? @denrase |
Platform
Flutter Mobile
Obfuscation
Disabled
Debug Info
Disabled
Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.3, on macOS 14.4.1 23E224 darwin-arm64, locale en-AT)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] Connected device (5 available)
! Error: Browsing on the local area network for M’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• No issues found!
Version
8.1.0
Steps to Reproduce
---- Code ----
await SentryFlutter.init((options) {
options
..dsn = dsn
..addIntegration(LoggingIntegration(minEventLevel: Level.WARNING))
..beforeSend = ((event, hint) {
print('Sending event with id ${event.eventId} and message: ${event.message?.formatted}');
return event;
});
});
Timer.periodic(const Duration(seconds: 5), (timer) {
logger.warning('Sending event At ${DateTime.now()}');
});
Expected Result
beforeSend is called before the request is sent to Sentry
Actual Result
beforeSend is not called and the request is sent to Sentry
Are you willing to submit a PR?
None
The text was updated successfully, but these errors were encountered: