[Feat] Add HTTP header OneSignal-Install-Id#2072
Merged
Conversation
OneSignal-Install-Id is a UUIDv4 locally generated on the device and added to as an HTTP Header to all calls made to OneSignal's backend. This allows the OneSignal's backend know where traffic is coming from, no matter if the SubscriptionId or OneSignalId changes or isn't available yet. State for the new installId is encapsulated in a new InstallIdService class, where it handles generating the id and persisting it. Tests were also added to ensure the persisting behavior works as expected.
The motivation for this was we recently added a new HTTP header, OneSignal-Install-Id, and wanted to confirm it is being sent, however this will help if we need to debug any other headers. This also makes a small improvement to separate out the debug logic from production logic.
a942c88 to
6ed8b4d
Compare
Added "Got Response =" to the beginning of each line were we got a response. This exact wording was picked since it is the same number of characters as "Request Sent = ", this way it lines up in the logs, making them easier to read.
6ed8b4d to
37487e0
Compare
Merged
This was referenced May 16, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
One Line Summary
Add HTTP header
OneSignal-Install-Id, a persistent id. Allows OneSignal's backend to know where traffic is coming from.Details
OneSignal-Install-Idis a UUIDv4 locally generated on the device and added to as an HTTP Header to all calls made to OneSignal's backend.State for the new
installIdis encapsulated in a newInstallIdServiceclass, where it handles generating the id and persisting it. Tests were also added to ensure the persisting behavior works as expected.Motivation
Allows the OneSignal's backend know where traffic is coming from, no matter if the
SubscriptionIdorOneSignalIdchanges or isn't available yet.Scope
OneSignal-Install-IdHTTP header added to all network calls.Testing
Unit testing
Added
InstallIdServiceTestto test the newInstallIdServiceclass.Manual testing
Tested on an Android 6 device, ensuring the new
OneSignal-Install-Idheader is sent. Restarted app to ensure the value stays the same as well.Affected code checklist
Checklist
Overview
Testing
Final pass
This change is