-
Notifications
You must be signed in to change notification settings - Fork 0
FFM-42656 Added ability to block uploads on networks in "Low Data Mode" #3
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: ffm/release/2.22.0
Are you sure you want to change the base?
FFM-42656 Added ability to block uploads on networks in "Low Data Mode" #3
Conversation
…in "Low Data Mode"
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.
My only feedback is to match the name of Apple's property on URLSession
. Otherwise this lgm!
internal struct DataUploadConditions { | ||
enum Blocker { | ||
case battery(level: Int, state: BatteryStatus.State) | ||
case lowDataModeOn |
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.
Precision here to match Apple's API might be a good idea. allowsConstrained...
or whatever URLRequest
calls 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.
Good idea 👍 I renamed this and a few others to better match allowsConstrainedNetworkAccess
case let .battery(level: level, state: state): | ||
return "🔋 Battery state is: \(state) (\(level)%)" | ||
case .lowDataModeOn: | ||
return "🛜 Network is in Low Data Mode and uploads are disabled for constrained networks" |
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.
Nice emoji! 😄
DatadogCore/Sources/Datadog.swift
Outdated
|
||
/// Allows uploads on constrained networks | ||
/// | ||
/// Defaults to `true` but can be overridden to block uploads on networks with "Low Data Mode" enabled |
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.
Are "block"ed uploads cancelled or deferred? Is that explicitly understood here, or do we want to specify?
/// Defaults to `true` but can be overridden to block uploads on networks with "Low Data Mode" enabled | |
/// Defaults to `true` but can be overridden to block uploads on networks with "Low Data Mode" enabled. |
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.
Blocked uploads are deferred and I updated this comment to make that more clear
…s "allowsConstrainedNetworkAccess"
What and why?
This PR adds a
constrainedNetworkUploadsDisabled
property which allows users to configure whether or not the SDK blocks uploads on constrained networks. This property defaults tofalse
to keep the existing behavior.How?
The SDK is already tracking whether or not the network is constrained in NWPathMonitorPublisher and has a mechanism for blocking uploads with DataUploadConditions.blockersForUpload(). This PR updates
blockersForUpload()
to check theisConstrained
network property. IfisConstrained
istrue
and theconstrainedNetworkUploadsDisabled
parameter istrue
, the upload is blocked.Review checklist
make api-surface
)