Skip to content

Conversation

@kmusco-foreflight
Copy link

@kmusco-foreflight kmusco-foreflight commented Jun 17, 2025

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 constrainedNetworkAccessEnabled parameter that can be passed to Datadog.init(). This name was chosen to match URLSession's allowsConstrainedNetworkAccess property which specifies if "Low Data Mode" is enabled. The property defaults to true to maintain the current behavior and will disable uploads when set to false.

The SDK is already tracking whether or not the network is constrained in NWPathMonitorPublisher with the isConstrained property, and has a mechanism for blocking uploads with DataUploadConditions.blockersForUpload(). This PR updates blockersForUpload() to block uploads if isConstrained is true and the allowsConstrainedNetworkAccess parameter is false.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes
  • Add Objective-C interface for public APIs (see our guidelines (internal) and run make api-surface)

@kmusco-foreflight kmusco-foreflight requested review from a team as code owners June 17, 2025 19:18
@kmusco-foreflight kmusco-foreflight force-pushed the block-uploads-on-constrained-networks branch from d84928c to 09fc6ec Compare June 18, 2025 17:17
Copy link
Contributor

@simaoseica-dd simaoseica-dd left a 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
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Author

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 👍

@simaoseica-dd simaoseica-dd changed the base branch from develop to simaoseica/RUM-10424/add-new-data-upload-blocker June 19, 2025 13:56
@Valpertui
Copy link
Contributor

@kmusco-foreflight
Hello, I wanted to see if you had time to do review the comments we provided on this pull request.
Thanks

@kmusco-foreflight
Copy link
Author

@kmusco-foreflight Hello, I wanted to see if you had time to do review the comments we provided on this pull request. Thanks

@Valpertui Thank you for the follow up! I applied your suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants