Skip to content

Send customerInfo and per-product isSubscribed to paywalls - #532

Open
ianrumac wants to merge 4 commits into
developfrom
ir/sweet-pasteur-74799f
Open

ianrumac wants to merge 4 commits into
developfrom
ir/sweet-pasteur-74799f

Conversation

@ianrumac

@ianrumac ianrumac commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Changes in this pull request

Brings Android in line with iOS on what paywalls can read about the user's purchases.

  • device.customerInfo: the merged customer info (subscriptions, non-subscription purchases, entitlements, userId) is added to the paywall page's template variables. Keys are camelCase, matching iOS. The SDK's shared encoder renames keys to snake_case, so CustomerInfo.toTemplateParams() encodes without that strategy. The existing toParams() used for events is unchanged.
    • It's added only to the variables sent to the page, not to the device attributes. Those also go to the enrichment request and audience filters, so their payload is unchanged.
    • It's an empty object until the customer info has loaded.
  • Per-product isSubscribed: each Play Store product variable gets isSubscribed (e.g. products.primary.isSubscribed), set in TemplateLogic. The active ids come from completed Google Play purchases (new internal ReceiptManager.completedPurchaseFullProductIds, full ids with base plan; pending purchases are left out) plus active subscriptions in the merged customer info. Unlike iOS, this also counts web checkout and purchase-controller subscriptions.
    • A purchase matches a product with the same subscription id. If both name a base plan, the base plans must also match. A product on sw-auto, or a purchase recorded without its base plan, matches any base plan of that subscription.
  • Template logging: TemplateLogic and PaywallMessageHandler no longer log the templates or the scripts that carry them, only their size. They hold user attributes and now customer info, and logs reach SuperwallDelegate.handleLog.
  • New VariablesFactory.activePurchasedProductIds(), with a default empty implementation so existing fakes keep compiling. It's added to superwall.api.
  • Version bumped to 2.11.0 (main and develop were both at 2.10.2), with a CHANGELOG entry.

Checklist

  • All unit tests pass. (2,103 tests, :superwall:testDebugUnitTest, and the unit-tests CI job)
  • All UI tests pass. (instrumentation-tests CI jobs)
  • Demo project builds and runs.
  • I added/updated tests or detailed why my change isn't tested. (TemplateLogicTest: isSubscribed matching, camelCase customerInfo reaching the page, empty placeholder. ReceiptManagerBasePlanTest: paid vs pending purchases. TemplateLogPrivacyTest: templates reach the page but no delegate log.)
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run ktlint in the main directory and fixed any issues. (Not run: ktlint couldn't be installed in the environment this was built in.)
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

🤖 Generated with Claude Code

https://claude.ai/code/session_01CR7gAnqM9DKHUgsEkJsvWP

Paywalls can read device.customerInfo with camelCase keys, as the iOS
SDK sends it. It's added only to the paywall page's variables, not to
the device attributes, which also go to enrichment and audience filters.

Each Play Store product variable gets isSubscribed, from the active
Google Play purchases and the merged customer info. A purchase matches a
product with the same subscription id, and the same base plan when both
name one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CR7gAnqM9DKHUgsEkJsvWP
Its strict VariablesFactory mock has no answer for the new method.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CR7gAnqM9DKHUgsEkJsvWP
@maple-review-bot

This comment has been minimized.

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 inline notes from Maple's review. The score and summary are in the review comment above.

// to enrichment and audience filters, so it isn't added to them.
templateDeviceDictionary =
templateDeviceDictionary +
("customerInfo" to customerInfoManager.customerInfo.value.toTemplateParams()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

customerInfo reaches delegate logs with the full purchase history

F1 · Warning · security · PII-01

Adding the customer record here also adds it to TemplateLogic's plaintext templatesString log and PaywallMessageHandler's logged scripts. This exposes userId, transaction IDs and purchase history through SuperwallDelegate.handleLog, even when console logging is disabled (Logger.kt:70,92). The payload is not confined to the paywall page.

Remove or redact the template payload and encoded scripts from these logs before adding customer info; log only message type and counts.
🤖 Prompt to fix with an AI agent
In `superwall/src/main/java/com/superwall/sdk/dependencies/DependencyContainer.kt:1521`: `customerInfo` reaches delegate logs with the full purchase history.

Adding the customer record here also adds it to `TemplateLogic`'s plaintext `templatesString` log and `PaywallMessageHandler`'s logged scripts. This exposes `userId`, transaction IDs and purchase history through `SuperwallDelegate.handleLog`, even when console logging is disabled (`Logger.kt:70,92`). The payload is not confined to the paywall page.

Suggested fix: Remove or redact the template payload and encoded scripts from these logs before adding customer info; log only message type and counts.

Verify the problem exists at that location before changing it, and keep the fix to those lines.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 721f736. TemplateLogic and PaywallMessageHandler no longer log the templates or the scripts that carry them, only their size. That covers the "Template Logic" log, both "Posting Message" logs, the didLoadWebView script log and "Error Evaluating JS". TemplateLogPrivacyTest checks that a value from the user attributes and customer info reaches the page but no log passed to SuperwallDelegate.handleLog. It fails against the old logging.


Generated by Claude Code

@maple-review-bot

This comment has been minimized.

…scribed

The templates hold user attributes and now customer info, and logs reach
SuperwallDelegate.handleLog, so TemplateLogic and PaywallMessageHandler
log only their size.

isSubscribed counted pending Google Play purchases, which aren't paid
for. ReceiptManager now keeps the full ids of completed purchases only,
internal rather than public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CR7gAnqM9DKHUgsEkJsvWP
@maple-review-bot

maple-review-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 10/10 · safe to merge. Targeted regression tests cover paid/pending receipts and template log redaction; tests were inspected, not executed.
no findings · tests covered · risk high

Adds customer info and per-product subscription state to paywall templates. The follow-up excludes pending purchases and removes template contents from delegate logs; the changed code is safe to merge.

721f736 · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants