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

fix(analytics): Fix accessing the Analytics category from RxAmplify or Kotlin Facade #2944

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

mattcreaser
Copy link
Member

  • PR title and description conform to Pull Request guidelines.

Issue #, if available:
#2943

Description of changes:
The RxAmplify and the Kotlin Facade version of Amplify both instantiate their own versions of the Analytics (and Logging) category. Neither do that for other categories.

This is a problem because they delegate to the main Amplify for all other actions, including adding plugins. Therefore, the Analytics plugin gets added to the "main" instance of the Category (e.g. the one owned by com.amplifyframework.core.Amplify) while subsequent API calls get routed to the "new" instance of the category (owned by com.amplifyframework.rx.RxAmplify or com.amplifyframework.kotlin.core.Amplify). Such API calls always result in a IllegalStateException because there is no plugin added to that instance of the category.

The fix is simple, the two facade classes should reference the Analytics/Logging instance owned by the main Amplify class, just as they do for all other categories.

This fixes the crash. Now it does not matter what combination of Amplify/RxAmplify/Kotlin Facade is used, all calls work as expected.

How did you test these changes?

  • Built app with RxAmplify & Kotlin Facade and verified crash is resolved by using the updated libraries in this PR.

Documentation update required?

  • No
  • Yes (Please include a PR link for the documentation update)

General Checklist

  • Added Unit Tests
  • Added Integration Tests
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mattcreaser mattcreaser requested a review from a team as a code owner November 7, 2024 16:30
@mattcreaser mattcreaser enabled auto-merge (squash) November 12, 2024 15:30
@mattcreaser mattcreaser merged commit 7199b84 into main Nov 15, 2024
4 checks passed
@mattcreaser mattcreaser deleted the mattcreaser/rx-analytics-fix branch November 15, 2024 15:52
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.

2 participants