segmentio / analytics-swift

The hassle-free way to add Segment analytics to your Swift app (iOS/tvOS/watchOS/macOS/Linux).
MIT License
92 stars 81 forks source link

Infinite loop of network failures contacting https://api.segment.io/v1/b #317

Closed xmollv closed 3 months ago

xmollv commented 3 months ago

Describe the bug

We're recently seeing an infinite loop contacting this endpoint on our console logs: https://api.segment.io/v1/b

It seems to have started when we updated Segment to 1.5.8.

Task <279A17CF-BC6B-47E8-85CF-BD283BF13069>.<4127> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x3031d2a30 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_NSURLErrorBlockedTrackerFailureKey=true, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, dns, uses wifi}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalUploadTask <279A17CF-BC6B-47E8-85CF-BD283BF13069>.<4127>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalUploadTask <279A17CF-BC6B-47E8-85CF-BD283BF13069>.<4127>"
), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://api.segment.io/v1/b, NSErrorFailingURLKey=https://api.segment.io/v1/b, _kCFStreamErrorDomainKey=1}

Obviously, I'm not offline. Everything else works, and If I roll back to 1.5.7, this error is no longer printed to the console.

To Reproduce

Expected behavior

Screenshots

Platform (please complete the following information):

Additional context

tristan-warner-smith commented 3 months ago

We're also seeing the same behaviour described above.

jorgefrazaocosta commented 3 months ago

Same with us.

sergiymomot commented 3 months ago

We see this error, which might be related:

nw_endpoint_handler_path_change [C1 cdn-settings.segment.com:443 waiting parent-flow (satisfied (Path is satisfied), interface: en0[802.11], uses wifi)] blocked tracker

This most likely happens because Segment's SDK lists cdn-settings.segment.com and api.segment.io in their PrivacyInfo.xcprivacy manifest under NSPrivacyTrackingDomains section

According to Apple:

NSPrivacyTrackingDomains An array of strings that lists the internet domains your app or third-party SDK connects to that engage in tracking. If the user has not granted tracking permission through the App Tracking Transparency framework, network requests to these domains fail and your app receives an error. If you set NSPrivacyTracking to true then you need to provide at least one internet domain in NSPrivacyTrackingDomains; otherwise, you can provide zero or more domains.

Once I granted access to track the user, this error went away

@bsneed I think unless you are specifying NSPrivacyTracking as true, meaning Segment tracks the user, you don't need to list these domains

bsneed commented 3 months ago

Thanks for all this info and the catch guys. What should this be? It seems a little confusing to me.

We're not technically tracking anything that would require ATT, but could if a customer opts-in to it by including the IDFA plugin.

I'm not sure what to do here yet (other than get it fixed somehow).

bsneed commented 3 months ago

https://developer.apple.com/app-store/user-privacy-and-data-use/

According to that, IDFV doesn't need it, so seems like we should remove it entirely. If a customer opts in to IDFA, they'd handle it via their own app privacy info I think. Happy to hear your thoughts @sergiymomot @vlvs @xmollv @tristan-warner-smith before I make any changes.

sergiymomot commented 3 months ago

I think you can omit privacy domains since, as you said, you are not tracking the user but provide a platform to send track events - what data is being sent inside these event payloads is outside of Segment's control If a customer uses the IDFA plugin, they would be in charge of specifying it in their Privacy Manifest Due to the Plugin system, you cannot account for all possible use-cases apps will implement concerning user privacy and identity tracking guidelines

sergiymomot commented 3 months ago

Same goes for 3rd party integrations - it's AppsFlyer's responsibility to declare what data they use for tracking even if SDK is not used directly but through a destination plugin

bsneed commented 3 months ago

Thanks for the feedback @sergiymomot; We'll move forward with that. Release coming shortly.

xmollv commented 3 months ago

@bsneed I've updated to 1.5.9 and it seems to have solved the issue! Thanks, feel free to close this ticket once it looks good on your end 👍🏼

jorgefrazaocosta commented 3 months ago

I can also confirm this is fixed! Thank you 🙌

bsneed commented 3 months ago

Thanks everyone for your assistance! 🙌

hulsizer commented 1 month ago

Hello, we are experiencing this issue as well but we are currently on 1.5.11. We had 1 user this morning make 20k requests which resulted in an errors being sent back to Sentry. We just recently upgraded to analytics-swift from analytics-ios, due to the privacy tracking from Apple.

Is there an approach we should be taking to prevent these errors from looping?

Screenshot 2024-05-22 at 3 34 17 PM

bsneed commented 1 month ago

@hulsizer please reach out to friends@segment.com for support.