Skip to content

Commit

Permalink
Merge branch 'main' into create-feedback-survey-event
Browse files Browse the repository at this point in the history
  • Loading branch information
vegaro committed Dec 4, 2024
2 parents 6ef3144 + 658782b commit 440c861
Show file tree
Hide file tree
Showing 36 changed files with 948 additions and 158 deletions.
27 changes: 21 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ aliases:
release-tags: &release-tags
filters:
tags:
ignore:
ignore:
- /^.*-SNAPSHOT/
- /^.*-customercenter.alpha.*/
branches:
Expand Down Expand Up @@ -1282,6 +1282,19 @@ jobs:
name: Submit Purchase Tester
command: bundle exec fastlane deploy_purchase_tester dry_run:<< parameters.dry_run >>

emerge_purchases_ui_snapshot_tests:
executor:
name: macos-executor
steps:
- checkout
- setup-git-credentials
- trust-github-key
- install-dependencies
- update-spm-installation-commit
- run:
name: Build Paywalls Tester
command: bundle exec fastlane build_paywalls_tester_for_emerge

deploy-to-spm:
docker:
- image: cimg/base:stable
Expand Down Expand Up @@ -1335,13 +1348,14 @@ workflows:
- pod-lib-lint
- run-revenuecat-ui-ios-17
- run-revenuecat-ui-ios-18
- emerge_purchases_ui_snapshot_tests

create-tag:
when:
and:
- not:
equal: [scheduled_pipeline, << pipeline.trigger_source >>]
- matches:
- matches:
pattern: "^release/.*$"
value: << pipeline.git.branch >>
jobs:
Expand Down Expand Up @@ -1426,21 +1440,21 @@ workflows:
- docs-deploy

# To trigger tests manually, log into circleCI, select the project, a branch, and then click "Trigger Pipeline"
# in the top right hand corner of the screen. In the modal that appears, set the following parameter fields
# in the top right hand corner of the screen. In the modal that appears, set the following parameter fields
# and click "Trigger Pipeline" to begin the pipeline:
# - Parameter Type: string
# - Name: action
# - Value: run-manual-tests
all-tests:
when:
or:
- matches:
- matches:
pattern: "^release/.*$"
value: << pipeline.git.branch >>
- equal:
- "run-manual-tests"
- << pipeline.parameters.action >>
- equal:
- equal:
- "run-from-github-comments"
- << pipeline.parameters.GHA_Meta >>
jobs:
Expand Down Expand Up @@ -1475,4 +1489,5 @@ workflows:
- api-tests
- deploy-purchase-tester:
dry_run: true

- emerge_purchases_ui_snapshot_tests

3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-emerge (0.10.6)
faraday (~> 1.1)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
ffi (1.17.0-arm64-darwin)
Expand Down Expand Up @@ -371,6 +373,7 @@ DEPENDENCIES
danger
fastlane
fastlane-plugin-create_xcframework!
fastlane-plugin-emerge
fastlane-plugin-revenuecat_internal!
nokogiri
rest-client
Expand Down
33 changes: 33 additions & 0 deletions RevenueCat.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
35272E2226D0048D00F22C3B /* HTTPClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37E353CBE9CF2572A72A347F /* HTTPClientTests.swift */; };
352B7D7927BD919B002A47DD /* DangerousSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 352B7D7827BD919B002A47DD /* DangerousSettings.swift */; };
35316DAA2BD14BFD00E4A970 /* MockDiagnosticsSynchronizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35316DA82BD14BFD00E4A970 /* MockDiagnosticsSynchronizer.swift */; };
3531DF882CFE138D00D454BF /* ManageSubscriptionsButtonsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3531DF872CFE138800D454BF /* ManageSubscriptionsButtonsView.swift */; };
353756522C382BC700A1B8D6 /* PreferredLocalesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 353756512C382BC700A1B8D6 /* PreferredLocalesProvider.swift */; };
353756652C382C2800A1B8D6 /* CustomerCenterConfigTestData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 353756532C382C2800A1B8D6 /* CustomerCenterConfigTestData.swift */; };
353756662C382C2800A1B8D6 /* CustomerCenterError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 353756542C382C2800A1B8D6 /* CustomerCenterError.swift */; };
Expand Down Expand Up @@ -313,6 +314,7 @@
35D83300262FAD8000E60AC5 /* ETagManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35D832FF262FAD8000E60AC5 /* ETagManagerTests.swift */; };
35D8330A262FBA9A00E60AC5 /* MockUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37E357D16038F07915D7825D /* MockUserDefaults.swift */; };
35D83312262FBD4200E60AC5 /* MockETagManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35D83311262FBD4200E60AC5 /* MockETagManager.swift */; };
35DE0DB62CEF9E8F00EB83E9 /* SubscriptionInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35DE0DB52CEF9E8C00EB83E9 /* SubscriptionInfo.swift */; };
35E840CC270FB70D00899AE2 /* ManageSubscriptionsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35E840C5270FB47C00899AE2 /* ManageSubscriptionsHelper.swift */; };
35E840CE2710E2EB00899AE2 /* MockManageSubscriptionsHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35E840CD2710E2EB00899AE2 /* MockManageSubscriptionsHelper.swift */; };
35F249CA2C493D970058993A /* LoadPromotionalOfferUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35F249C92C493D970058993A /* LoadPromotionalOfferUseCase.swift */; };
Expand Down Expand Up @@ -1182,6 +1184,13 @@
remoteGlobalIDString = 2DEAC2D926EFE46E006914ED;
remoteInfo = UnitTestsHostApp;
};
4D6F4BE82CFE2FAB00353AF6 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 2DD5008F2C519EB4009C19B7 /* PaywallsTester.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = FA29FBA82CCAA79800DA1976;
remoteInfo = PaywallsTesterTests;
};
4F6BEE082A27B02400CD9322 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 352629F51F7C4B9100C04F2C /* Project object */;
Expand Down Expand Up @@ -1511,6 +1520,7 @@
352B7D7827BD919B002A47DD /* DangerousSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DangerousSettings.swift; sourceTree = "<group>"; };
3530C18822653E8F00D6DF52 /* AdSupport.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AdSupport.framework; path = System/Library/Frameworks/AdSupport.framework; sourceTree = SDKROOT; };
35316DA82BD14BFD00E4A970 /* MockDiagnosticsSynchronizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockDiagnosticsSynchronizer.swift; sourceTree = "<group>"; };
3531DF872CFE138800D454BF /* ManageSubscriptionsButtonsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageSubscriptionsButtonsView.swift; sourceTree = "<group>"; };
353756512C382BC700A1B8D6 /* PreferredLocalesProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferredLocalesProvider.swift; sourceTree = "<group>"; };
353756532C382C2800A1B8D6 /* CustomerCenterConfigTestData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomerCenterConfigTestData.swift; sourceTree = "<group>"; };
353756542C382C2800A1B8D6 /* CustomerCenterError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomerCenterError.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1576,6 +1586,7 @@
35D832F3262E606500E60AC5 /* HTTPResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPResponse.swift; sourceTree = "<group>"; };
35D832FF262FAD8000E60AC5 /* ETagManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ETagManagerTests.swift; sourceTree = "<group>"; };
35D83311262FBD4200E60AC5 /* MockETagManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockETagManager.swift; sourceTree = "<group>"; };
35DE0DB52CEF9E8C00EB83E9 /* SubscriptionInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionInfo.swift; sourceTree = "<group>"; };
35E1CE1F26E022C20008560A /* TrialOrIntroPriceEligibilityCheckerSK1Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrialOrIntroPriceEligibilityCheckerSK1Tests.swift; sourceTree = "<group>"; };
35E840C5270FB47C00899AE2 /* ManageSubscriptionsHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManageSubscriptionsHelper.swift; sourceTree = "<group>"; };
35E840CD2710E2EB00899AE2 /* MockManageSubscriptionsHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockManageSubscriptionsHelper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1643,6 +1654,7 @@
4D6ABB0D2AF13FB100BB2A08 /* StoreEnvironment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoreEnvironment.swift; sourceTree = "<group>"; };
4D6ABB0F2AF13FBD00BB2A08 /* SK2AppTransaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SK2AppTransaction.swift; sourceTree = "<group>"; };
4D6F4BCF2CF69DE300353AF6 /* ForegroundColorScheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForegroundColorScheme.swift; sourceTree = "<group>"; };
4D6F4BE52CFE2FAB00353AF6 /* PaywallsTesterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaywallsTesterTests.swift; sourceTree = "<group>"; };
4D7A3E272B85729E00ABDE67 /* PurchasesOrchestratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchasesOrchestratorTests.swift; sourceTree = "<group>"; };
4DBC30952B1DFA97001D33C7 /* StoreKitVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoreKitVersion.swift; sourceTree = "<group>"; };
4DBF1F352B4D572400D52354 /* LocalReceiptFetcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LocalReceiptFetcher.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3011,6 +3023,7 @@
children = (
2DD500402C519EB4009C19B7 /* ci_scripts */,
2DD5008E2C519EB4009C19B7 /* PaywallsTester */,
4D6F4BE62CFE2FAB00353AF6 /* PaywallsTesterTests */,
2DD5008F2C519EB4009C19B7 /* PaywallsTester.xcodeproj */,
2DD500902C519EB4009C19B7 /* PaywallsTester.xcworkspace */,
2DD500912C519EB4009C19B7 /* Postprocessor.sh */,
Expand Down Expand Up @@ -3166,6 +3179,7 @@
isa = PBXGroup;
children = (
2DD500F82C519EB4009C19B7 /* PaywallsTester.app */,
4D6F4BE92CFE2FAB00353AF6 /* PaywallsTesterTests.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -3528,6 +3542,7 @@
353756602C382C2800A1B8D6 /* Views */ = {
isa = PBXGroup;
children = (
3531DF872CFE138800D454BF /* ManageSubscriptionsButtonsView.swift */,
2D2AFE8E2C6A9D8700D1B0B4 /* CompatibilityContentUnavailableView.swift */,
2C4C36122C6FBA8B00AE959B /* CompatibilityTopBarTrailing.swift */,
3537565B2C382C2800A1B8D6 /* CustomerCenterView.swift */,
Expand Down Expand Up @@ -3894,6 +3909,14 @@
path = BasicTypes;
sourceTree = "<group>";
};
4D6F4BE62CFE2FAB00353AF6 /* PaywallsTesterTests */ = {
isa = PBXGroup;
children = (
4D6F4BE52CFE2FAB00353AF6 /* PaywallsTesterTests.swift */,
);
path = PaywallsTesterTests;
sourceTree = "<group>";
};
4F1428A52A4A1330006CD196 /* Test Data */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4872,6 +4895,7 @@
B3A36AAC26BC76230059EDEA /* Identity */ = {
isa = PBXGroup;
children = (
35DE0DB52CEF9E8C00EB83E9 /* SubscriptionInfo.swift */,
A56F9AB026990E9200AFC48F /* CustomerInfo.swift */,
57F3C10429B7B22E0004FD7E /* CustomerInfo+ActiveDates.swift */,
4F15B4A02A6774C9005BEFE8 /* CustomerInfo+NonSubscriptions.swift */,
Expand Down Expand Up @@ -5436,6 +5460,13 @@
remoteRef = 2DD501092C519EB4009C19B7 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
4D6F4BE92CFE2FAB00353AF6 /* PaywallsTesterTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = PaywallsTesterTests.xctest;
remoteRef = 4D6F4BE82CFE2FAB00353AF6 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

/* Begin PBXResourcesBuildPhase section */
Expand Down Expand Up @@ -5847,6 +5878,7 @@
FD43D2FC2C41864000077235 /* TimeInterval+Extensions.swift in Sources */,
4F7DBFBD2A1E986C00A2F511 /* StoreKit2TransactionFetcher.swift in Sources */,
5766AB4728401B8400FA6091 /* PackageType.swift in Sources */,
35DE0DB62CEF9E8F00EB83E9 /* SubscriptionInfo.swift in Sources */,
B3F3E8DA277158FE0047A5B9 /* DNSChecker.swift in Sources */,
1EB697862CD0ED0B003000FC /* WebPurchaseRedemptionResult.swift in Sources */,
A525BF4B26C320D100C354C4 /* SubscriberAttributesManager.swift in Sources */,
Expand Down Expand Up @@ -6564,6 +6596,7 @@
77BA1AB32CCBB6EE009BF0EA /* RootView.swift in Sources */,
887A606C2C1D037000E1A461 /* Constants.swift in Sources */,
887A60BF2C1D037000E1A461 /* PaywallViewController.swift in Sources */,
3531DF882CFE138D00D454BF /* ManageSubscriptionsButtonsView.swift in Sources */,
2CC791552CC0452100FBE120 /* PurchaseButtonComponentViewModel.swift in Sources */,
2CC791562CC0452100FBE120 /* PackageComponentView.swift in Sources */,
2CC791592CC0452100FBE120 /* PurchaseButtonComponentView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import SwiftUI
class ManageSubscriptionsViewModel: ObservableObject {

let screen: CustomerCenterConfigData.Screen
let paths: [CustomerCenterConfigData.HelpPath]

@Published
var showRestoreAlert: Bool = false
Expand Down Expand Up @@ -66,6 +67,7 @@ class ManageSubscriptionsViewModel: ObservableObject {
purchasesProvider: ManageSubscriptionsPurchaseType = ManageSubscriptionPurchases(),
loadPromotionalOfferUseCase: LoadPromotionalOfferUseCaseType? = nil) {
self.screen = screen
self.paths = screen.filteredPaths
self.purchasesProvider = purchasesProvider
self.customerCenterActionHandler = customerCenterActionHandler
self.loadPromotionalOfferUseCase = loadPromotionalOfferUseCase ?? LoadPromotionalOfferUseCase()
Expand All @@ -77,6 +79,7 @@ class ManageSubscriptionsViewModel: ObservableObject {
customerCenterActionHandler: CustomerCenterActionHandler?,
refundRequestStatus: RefundRequestStatus? = nil) {
self.screen = screen
self.paths = screen.filteredPaths
self.purchaseInformation = purchaseInformation
self.purchasesProvider = ManageSubscriptionPurchases()
self.refundRequestStatus = refundRequestStatus
Expand Down Expand Up @@ -262,4 +265,18 @@ private final class ManageSubscriptionPurchases: ManageSubscriptionsPurchaseType

}

private extension CustomerCenterConfigData.Screen {

var filteredPaths: [CustomerCenterConfigData.HelpPath] {
return self.paths.filter { path in
#if targetEnvironment(macCatalyst)
return path.type == .refundRequest
#else
return path.type != .unknown
#endif
}
}

}

#endif
8 changes: 7 additions & 1 deletion RevenueCatUI/CustomerCenter/Views/CustomerCenterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ private extension CustomerCenterView {
WrongPlatformView()
}
} else {
NoSubscriptionsView(configuration: configuration)
if let screen = configuration.screens[.noActive] {
ManageSubscriptionsView(screen: screen,
customerCenterActionHandler: viewModel.customerCenterActionHandler)
} else {
// Fallback with a restore button
NoSubscriptionsView(configuration: configuration)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// Copyright RevenueCat Inc. All Rights Reserved.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://opensource.org/licenses/MIT
//
// ManageSubscriptionsButtonsView.swift
//
// Created by Cesar de la Vega on 2/12/24.

import Foundation
import RevenueCat
import SwiftUI

#if os(iOS)

@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
struct ManageSubscriptionsButtonsView: View {

@ObservedObject
var viewModel: ManageSubscriptionsViewModel
@Binding
var loadingPath: CustomerCenterConfigData.HelpPath?
@Environment(\.openURL)
var openURL

@Environment(\.localization)
private var localization: CustomerCenterConfigData.Localization

var body: some View {
ForEach(self.viewModel.paths, id: \.id) { path in
ManageSubscriptionButton(path: path, viewModel: self.viewModel)
}
}

}

@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
struct ManageSubscriptionButton: View {

let path: CustomerCenterConfigData.HelpPath
@ObservedObject var viewModel: ManageSubscriptionsViewModel

@Environment(\.appearance) private var appearance: CustomerCenterConfigData.Appearance

var body: some View {
AsyncButton(action: {
await self.viewModel.determineFlow(for: path)
}, label: {
if self.viewModel.loadingPath?.id == path.id {
TintedProgressView()
} else {
Text(path.title)
}
})
.disabled(self.viewModel.loadingPath != nil)
}

}

#endif
Loading

0 comments on commit 440c861

Please sign in to comment.