Skip to content

fix: refactor initialization sequence to guarantee readiness before event upload #765

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

Merged
merged 3 commits into from
Feb 23, 2023

Conversation

oscb
Copy link
Contributor

@oscb oscb commented Feb 22, 2023

Beforehand init and isStorageReady would operate asynchronously completely on their own, the second one marking the client as ready for processing events. This was however brittle, as context updates from plugins (IDFA, AdvertisingID) could make the client think it was ready before it would actually load all the relevant information (context, events from previous sessions, settings).

This refactors the sequence of initialization so that: storage is always restored first, then settings, context and callbacks are setup (in any order between them), then the client is marked ready.

  • isReady replaces onContextLoaded for readiness checks. isReady is a better guarantee as it makes sure it has a full context loaded (either from restoration or from fetching), whereas before it would only check for context from the device get.
  • Fixing info.ts generator for eslint rules

@oscb oscb marked this pull request as ready for review February 22, 2023 22:44
@oscb oscb merged commit af21c24 into master Feb 23, 2023
@oscb oscb deleted the oscb/initRefactor branch February 23, 2023 21:32
oscb pushed a commit that referenced this pull request Feb 28, 2023
## [@segment/analytics-react-native-v2.13.1](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-v2.13.0...@segment/analytics-react-native-v2.13.1) (2023-02-28)

### Bug Fixes

* refactor initialization sequence to guarantee readiness before event upload ([#765](#765)) ([af21c24](af21c24))
@oscb
Copy link
Contributor Author

oscb commented Feb 28, 2023

🎉 This PR is included in version @segment/analytics-react-native-v2.13.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@oscb oscb added the released label Feb 28, 2023
oscb pushed a commit that referenced this pull request Feb 28, 2023
## [@segment/analytics-react-native-plugin-destination-filters-v1.0.1](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-destination-filters-v1.0.0...@segment/analytics-react-native-plugin-destination-filters-v1.0.1) (2023-02-28)

### Bug Fixes

* refactor initialization sequence to guarantee readiness before event upload ([#765](#765)) ([af21c24](af21c24))
@oscb
Copy link
Contributor Author

oscb commented Feb 28, 2023

🎉 This PR is included in version @segment/analytics-react-native-plugin-destination-filters-v1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants