Skip to content

Wire RemoteConfigManager refresh on first foreground and identity changes (off by default)#3450

Draft
tonidero wants to merge 2 commits into
toniricodiez/fall-back-across-blob-sourcesfrom
toniricodiez/wire-remote-config-manager-on-configure-and-login
Draft

Wire RemoteConfigManager refresh on first foreground and identity changes (off by default)#3450
tonidero wants to merge 2 commits into
toniricodiez/fall-back-across-blob-sourcesfrom
toniricodiez/wire-remote-config-manager-on-configure-and-login

Conversation

@tonidero
Copy link
Copy Markdown
Contributor

@tonidero tonidero commented May 7, 2026

Motivation

Final piece of the initial remote-config wiring: hook RemoteConfigManager into the SDK's actual lifecycle so the topic-fetch pipeline runs on real devices. The earlier PRs in the stack added the network scaffolding (#3435), the manager + topic fetcher (#3437), and the unreferenced-topic cleanup (#3439). None of them invoke the manager — this PR does, behind a developer-only build flag so production traffic is unaffected.

Description

  • Constructs RemoteConfigManager (with a TopicFetcher) inside PurchasesFactory and passes it into PurchasesOrchestrator.
  • Adds a private refreshRemoteConfigIfEnabled(appUserID) helper on PurchasesOrchestrator that calls remoteConfigManager.updateRemoteConfigIfNeeded(...). The helper is invoked from four places, each of which already runs only when something meaningful changed:
    • onAppForegrounded() — only when state.firstTimeInForeground is true (i.e. first foreground after Purchases.configure(...), exactly once per Purchases instance).
    • logIn(...) onSuccess — only reached when the new appUserID differs from the current one.
    • logOut(...) success branch — the appUserID has just been replaced with a fresh anonymous id.
    • switchUser(...) — the early-return on the same-id path filters out no-ops before we get here.
  • Every call site is gated on the new compile-time flag BuildConfig.ENABLE_REMOTE_CONFIG, fed from local.properties (ENABLE_REMOTE_CONFIG=true). Default: false, so disabling the flag is a no-op at every call site. Mirrors the existing ENABLE_EXTRA_REQUEST_LOGGING pattern.
  • Existing orchestrator tests are updated to pass a relaxed mock for the new constructor parameter. No tests are added for the flag-on path: BuildConfig.ENABLE_REMOTE_CONFIG is false in CI unit-test builds, so that branch is unreachable from JUnit. Same precedent as ENABLE_EXTRA_REQUEST_LOGGING. The on-path is exercised manually via purchase-tester against a localhost backend (combine with REMOTE_CONFIG_BASE_URL from Add network scaffolding for remote config endpoint #3435).

All new types remain internal. No public API surface change.

Stack

Checklist

  • Existing unit tests pass (orchestrator tests pick up the new relaxed mock; flag-on path is dev-only, tested manually).
  • Follow-up issues for purchases-ios / hybrids (deferred — feature is not yet wired to any consumer).

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.98%. Comparing base (4650c71) to head (bf72a8a).

Files with missing lines Patch % Lines
.../com/revenuecat/purchases/PurchasesOrchestrator.kt 85.71% 1 Missing ⚠️
Additional details and impacted files
@@                              Coverage Diff                               @@
##           toniricodiez/fall-back-across-blob-sources    #3450      +/-   ##
==============================================================================
+ Coverage                                       79.96%   79.98%   +0.02%     
==============================================================================
  Files                                             369      369              
  Lines                                           14937    14951      +14     
  Branches                                         2068     2069       +1     
==============================================================================
+ Hits                                            11944    11959      +15     
+ Misses                                           2154     2153       -1     
  Partials                                          839      839              

☔ 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.

@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from 191c8ba to 4e3d34d Compare May 8, 2026 08:36
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch 2 times, most recently from a00cdc7 to 8feda35 Compare May 8, 2026 10:37
@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from 4e3d34d to 61a48d6 Compare May 8, 2026 10:37
@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from 61a48d6 to 8c72036 Compare May 8, 2026 11:27
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch 2 times, most recently from 63a76b2 to dbef916 Compare May 8, 2026 12:09
@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from 8c72036 to b3336d9 Compare May 8, 2026 12:09
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from dbef916 to b206de3 Compare May 8, 2026 13:48
@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from b3336d9 to bc65ad3 Compare May 8, 2026 13:48
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from b206de3 to ed2adf1 Compare May 11, 2026 08:40
@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from bc65ad3 to 9705117 Compare May 11, 2026 08:40
@emerge-tools
Copy link
Copy Markdown

emerge-tools Bot commented May 11, 2026

📸 Snapshot Test

591 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility Paparazzi
com.revenuecat.testpurchasesuiandroidcompatibility.paparazzi
0 0 0 0 257 0 N/A
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 0 0 334 0 N/A

🛸 Powered by Emerge Tools

@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from 9705117 to fe02da5 Compare May 11, 2026 11:37
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch 2 times, most recently from 49cac31 to 87d6e93 Compare May 11, 2026 13:16
@tonidero tonidero force-pushed the toniricodiez/add-remote-config-topic-cleanup branch from fe02da5 to 6d89f70 Compare May 11, 2026 13:16
@tonidero tonidero changed the base branch from toniricodiez/add-remote-config-topic-cleanup to graphite-base/3450 May 11, 2026 13:23
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from 87d6e93 to e90d04d Compare May 11, 2026 13:23
@tonidero tonidero changed the base branch from graphite-base/3450 to toniricodiez/select-blob-source-by-priority-and-weight May 11, 2026 13:23
@tonidero tonidero force-pushed the toniricodiez/select-blob-source-by-priority-and-weight branch from 4e64b90 to ae9921c Compare May 11, 2026 14:05
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch 2 times, most recently from 61eade2 to a822583 Compare May 12, 2026 09:47
@tonidero tonidero force-pushed the toniricodiez/select-blob-source-by-priority-and-weight branch from ae9921c to 6eda732 Compare May 12, 2026 09:47
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from a822583 to 0ac6c71 Compare May 12, 2026 11:56
@tonidero tonidero force-pushed the toniricodiez/select-blob-source-by-priority-and-weight branch from 6eda732 to 4cd0810 Compare May 12, 2026 11:56
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch 2 times, most recently from 0ac6c71 to 8b87d1a Compare May 12, 2026 12:52
@tonidero tonidero force-pushed the toniricodiez/select-blob-source-by-priority-and-weight branch from 4cd0810 to a29029f Compare May 12, 2026 12:52
@tonidero tonidero changed the base branch from toniricodiez/select-blob-source-by-priority-and-weight to graphite-base/3450 May 12, 2026 14:01
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from 8b87d1a to dab20f7 Compare May 12, 2026 14:01
@tonidero tonidero changed the base branch from graphite-base/3450 to toniricodiez/fall-back-across-blob-sources May 12, 2026 14:01
@tonidero tonidero force-pushed the toniricodiez/fall-back-across-blob-sources branch from 47a4da1 to 91699e8 Compare May 13, 2026 08:49
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from dab20f7 to 87f1fd5 Compare May 13, 2026 08:49
@tonidero tonidero force-pushed the toniricodiez/fall-back-across-blob-sources branch from 91699e8 to d88dd12 Compare May 13, 2026 09:40
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch 3 times, most recently from 6e1a280 to c6390a4 Compare May 13, 2026 11:09
@tonidero tonidero force-pushed the toniricodiez/fall-back-across-blob-sources branch 2 times, most recently from b32ecf1 to 1b90c96 Compare May 13, 2026 11:52
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from c6390a4 to 98f0ddd Compare May 13, 2026 11:52
@tonidero tonidero force-pushed the toniricodiez/fall-back-across-blob-sources branch from 1b90c96 to 3049129 Compare May 13, 2026 13:23
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch 2 times, most recently from 4446628 to d08fa32 Compare May 13, 2026 15:19
@tonidero tonidero force-pushed the toniricodiez/fall-back-across-blob-sources branch from 3049129 to 6a85f55 Compare May 13, 2026 15:19
tonidero added 2 commits May 13, 2026 18:12
Follows the parent-branch change to RemoteConfigManager.updateRemoteConfigIfNeeded
which no longer takes an appUserID since the /v2/config endpoint is not
user-scoped. The four call sites (onAppForegrounded, logIn onSuccess,
logOut success branch, switchUser) become parameterless.
@tonidero tonidero force-pushed the toniricodiez/fall-back-across-blob-sources branch from 6a85f55 to 4650c71 Compare May 13, 2026 16:12
@tonidero tonidero force-pushed the toniricodiez/wire-remote-config-manager-on-configure-and-login branch from d08fa32 to bf72a8a Compare May 13, 2026 16:12
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.

1 participant