-
Notifications
You must be signed in to change notification settings - Fork 204
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
Support changing Event's api key in OnErrorCallback #928
Conversation
82154c8
to
4a4a47e
Compare
Android notifier sizes
Generated by 🚫 Danger |
4a4a47e
to
b04549d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, but broadly looks good.
Can you create an integration branch and target that so we can combine the session and NDK work too?
bugsnag-android-core/src/main/java/com/bugsnag/android/FileStore.java
Outdated
Show resolved
Hide resolved
bugsnag-android-core/src/main/java/com/bugsnag/android/ImmutableConfig.kt
Outdated
Show resolved
Hide resolved
init { | ||
config.autoTrackSessions = false | ||
config.addOnError(OnErrorCallback { event -> | ||
event.apiKey = "0000111122223333aaaabbbbcccc9999" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: might be worth adding another scenario where one client instance generates an event with a specific API key (without overriding it in OnErrorCallback, just using its default config) and dumps it on the file system and then a new client instance is created with a different API key, and that new client instance ends up uploading the error and uses the right (initial) API key.
Goal
Supports changing the apiKey for an
Event
via anOnErrorCallback
. This is achieved by encoding the apiKey in the filename if an event is cached on disk, and reading this apiKey from the filename at the point of delivery.Changeset
DeliveryDelegate
uses the apiKey set onEvent
rather thanConfiguration
, which covers delivery of handled errorserrorApiHeaders()
now takes theapiKey
as a parameter when generating HTTP headers so thatBugsnag-Api-Key
is not always set toconfig.apiKey
flushEventFile()
reads the apiKey from the filename if present, and otherwise falls back to theconfig.apiKey
value if the cached file is in the legacy formatapiKey
in the filenameThis changeset does not address altering the API key for NDK errors, which will be handled separately.
Testing
Added an E2E test for a handled error (which should be delivered without writing to disk) and an unhandled error (which requires writing to disk). Additionally unit tests have been added to cover filename generation for each event, and reading the apiKey from the filename.