Skip to content

Adds support for switching between 2 API keys to PaywallsTester#2213

Merged
JayShortway merged 8 commits into
mainfrom
pw2-support-multiple-projects-paywall-tester
Mar 4, 2025
Merged

Adds support for switching between 2 API keys to PaywallsTester#2213
JayShortway merged 8 commits into
mainfrom
pw2-support-multiple-projects-paywall-tester

Conversation

@JayShortway

@JayShortway JayShortway commented Mar 4, 2025

Copy link
Copy Markdown
Member

This adds the ability to switch between 2 projects (API keys) to PaywallsTester.

Motivation

To be able to effectively test new paywall templates on Android. See MON-970 for more context and details.

Description

I wanted to do this in the most pragmatic way possible without it being hacky, since we might be building other ways of previewing paywalls in the near future. Since the goal is to switch between 2 specific projects, I chose to support exactly that. Other options would have been to allow logging in with your account like RC Mobile, or adding your own API key in a text field, but that would have meant adding persistence. Let me know if you disagree or have other ideas! 🙏

  • Constants.kt now has GOOGLE_API_KEY_A and GOOGLE_API_KEY_B. The app uses A by default. During development you can leave B empty, as it is not used unless you attempt to switch API keys in the UI.
  • There's a new "Switch API key" button on the App Info screen.
  • The published version of PaywallsTester will include the "Paywalls V2 Alpha" (as before) and "Official Paywalls V2 Template Repo" keys.
  • The $PAYWALLS_V2_TEMPLATE_REPO_API_KEY environment variable already exists on Circle CI for our update-template-previews update job.

Closes MON-970.

@JayShortway JayShortway requested a review from a team March 4, 2025 14:31
@JayShortway JayShortway marked this pull request as ready for review March 4, 2025 14:31
@emerge-tools

emerge-tools Bot commented Mar 4, 2025

Copy link
Copy Markdown

📸 Snapshot Test

4 modified, 241 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 4 0 241 0 ✅ Approved

🛸 Powered by Emerge Tools

@codecov

codecov Bot commented Mar 4, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.47%. Comparing base (8bcebc9) to head (e4d24b2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2213   +/-   ##
=======================================
  Coverage   80.47%   80.47%           
=======================================
  Files         277      277           
  Lines        9461     9461           
  Branches     1336     1336           
=======================================
  Hits         7614     7614           
  Misses       1287     1287           
  Partials      560      560           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tonidero tonidero 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.

TBH, I wonder if it might be better to just persist the last API key used. Mostly since I think the A/B API keys distinction are very easy to forget... But then again I don't want to block testing so I'm ok merging this for now.

}

@Composable
private fun ApiKeyButton(label: String, apiKey: String, onClick: (String) -> Unit) {

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.

One alternative would be to just default to the "embedded" API key, and then add a text view to introduce a new API key to switch to that (with a reset button I guess). Might provide more flexibility while still working out of the box, but we should probably persist that API key as you said... Which honestly, I think it would be fine to do in SharedPreferences or something like that...

Having said that, I don't have a strong opinion, so I'm ok with your solution! Just a bit weird to have an A and B API key without a name 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea I agree, good points. I'll merge this for now to unblock testing, but I'll think about what we can do to make this less confusing.

@JayShortway JayShortway enabled auto-merge (squash) March 4, 2025 16:38
@JayShortway JayShortway merged commit 0188643 into main Mar 4, 2025
@JayShortway JayShortway deleted the pw2-support-multiple-projects-paywall-tester branch March 4, 2025 17:10
tonidero added a commit that referenced this pull request Mar 6, 2025
**This is an automatic release.**

## RevenueCat SDK
### ✨ New Features
* Add `hasPaywall` property to `Offering` (#2212) via Antonio Pallares
(@ajpallares)
### 🐞 Bugfixes
* Fix empty options in NoActive subscriptions screen (#2168) via Cesar
de la Vega (@vegaro)

## RevenueCatUI SDK
### Customer Center
#### ✨ New Features
* Create `CustomerCenterListener` (#2199) via Cesar de la Vega (@vegaro)
#### 🐞 Bugfixes
* Reload Customer Center after a successful restore (#2203) via Cesar de
la Vega (@vegaro)
* Fixes CustomerCenter state not refreshing when reopening (#2202) via
Cesar de la Vega (@vegaro)

### 🔄 Other Changes
* Improves PaywallsTester multi-API-key support (#2218) via JayShortway
(@JayShortway)
* [EXTERNAL] Bump Emerge Gradle Plugin and Snaphsots version (#2211) via
@runningcode (#2217) via JayShortway (@JayShortway)
* [AUTOMATIC][Paywalls V2] Updates Compose previews of all templates
(#2207) via RevenueCat Git Bot (@RCGitBot)
* [Paywalls V2] Enables template previews again (#2215) via JayShortway
(@JayShortway)
* Adds support for switching between 2 API keys to PaywallsTester
(#2213) via JayShortway (@JayShortway)
* Adds a `LocalPreviewImageLoader` `CompositionLocal`. (#2201) via
JayShortway (@JayShortway)
* Logs from RevenueCatUI are now tagged with `[Purchases]` too. (#2206)
via JayShortway (@JayShortway)
* [Paywalls V2] Ignores template previews for now. (#2209) via
JayShortway (@JayShortway)
* [Paywalls V2] Some more template previews optimizations (#2208) via
JayShortway (@JayShortway)
* chore: Delete key from customer center survey event (#2204) via
Facundo Menzella (@facumenzella)
* [Paywalls V2] Extract ImageLoader to use a single one (#2146) via Toni
Rico (@tonidero)
* [Paywalls V2] Adds progress indicator to buttons (#2198) via
JayShortway (@JayShortway)
* Avoids triggering "unscheduled" workflows when triggering workflows
via the CircleCI API (#2200) via JayShortway (@JayShortway)
* [Paywalls V2] Adds a note on publishing to the missing paywall error.
(#2193) via JayShortway (@JayShortway)
* Adds X-Kotlin-Version header. (#2197) via JayShortway (@JayShortway)
* [Paywalls V2] Adds docs on ignored arguments for Paywalls V2 in more
places. (#2195) via JayShortway (@JayShortway)
* chore: Add backend integration test for events (#2189) via Facundo
Menzella (@facumenzella)
* [Paywalls V2] Adds CI job to update template previews (#2192) via
JayShortway (@JayShortway)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Cesar de la Vega <cesarvegaro@gmail.com>
Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
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.

2 participants