Skip to content

[PW-128] Redact text in V2 paywalls while eligibility checks are pending#6775

Merged
facumenzella merged 7 commits into
mainfrom
worktree-kind-toasting-pebble
Jun 5, 2026
Merged

[PW-128] Redact text in V2 paywalls while eligibility checks are pending#6775
facumenzella merged 7 commits into
mainfrom
worktree-kind-toasting-pebble

Conversation

@facumenzella

@facumenzella facumenzella commented May 12, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a new isPaywallLoading SwiftUI environment key (PaywallLoadingKey.swift)
  • PaywallsV2View sets it to true until both introOfferEligibilityContext and paywallPromoOfferCache finish their async eligibility checks
  • TextComponentView reads the key and applies .redacted(reason: .placeholder) to NonLocalizedMarkdownText, hiding text content while preserving layout, images, and buttons
  • Snapshot tests added for both loading (true) and loaded (false) states
Header Header
pw_loaded_debug pw_loading_debug

🤖 Generated with Claude Code


Note

Low Risk
UI-only placeholder redaction on text during async eligibility; no purchase, auth, or backend changes.

Overview
Adds a Paywalls V2 loading state driven by a new SwiftUI environment value isPaywallLoading, set from PaywallsV2View while intro-offer and promo-offer eligibility work is still in flight.

TextComponentView applies .redacted(reason: .placeholder) when that flag is true so copy does not flash wrong prices or intro messaging before eligibility resolves; layout and non-text UI are unchanged.

DEBUG adds paywallLoadingOverride for previews/tests, treats preview runs as already loaded so snapshots are not stuck redacted, and adds snapshot coverage plus “(Loading)” paywall previews.

Reviewed by Cursor Bugbot for commit f3f702c. Bugbot is set up for automated code reviews on this repo. Configure here.

@emerge-tools

emerge-tools Bot commented May 12, 2026

Copy link
Copy Markdown

📸 Snapshot Test

5 added, 269 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
RevenueCat
com.revenuecat.PaywallsTester
5 0 0 0 269 0 ✅ Approved

🛸 Powered by Emerge Tools

@facumenzella facumenzella marked this pull request as ready for review May 15, 2026 19:09
@facumenzella facumenzella requested review from a team as code owners May 15, 2026 19:09

@MonikaMateska MonikaMateska left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The PR looks great, thanks for implementing it! 🙏
One thing worth exploring in the future: we could eagerly prefetch intro/promo offer eligibility right after offerings and products are resolved. That said, I'd still ship the current text reduction as-is while we figure that out.
On the configuration side, not urgent, just something to keep in mind, we could add a simple introEligibilityLoadingBehavior flag to PaywallViewConfiguration with two cases: .waitForResult (current default, shows a spinner) and .optimistic
(shows full-price text immediately, upgrades to the intro offer text once eligibility resolves)

@JZDesign JZDesign left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great work!

Considering the engine team's goal of keeping a sound testing framework that will aid in preventing UI regressions, the impact this has to the emerge snapshot test suite isn't ideal.

Please update the changed emerge snapshots to set isPaywallLoading to false, so that we can still use emerge the way we currently do. Spitballing here… one way is to add a constructor that is only available in debug builds, explicitly marked for use in previews, that we can provide a shouldShowLoadingState function, then in the normal initializer, we set the value ourselves then pass that in.

Another way would be to use the functions we have to tell if the sdk is being run for previews and to act on that (though this has less flexibility)

@facumenzella facumenzella requested a review from JZDesign May 27, 2026 10:36
@facumenzella

Copy link
Copy Markdown
Member Author

@JZDesign I've reverted the preview changes and added new ones for reference.

facumenzella and others added 7 commits June 5, 2026 16:10
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
In Xcode Previews and Emerge runs the async eligibility check never
completes, leaving didFinishEligibilityCheck=false forever and causing
all text to render as redacted. Default didFinishEligibilityCheck to
true (finished) in those environments via ProcessInfo.isRunningForPreviews,
which covers both XCODE_RUNNING_FOR_PREVIEWS and EMERGE_IS_RUNNING_FOR_SNAPSHOTS.

Adds two new TextComponentView preview entries ("Default (Loading)" and
"Detected Platform (Loading)") that explicitly inject isPaywallLoading=true
so Emerge captures dedicated loading-state snapshots alongside the
existing loaded-state ones.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a DEBUG-only `paywallLoadingOverride` environment key that lets
preview callers force `isPaywallLoading` on `PaywallsV2View` from
outside, bypassing the internal `didFinishEligibilityCheck` state.

Duplicates three representative preview entries (Template1, ButtonWithFooter,
PackageVisibility) with `.environment(\.paywallLoadingOverride, true)` so
emerge captures a redacted loading-state snapshot alongside each existing
loaded-state snapshot.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@facumenzella facumenzella force-pushed the worktree-kind-toasting-pebble branch from ba8d6bd to f3f702c Compare June 5, 2026 14:12
@facumenzella facumenzella enabled auto-merge (squash) June 5, 2026 14:12
@facumenzella facumenzella merged commit a4f2969 into main Jun 5, 2026
18 of 20 checks passed
@facumenzella facumenzella deleted the worktree-kind-toasting-pebble branch June 5, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants