segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
361 stars 187 forks source link

New version of `@segment/analytics-react-native` requires old version of `@segment/sovran-react-native` #791

Closed mateusz1913 closed 1 year ago

mateusz1913 commented 1 year ago

πŸ‘‹ I tried new versions of Analytics and Sovran libraries after moving to monorepo and removing mandatory AsyncStorage dependency. It looks very promising, but after I updated dependencies I still get the error with lack of AsyncStorage dep linked.

It seems that Analytics library still requires old version of Sovran lib - even if I declare Sovran version 1.0.1 in my package.json, I still get the old version installed (with addition of AsyncStorage :/ )

There're 2 solutions: 1) (less flexible, makes sure that Sovran is pinned) bumping the direct Sovran dependency to the newest version 2) (more flexible) marking Sovran as a peer dependency and stating that current Analytics version requires Sovran >= 1.0.0

In the installation docs it's already listed to install it, so IMO there's no need to include it as a direct dependency, but it's up to you to decide (both solutions will work). If you want, I can make a PR, just let me know which solution you choose πŸ‘

Steps to reproduce

Install Analytics & Sovran dependency in the project without AsyncStorage dep

Expected behavior

App should not crash

Actual behavior

App crashes with following log

Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.

To fix this issue try these steps:

  β€’ Rebuild and restart the app.

  β€’ Run the packager with `--reset-cache` flag.

  β€’ If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app.

  β€’ If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest

If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-async-storage/async-storage/issues
, js engine: hermes
oscb commented 1 year ago

@mateusz1913 yea, sorry for the mess. npm version bumped the major version in Sovran unexpectedly when we moved the package to this monorepo.

It is fixed in v2.13.3

It is set to >1.0, just as you described in your 2nd choice.

Let me know if you bump into issues

mateusz1913 commented 1 year ago

Thx for a quick response!