Skip to content
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

Starting app first time without network connection prevents events being pushed to Segment #901

Open
simon-westman-uba opened this issue Dec 1, 2023 · 2 comments
Labels
bug Something isn't working 🚧 Work In Progress

Comments

@simon-westman-uba
Copy link

simon-westman-uba commented Dec 1, 2023

I have noticed that if I install the app, but open it the very first time without any internet connection, so that the Segment SDK gets initialized without internet connection, no events will ever be pushed to Segment for that session, even after I regain internet connection again.
It is first after I restart the app that events are getting into Segment again, but only for the new session after the restart. The events that should have been created and pushed during the very first session that started without internet connection are lost for ever.

I can see these logs when running locally on iOS, which might be related to this issue:

Connection 13: received failure notification
Connection 13: failed to connect 1:50, reason 18 446 744 073 709 551 615
Connection 13: encountered error(1:50)
Task <9D428989-9D90-4661-8C10-18A09448F79B>.<2> HTTP load failed, 0/0 bytes (error code: 18 446 744 073 709 550 607 [1:50])
Task <9D428989-9D90-4661-8C10-18A09448F79B>.<2> finished with error [18 446 744 073 709 550 607] Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x280501ad0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, _NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 2ms using unknown from cache, _NSURLErrorNWPathKey=unsatisfied (No network route)}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <9D428989-9D90-4661-8C10-18A09448F79B>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <9D428989-9D90-4661-8C10-18A09448F79B>.<2>"
), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://cdn-settings.segment.com/v1/projects/Ui9dSUFlcu71Jnur5FOfyLWvI3xbIKwm/settings, NSErrorFailingURLKey=https://cdn-settings.segment.com/v1/projects/Ui9dSUFlcu71Jnur5FOfyLWvI3xbIKwm/settings, _kCFStreamErrorDomainKey=1}
'An internal error occurred: ', '{"type":3,"innerError":{},"statusCode":-1}'
'Could not receive settings from Segment. Device mode destinations will be ignored unless you specify default settings in the client config.'

The workaround I currently implemented for this is to check for internet connection before initializing the Segment SDK, and if it is the very first start of the app I do not initialize the SDK until internet connection is available through a network listener.
Any subsequent start of the app, after the Segment SDK has been initialized successfully with internet connection, does work as expected even without internet connection.

Also, I could not find anything about this in the documentation. If this was a known issue I would at least expect the documentation to state "Please make sure to have internet connection the first time you initialize the SDK".

  • analytics-react-native version:
"@react-native-async-storage/async-storage": "1.19.7",
"@segment/analytics-react-native": "2.17.0",
"@segment/sovran-react-native": "1.0.4",
  • Integrations versions (if used):
  • React Native version:
"react": "18.2.0",
"react-native": "0.71.11",
  • iOS or Android or both?:
    Both Android and iOS.
    Tested on Galaxy S21 5G with Android 13 and iPhone 11 with iOS 17.0.2

Steps to reproduce

  1. Install your app containing the Segment SDK (but don't open it)
  2. Enable airplane mode
  3. Open your app
  4. Wait for Segment SDK to be initialized in your code
  5. Disable airplane mode (and wait for phone to connect to internet)
  6. No events will be pushed to Segment

Expected behavior

I would expect to see events being pushed to Segment after step 5 since internet connection will be available again at that point.

Actual behavior

No events at all are being pushed to Segment.
I have to restart the app, and only any new events will be pushed after the restart.

@simon-westman-uba simon-westman-uba added the bug Something isn't working label Dec 1, 2023
@oscb
Copy link
Contributor

oscb commented Dec 4, 2023

@simon-westman-uba Hey Simon, this is super detailed and good report, I appreciate the time to test this out.

We already have an idea of what's going on, it's not an intended behavior. I put this up on our sprint to get this fixed

@simon-westman-uba
Copy link
Author

Thank you very much. I will keep an eye out for any upcoming updates and hope you will be able to solve this rather easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🚧 Work In Progress
Projects
None yet
Development

No branches or pull requests

2 participants