fix(rewards): patch invalidateSubscriptionCache#30279
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The RewardsController manages state for:
The cache invalidation changes could affect data freshness after user actions (claiming rewards, applying bonus codes, opting into campaigns, logging out). If cache is not properly invalidated, stale data could be shown in the UI. E2E tests for these flows should verify the behavior is correct end-to-end. Per tag descriptions: SmokePerps requires SmokeWalletPlatform and SmokeConfirmations; SmokePredictions requires SmokeWalletPlatform and SmokeConfirmations; SmokeSwap requires SmokeConfirmations. Performance Test Selection: |
|



Description
invalidateSubscriptionCacheto take an options object: { subscriptionId, seasonId?, campaignId? }.-- subscriptionId + seasonId: season-scoped caches only.
-- subscriptionId + campaignId: campaign-scoped caches only.
-- subscriptionId only: all subscription-related rewards API caches.
Changelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes cache invalidation semantics in
RewardsController, including new season/campaign scoping and narrower invalidations after reward claims/bonus codes, which could leave stale UI data or trigger extra refetches if callers rely on prior broad clears.Overview
Refactors
RewardsController.invalidateSubscriptionCacheto accept an options object ({ subscriptionId, seasonId?, campaignId? }) and centralizes composite-key generation/matching so invalidation can be targeted to season-scoped vs campaign-scoped caches, plus subscription-keyed caches (e.g. benefits/VIP/off-device accounts) only when doing a full subscription clear.Separates responsibilities between auth/account reset and cache clearing:
invalidateSubscriptionAndAccountsnow removes subscription metadata, resets linked account state, and removes the session token without clearing rewards API caches likevipDashboard, whilelogout,optOut, account linking flows, auth-retry, and balance update paths are updated to use the new invalidation API.Narrows post-mutation invalidation:
claimRewardandapplyBonusCodenow invalidate onlypointsEventsfor the subscription (with updated logging), and the test suite is updated/expanded to reflect the new scoping rules and typed cache-key deletion behavior.Reviewed by Cursor Bugbot for commit 79d25a2. Bugbot is set up for automated code reviews on this repo. Configure here.