feat(paywalls): decode top-level state declaration map#6989
Merged
Conversation
Member
Author
This was referenced Jun 14, 2026
8f8b112 to
9fbd9f3
Compare
0fe842c to
fd6e0ad
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b5a745b. Configure here.
b5a745b to
ca873a9
Compare
alexrepty
approved these changes
Jun 16, 2026
alexrepty
left a comment
Contributor
There was a problem hiding this comment.
One nitpick, and one idea: since we're decoding defensively and guarding for errors, missing values and such, should we also guard against type mismatch?
I think it's fine without these things though, so please feel free to disregard.
…low (#7002) * fix(paywalls): skip workflow fetch for offerings with no mapped workflow Under workflows-enabled, presenting a paywall for an offering with only a legacy paywall (no workflow on the backend) fired a workflow fetch that 404'd and surfaced an error state instead of rendering the legacy paywall. Gate the workflow path on the offeringId -> workflowId map: no mapping renders the legacy paywall with no network call. Offerings are fetched first so the map is populated before the decision, avoiding a cold-cache downgrade of real workflow offerings. Port of RevenueCat/purchases-android#3598 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Gate legacy-vs-workflow on offering.paywall, not the workflows map Aligns with the merged purchases-android #3598: route an offering to the workflows endpoint only when `offering.paywall == nil` (the durable marker of a non-legacy paywall), instead of checking the offeringId -> workflowId map. The map check was an intermediate approach the Android PR abandoned: an offering not yet migrated to workflows is missing from the map, which would wrongly fall back to legacy for a real workflow offering. Reading offering.paywall is authoritative and removes the timing dependency on the map. Drops the cachedWorkflowId plumbing (no longer needed; Purchases.workflow already resolves the workflow id with an offering-id fallback) and the now-unused warning string. Applies the same gate to the synchronous cache seed for consistency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5c8032b to
6977334
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Checklist
purchases-androidand hybridsMotivation
First PR in the state-driven paywalls Phase 0 stack (iOS, PWENG-56). Adds the top-level
statemap so the SDK can decode declared state keys (type + default) that seed the presentation-session store in later PRs. Strictly additive and decode-only.Spec: https://github.com/RevenueCat/sdk-specs/tree/main/openspec/changes/add-paywall-component-state
Description
Decodes the optional top-level
statedeclaration onPaywallComponentsDataintoStateDeclarationvalues. Decoding is resilient: a malformed entry is dropped individually and a malformed map is ignored, so it can never fail the whole paywall. All types are@_spi(Internal).Stack: 1/5 → base
main.Note
Low Risk
Additive, internal SPI decoding with no runtime state-store or UI behavior yet; malformed state is dropped without failing paywall loads.
Overview
Adds decode-only support for the optional top-level
statemap on paywall component JSON, as the first step toward state-driven paywalls.Introduces
PaywallComponent.StateDeclaration(wiretype+defaultas existingConditionValue, plusnormalizedDefaultValuefor double keys with integral JSON literals).PaywallComponentsDatagainsstateDeclarations, mapped from JSON keystate, with resilient decoding: malformed entries are skipped, a bad map is ignored, and empty/missing/all-failed maps becomenilso paywall decode never fails on state. Encoding round-trips the map. New unit tests cover declarations andPaywallComponentsDataedge cases.Package.resolvedalso picks up additional SPM pins (e.g. snapshot/preview tooling).Reviewed by Cursor Bugbot for commit 6977334. Bugbot is set up for automated code reviews on this repo. Configure here.