Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced debugRevenueCatOverlay(): new SwiftUI debug overlay #2567

Conversation

NachoSoto
Copy link
Contributor

@NachoSoto NachoSoto commented May 30, 2023

simulator_screenshot_DBF551B9-3BA8-440D-9B3F-16DB1D47A0A7

@NachoSoto NachoSoto added the pr:feat A new feature label May 30, 2023
@NachoSoto NachoSoto requested a review from a team May 30, 2023 23:46
@NachoSoto NachoSoto force-pushed the nacho/sdk-3152-purchase-tester-automatically-included-in-debug-mode branch from e8693e3 to 8826d43 Compare May 31, 2023 18:22
var body: some View {
NavigationStack(path: self.$model.navigationPath) {
DebugSummaryView(model: self.model)
.navigationDestination(for: DebugViewPath.self) { path in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New SwiftUI navigation API 🤓

@NachoSoto NachoSoto force-pushed the nacho/sdk-3152-purchase-tester-automatically-included-in-debug-mode branch from 8826d43 to 906b823 Compare May 31, 2023 22:28
@NachoSoto NachoSoto changed the title [WIP] Introduced debugRevenueCatOverlay(): new SwiftUI debug overlay Introduced debugRevenueCatOverlay(): new SwiftUI debug overlay May 31, 2023
@NachoSoto NachoSoto marked this pull request as ready for review May 31, 2023 22:30
@NachoSoto NachoSoto force-pushed the nacho/sdk-3152-purchase-tester-automatically-included-in-debug-mode branch 3 times, most recently from 252a673 to 2ce85f4 Compare June 2, 2023 19:19
@NachoSoto
Copy link
Contributor Author

This is ready.

@codecov
Copy link

codecov bot commented Jun 2, 2023

Codecov Report

Merging #2567 (fdc749b) into main (4b14260) will decrease coverage by 1.74%.
The diff coverage is 1.41%.

@@            Coverage Diff             @@
##             main    #2567      +/-   ##
==========================================
- Coverage   88.07%   86.34%   -1.74%     
==========================================
  Files         201      205       +4     
  Lines       14031    14312     +281     
==========================================
- Hits        12358    12357       -1     
- Misses       1673     1955     +282     
Impacted Files Coverage Δ
Sources/Purchasing/Purchases/Purchases.swift 76.69% <0.00%> (-0.88%) ⬇️
Sources/Support/DebugUI/DebugContentViews.swift 0.00% <0.00%> (ø)
Sources/Support/DebugUI/DebugView.swift 0.00% <0.00%> (ø)
Sources/Support/DebugUI/DebugViewModel.swift 0.00% <0.00%> (ø)
...s/Support/DebugUI/DebugViewSheetPresentation.swift 0.00% <0.00%> (ø)
Sources/Misc/SystemInfo.swift 98.31% <100.00%> (+0.04%) ⬆️

... and 2 files with indirect coverage changes

@NachoSoto NachoSoto force-pushed the nacho/sdk-3152-purchase-tester-automatically-included-in-debug-mode branch 2 times, most recently from 17b242c to a53aef5 Compare June 6, 2023 21:21
@NachoSoto NachoSoto force-pushed the nacho/sdk-3152-purchase-tester-automatically-included-in-debug-mode branch from b3b4015 to 04f0358 Compare June 7, 2023 01:07
@NachoSoto NachoSoto force-pushed the nacho/sdk-3152-purchase-tester-automatically-included-in-debug-mode branch from 04f0358 to fdc749b Compare June 7, 2023 01:10
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

I'm not very familiar with iOS UI development but looks great to me! Will approve it tentatively.

//
// Created by Nacho Soto on 5/30/23.

#if DEBUG && os(iOS) && swift(>=5.8)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we support macos as well? It probably shouldn't be a bottom sheet though... We can think about it and add in a future PR though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah we'd have to make it slightly different cause that API isn't available there 👍🏻


@MainActor
@available(iOS 16.0, *)
final class DebugViewModel: ObservableObject {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we exclude these new files from coverage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to write UI snapshot tests for this since it's a public facing feature :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done: #2630

@ViewBuilder content: @escaping () -> some View
) -> some View {
self
.sheet(isPresented: isPresented) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with iOS UI development 😅 . So just to check, if isPresented is false, is the view created? I just have some concerns of loading the debug view model triggering some extra operations in the SDK... I don't think it should be a big issue right now though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point let me check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed :) it doesn't load until it's visible.

@NachoSoto NachoSoto merged commit 3b53f24 into main Jun 7, 2023
@NachoSoto NachoSoto deleted the nacho/sdk-3152-purchase-tester-automatically-included-in-debug-mode branch June 7, 2023 16:16
NachoSoto added a commit that referenced this pull request Jun 13, 2023
NachoSoto added a commit that referenced this pull request Jun 13, 2023
NachoSoto pushed a commit that referenced this pull request Jun 13, 2023
**This is an automatic release.**

### New Features
* New `DebugViewController`: UIKit counterpart for SwiftUI's
`debugRevenueCatOverlay` (#2631) via NachoSoto (@NachoSoto)
* Created `PaywallExtensions`: `StoreView` and `SubscriptionStoreView`
overloads for `Offering` (#2593) via NachoSoto (@NachoSoto)
* Introduced `debugRevenueCatOverlay()`: new SwiftUI debug overlay
(#2567) via NachoSoto (@NachoSoto)
### Bugfixes
* Removed `preventPurchasePopupCallFromTriggeringCacheRefresh`, update
caches on `willEnterForeground` (#2623) via NachoSoto (@NachoSoto)
* Fixed `Catalyst` build with `Xcode 15 beta 1` (#2586) via NachoSoto
(@NachoSoto)
### Dependency Updates
* Bump danger from 9.3.0 to 9.3.1 (#2592) via dependabot[bot]
(@dependabot[bot])
### Other Changes
* `StoreTransaction`: added new `Storefront` to API testers (#2634) via
NachoSoto (@NachoSoto)
* `DebugView`: added snapshot tests (#2630) via NachoSoto (@NachoSoto)
* `verifyNoUnfinishedTransactions`/`verifyUnfinishedTransaction`: added
missing `#file` parameter (#2625) via NachoSoto (@NachoSoto)
* `PostReceiptDataOperation`: clean up cache key (#2628) via NachoSoto
(@NachoSoto)
* `PurchasesOrchestrator`: also get `Storefront` from SK1 (#2629) via
NachoSoto (@NachoSoto)
* `CI`: disable iOS 17 for now (#2627) via NachoSoto (@NachoSoto)
* `Tests`: fixed crash on iOS 13 (#2624) via NachoSoto (@NachoSoto)
* `StoreTransaction`: read `Storefront` from `StoreKit.Transaction`
(#2611) via NachoSoto (@NachoSoto)
* `StoreKitConfigTestCase`/`BaseStoreKitIntegrationTests`: also clear
transactions after every test (#2616) via NachoSoto (@NachoSoto)
* `ErrorCode.networkError`: improved description (#2610) via NachoSoto
(@NachoSoto)
* `PurchaseTester`: make CI job always point to current version (#2622)
via NachoSoto (@NachoSoto)
* Improved `finishAllUnfinishedTransactions` (#2615) via NachoSoto
(@NachoSoto)
* `StoreKitConfigTestCase`: improved `waitForStoreKitTestIfNeeded`
(#2614) via NachoSoto (@NachoSoto)
* `StoreKitConfigTestCase`: set `continueAfterFailure` to `false`
(#2617) via NachoSoto (@NachoSoto)
* `PaywallExtensions`: fixed compilation (#2613) via NachoSoto
(@NachoSoto)
* `CI`: added `iOS 17` job (#2591) via NachoSoto (@NachoSoto)
* `Encodable.jsonEncodedData`: fixed tests on iOS 17 due to inconsistent
key ordering (#2607) via NachoSoto (@NachoSoto)
* `debugRevenueCatOverlay`: added ability to display new
`SubscriptionStoreView` (#2595) via NachoSoto (@NachoSoto)
* Refactor: extracted all log strings (#2600) via NachoSoto (@NachoSoto)
* Changed tests to work around `URL` decoding differences in `iOS 17`
(#2605) via NachoSoto (@NachoSoto)
* Removed unnecessary `Strings.trimmedOrError` (#2601) via NachoSoto
(@NachoSoto)
* Fixed test compilation with `Xcode 15` (#2602) via NachoSoto
(@NachoSoto)
* Tests: added `iOS 17` snapshots (#2603) via NachoSoto (@NachoSoto)
* `StoreProductDiscount`: added `description` (#2604) via NachoSoto
(@NachoSoto)
* `debugRevenueCatOverlay` improvements (#2594) via NachoSoto
(@NachoSoto)
* `Xcode 15`: fixed all documentation warnings (#2596) via NachoSoto
(@NachoSoto)
* `StoreKitObserverModeIntegrationTests`: fixed and disabled SK2
`testPurchaseInDevicePostsReceipt` (#2589) via NachoSoto (@NachoSoto)
* `StoreKit2TransactionListener`: added log when receiving
`Transactions.Updates` (#2588) via NachoSoto (@NachoSoto)
* `Dictionary.MergeStrategy`: simplify implementation (#2587) via
NachoSoto (@NachoSoto)
* `Configuration.Builder`: fixed doc reference (#2583) via NachoSoto
(@NachoSoto)
* `APITesters`: available since iOS 11 (#2581) via NachoSoto
(@NachoSoto)
tonidero added a commit to RevenueCat/purchases-android that referenced this pull request Aug 3, 2023
### Description
Same as was added in iOS in
RevenueCat/purchases-ios#2567. Includes the
changes in #1180

This PR adds a debug view in the Android SDK and uses it in the
`MagicWeatherCompose` sample app. This debug view is meant to be a
Jetpack compose function, even though later we might add convenience
accessors for people not using jetpack compose. It's extracted to a
different module so it can be published separately from the main SDK. It
also attempts to keep all the code in the debug source set, to try to
include as few code in the release variants.

The provided API is currently 2 composable functions:
- `DebugRevenueCatDebugScreen`: This is the actual UI that is part of
the debug screen. In case devs want to use it in a custom UI.
- `DebugRevenueCatBottomSheet`: This will display the debug screen as a
bottom sheet. This is what's used in the `MagicWeatherCompose` sample
app.

##### TODO
- [ ] Allow visualizing offerings in debug menu
- [ ] Support non-composable apps by wrapping it into a fragment, with
utility launch methods.
- [ ] Split library for debug and release
- [ ] Add UI tests
- [ ] Support publishing the new module as different libraries for debug
and release.
- [ ] Remove module local substitution once debugview library has been
published


https://github.com/RevenueCat/purchases-android/assets/808417/b3a953e4-b96f-4b06-8294-d2bcf9b66c7d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:feat A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants