-
Notifications
You must be signed in to change notification settings - Fork 160
Added ability to block uploads on networks with "Low Data Mode" enabled #2345
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
base: simaoseica/RUM-10424/add-new-data-upload-blocker
Are you sure you want to change the base?
Conversation
d84928c to
09fc6ec
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.
Thank you for the contribution @kmusco-foreflight 🙏
And for providing the use case. It makes sense to have this constraint on data uploads.
I’ve left a few comments regarding naming to help improve readability.
Additionally, I’ll change the base branch to include telemetry for this change so we can monitor it going forward.
|
|
||
| init(minBatteryLevel: Float = Constants.minBatteryLevel) { | ||
| /// Blocks uploads on networks with "Low Data Mode" enabled when set to `false`. Defaults to `true`. | ||
| let allowsConstrainedNetworkAccess: Bool |
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: This naming references the urlsessionconfiguration API and it seems not used in the logic below which can lead to confusion.
Can you rename the parameters around the API used (NWPath.isConstrained)?
Here it can be isNetworkAccessConstrained with the opposite value of it.
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.
The same for case allowsConstrainedNetworkAccessFalse. It could be case constrainedNetworkAccess
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.
I applied your naming suggestions 👍
|
@kmusco-foreflight |
Co-authored-by: Simao <[email protected]>
Co-authored-by: Simao <[email protected]>
@Valpertui Thank you for the follow up! I applied your suggestions |
What and why?
This PR allows us to configure the SDK to block uploads when connected to a network with "Low Data Mode" enabled.
Why?
A large number of our users rely on satellite internet with plans that charge based on data consumption. There are also scenarios where the connection has limited bandwidth and we only want to allow critical services to make network requests.
How?
This PR adds a
constrainedNetworkAccessEnabledparameter that can be passed toDatadog.init(). This name was chosen to match URLSession's allowsConstrainedNetworkAccess property which specifies if "Low Data Mode" is enabled. The property defaults totrueto maintain the current behavior and will disable uploads when set tofalse.The SDK is already tracking whether or not the network is constrained in NWPathMonitorPublisher with the
isConstrainedproperty, and has a mechanism for blocking uploads with DataUploadConditions.blockersForUpload(). This PR updatesblockersForUpload()to block uploads ifisConstrainedistrueand theallowsConstrainedNetworkAccessparameter isfalse.Review checklist
make api-surface)