Skip to content

Conversation

tonidero
Copy link
Contributor

Description

We were storing data in the default shared preferences file, which could potentially be used by the app developer. That's a bad practice and it's more difficult to do some things with. This PR changes to a separate shared preferences file and adds a migration, so we migrate all RC data from the previous shared preferences file to the new one. We won't delete the data from the previous shared preferences file, but that will remain unused.

@@ -30,12 +28,6 @@ internal class DiagnosticsSynchronizer(

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
const val MAX_EVENTS_TO_SYNC_PER_REQUEST: Int = 200

fun initializeSharedPreferences(context: Context): SharedPreferences =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unused, so I took the chance to delete it. I think it might be worth moving all the shared preferences handling to the new SharedPreferencesManager... but didn't want to overcomplicate this PR.

@tonidero tonidero marked this pull request as ready for review August 21, 2025 13:51
@tonidero tonidero requested a review from a team August 21, 2025 13:51
editor.putFloat(key, value)
true
}
is Set<*> -> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the only types of data that we store in the shared preferences files (we actually don't use booleans/ints/floats... but I thought it might be good to add just in case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea agreed!

Copy link

codecov bot commented Aug 21, 2025

Codecov Report

❌ Patch coverage is 84.61538% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.47%. Comparing base (68c2560) to head (84029c8).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...uecat/purchases/common/SharedPreferencesManager.kt 84.37% 8 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2621      +/-   ##
==========================================
+ Coverage   78.41%   78.47%   +0.05%     
==========================================
  Files         301      302       +1     
  Lines       11241    11303      +62     
  Branches     1561     1571      +10     
==========================================
+ Hits         8815     8870      +55     
- Misses       1740     1745       +5     
- Partials      686      688       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice to have this! Just some suggestions.

editor.putFloat(key, value)
true
}
is Set<*> -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea agreed!

@tonidero tonidero requested a review from JayShortway August 22, 2025 09:28
Copy link
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes! Just one more suggestion haha

@tonidero tonidero enabled auto-merge August 22, 2025 13:18
@tonidero tonidero added this pull request to the merge queue Aug 22, 2025
Merged via the queue into main with commit 13b752e Aug 22, 2025
21 checks passed
@tonidero tonidero deleted the migrate-shared-preferences-to-separate-file branch August 22, 2025 13:48
github-merge-queue bot pushed a commit that referenced this pull request Aug 25, 2025
### Description
We migrated to a new shared preferences file in #2621, but we didn't
update the integration tests to use the new file. This fixes those
integration tests.
tonidero added a commit that referenced this pull request Aug 25, 2025
### Description
We were storing data in the default shared preferences file, which could
potentially be used by the app developer. That's a bad practice and it's
more difficult to do some things with. This PR changes to a separate
shared preferences file and adds a migration, so we migrate all RC data
from the previous shared preferences file to the new one. We won't
delete the data from the previous shared preferences file, but that will
remain unused.
tonidero added a commit that referenced this pull request Aug 25, 2025
### Description
We migrated to a new shared preferences file in #2621, but we didn't
update the integration tests to use the new file. This fixes those
integration tests.
tonidero pushed a commit that referenced this pull request Aug 25, 2025
**This is an automatic release.**

## RevenueCat SDK
### 🐞 Bugfixes
* Fix embedded font family loading (#2624) via Toni Rico (@tonidero)

### 🔄 Other Changes
* Fix integration tests shared preferences file (#2629) via Toni Rico
(@tonidero)
* Migrate RC SharedPreferences data to a separate file (#2621) via Toni
Rico (@tonidero)
* Add annotation experimental library to debug builds (#2617) via Toni
Rico (@tonidero)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
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