Skip to content

Commit

Permalink
Merge pull request #131 from superwall-me/develop
Browse files Browse the repository at this point in the history
3.0.0-rc.4
  • Loading branch information
yusuftor authored May 4, 2023
2 parents c7c6a4d + bfba47b commit a616836
Show file tree
Hide file tree
Showing 92 changed files with 1,601 additions and 1,169 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tag-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
cocoapods:
needs: tag
runs-on: macos-12
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Publish to CocoaPod register
Expand All @@ -39,7 +39,7 @@ jobs:
xcode12:
needs: tag
runs-on: macos-12
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ concurrency:

jobs:
run-tests:
runs-on: macos-12
runs-on: macos-13

steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '14.3'
- name: Git Checkout
uses: actions/checkout@v3
- name: xcodegen
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/xcode-12-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
cocoapods:
needs: tag
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Publish to CocoaPod register
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@

The changelog for `SuperwallKit`. Also see the [releases](https://github.com/superwall-me/Superwall-iOS/releases) on GitHub.

## 3.0.0-rc.4

### Breaking Changes

- Changes `DismissState` to `PaywallResult`.
- Removes the `closedForNextPaywall` case from `PaywallResult` in favor of a new `PaywallInfo` property called `closeReason`, which can either be `nil`, `.systemLogic`, or `.forNextPaywall`.
- Changes the `PaywallPresentationHandler` variables to functions.
- Removes `Superwall.shared.track`. We're going all in on `Superwall.shared.register` baby!
- Removes .error(Error) from `PaywallSkippedReason` in favor of a new `PaywallState` case `.presentationError(Error)`.
- Removes `PaywallPresentationHandler` completion block variables removed in favor of function calls with the same names.
- Changes `.onError` of `PaywallPresentationHandler` to no longer be called when a paywall is intentionally not shown (i.e. user is subscribed, user is in holdout, no rule match, event not configured)
- Adds `.onSkip(reason:)` to `PaywallPresentationHandler` to handle cases where paywall isn't shown because user is subscribed, user is in holdout, no rules match, event not configured

### Enhancements

- Adds `getPaywallViewController`! You can no request an actual view controller to present however you like. Check function documentation in Xcode for instructions – follow directions closely.
- Changes default logging level to `INFO`.
- Adds new automatically tracked `paywall_decline` event that can be used to present a new paywall when a user dismisses a paywall.
- Allows `transaction_abandon` to trigger new paywalls when added to a campaign – called when a user abandons checkout (did you know 75% of the time, users abandon checkout when Apple's payment sheet comes up?!).
- Adds `.onSkip` to `PaywallPresentationHandler` which is passed a `PaywallSkippedReason` when a paywall is not supposed to show.
- Adds logging at `INFO` level, mansplaining exactly why a paywall is not shown when calling `register` or `getPaywallViewController`.
- Adds new automatically tracked event `presentation_request` that gets sent with properties explaining why a paywall was or was not shown.

### Fixes

- Paywalls will now show even if you are missing products.

## 3.0.0-rc.3

### Breaking Changes
Expand Down
19 changes: 16 additions & 3 deletions Examples/SwiftUI/Superwall-SwiftUI/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,28 @@ struct HomeView: View {
VStack(spacing: 25) {
BrandedButton(title: "Launch Feature") {
let handler = PaywallPresentationHandler()
handler.onDismiss = { paywallInfo in
handler.onDismiss { paywallInfo in
print("The paywall dismissed. PaywallInfo:", paywallInfo)
}
handler.onPresent = { paywallInfo in
handler.onPresent { paywallInfo in
print("The paywall presented. PaywallInfo:", paywallInfo)
}
handler.onError = { error in
handler.onError { error in
print("The paywall presentation failed with error \(error)")
}
handler.onSkip { reason in
switch reason {
case .userIsSubscribed:
print("Paywall not shown because user is subscribed.")
case .holdout(let experiment):
print("Paywall not shown because user is in a holdout group in Experiment: \(experiment.id)")
case .noRuleMatch:
print("Paywall not shown because user doesn't match any rules.")
case .eventNotFound:
print("Paywall not shown because this event isn't part of a campaign.")
}
}

Superwall.shared.register(event: "campaign_trigger", handler: handler) {
// code in here can be remotely configured to execute. Either
// (1) always after presentation or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,28 @@ final class HomeViewController: UIViewController {

@IBAction private func launchFeature() {
let handler = PaywallPresentationHandler()
handler.onDismiss = { paywallInfo in
handler.onDismiss { paywallInfo in
print("The paywall dismissed. PaywallInfo:", paywallInfo)
}
handler.onPresent = { paywallInfo in
handler.onPresent { paywallInfo in
print("The paywall presented. PaywallInfo:", paywallInfo)
}
handler.onError = { error in
handler.onError { error in
print("The paywall presentation failed with error \(error)")
}
handler.onSkip { reason in
switch reason {
case .userIsSubscribed:
print("Paywall not shown because user is subscribed.")
case .holdout(let experiment):
print("Paywall not shown because user is in a holdout group in Experiment: \(experiment.id)")
case .noRuleMatch:
print("Paywall not shown because user doesn't match any rules.")
case .eventNotFound:
print("Paywall not shown because this event isn't part of a campaign.")
}
}

Superwall.shared.register(event: "campaign_trigger", handler: handler) {
// code in here can be remotely configured to execute. Either
// (1) always after presentation or
Expand Down
32 changes: 26 additions & 6 deletions Examples/UIKit-ObjC/Superwall-UIKit-ObjC/SSAHomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,35 @@ - (void)viewWillAppear:(BOOL)animated {

- (IBAction)registerEvent:(id)sender {
SWKPaywallPresentationHandler *handler = [[SWKPaywallPresentationHandler alloc] init];
handler.onDismiss = ^(SWKPaywallInfo *paywallInfo) {

[handler onDismiss:^(SWKPaywallInfo * _Nonnull paywallInfo) {
NSLog(@"The paywall dismissed. PaywallInfo: %@", paywallInfo);
};
handler.onPresent = ^(SWKPaywallInfo *paywallInfo) {
}];

[handler onPresent:^(SWKPaywallInfo * _Nonnull paywallInfo) {
NSLog(@"The paywall presented. PaywallInfo: %@", paywallInfo);
};
handler.onError = ^(NSError * _Nonnull error) {
}];

[handler onSkip:^(enum SWKPaywallSkippedReason reason) {
switch (reason) {
case SWKPaywallSkippedReasonUserIsSubscribed:
NSLog(@"Paywall not shown because user is subscribed.");
break;
case SWKPaywallSkippedReasonHoldout:
NSLog(@"Paywall not shown because user is in a holdout group.");
break;
case SWKPaywallSkippedReasonNoRuleMatch:
NSLog(@"Paywall not shown because user doesn't match any rules.");
break;
case SWKPaywallSkippedReasonEventNotFound:
NSLog(@"Paywall not shown because this event isn't part of a campaign.");
break;
}
}];

[handler onError:^(NSError * _Nonnull error) {
NSLog(@"The paywall presentation failed with error %@", error);
};
}];

[[Superwall sharedInstance] registerWithEvent:@"campaign_trigger" params:nil handler:handler feature:^{
UIAlertController* alert = [UIAlertController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,27 @@ final class HomeViewController: UIViewController {

@IBAction private func launchFeature() {
let handler = PaywallPresentationHandler()
handler.onDismiss = { paywallInfo in
handler.onDismiss { paywallInfo in
print("The paywall dismissed. PaywallInfo:", paywallInfo)
}
handler.onPresent = { paywallInfo in
handler.onPresent { paywallInfo in
print("The paywall presented. PaywallInfo:", paywallInfo)
}
handler.onError = { error in
handler.onError { error in
print("The paywall presentation failed with error \(error)")
}
handler.onSkip { reason in
switch reason {
case .userIsSubscribed:
print("Paywall not shown because user is subscribed.")
case .holdout(let experiment):
print("Paywall not shown because user is in a holdout group in Experiment: \(experiment.id)")
case .noRuleMatch:
print("Paywall not shown because user doesn't match any rules.")
case .eventNotFound:
print("Paywall not shown because this event isn't part of a campaign.")
}
}
Superwall.shared.register(event: "campaign_trigger", handler: handler) {
// code in here can be remotely configured to execute. Either
// (1) always after presentation or
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The preferred installation method is with [Swift Package Manager](https://swift.
To include the *Superwall* SDK in your app, add the following to your Podfile:

```
pod 'SuperwallKit', '3.0.0-rc.3'
pod 'SuperwallKit', '3.0.0-rc.4'
```

If you don't want to use the v3 beta, you'll need to add this instead:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,24 @@ enum InternalSuperwallEvent {
}
}

struct UnableToPresent: TrackableSuperwallEvent {
let state: PaywallPresentationFailureReason
struct PresentationRequest: TrackableSuperwallEvent {
let eventData: EventData?
let type: PresentationRequestType
let status: PaywallPresentationRequestStatus
let statusReason: PaywallPresentationRequestStatusReason?

var superwallEvent: SuperwallEvent {
return .paywallPresentationFail(reason: state)
return .paywallPresentationRequest(status: status, reason: statusReason)
}
var customParameters: [String: Any] = [:]
func getSuperwallParameters() async -> [String: Any] { [:] }
func getSuperwallParameters() async -> [String: Any] {
[
"source_event_name": eventData?.name ?? "",
"pipeline_type": type.rawValue,
"status": status.rawValue,
"status_reason": statusReason?.description ?? ""
]
}
}

struct PaywallOpen: TrackableSuperwallEvent {
Expand All @@ -274,6 +284,17 @@ enum InternalSuperwallEvent {
var customParameters: [String: Any] = [:]
}

struct PaywallDecline: TrackableSuperwallEvent {
var superwallEvent: SuperwallEvent {
return .paywallDecline(paywallInfo: paywallInfo)
}
let paywallInfo: PaywallInfo
func getSuperwallParameters() async -> [String: Any] {
return await paywallInfo.eventParams()
}
var customParameters: [String: Any] = [:]
}

struct Transaction: TrackableSuperwallEvent {
enum State {
case start(StoreProduct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ extension Superwall {
}
let presentationRequest = dependencyContainer.makePresentationRequest(
presentationInfo,
isPaywallPresented: isPaywallPresented
isPaywallPresented: isPaywallPresented,
type: .presentation
)
await internallyPresent(presentationRequest).asyncNoValue()
case .closePaywallThenTriggerPaywall:
Expand All @@ -104,7 +105,8 @@ extension Superwall {
}
let presentationRequest = dependencyContainer.makePresentationRequest(
presentationInfo,
isPaywallPresented: isPaywallPresented
isPaywallPresented: isPaywallPresented,
type: .presentation
)
await internallyPresent(
presentationRequest,
Expand All @@ -113,7 +115,8 @@ extension Superwall {
case .triggerPaywall:
let presentationRequest = dependencyContainer.makePresentationRequest(
presentationInfo,
isPaywallPresented: isPaywallPresented
isPaywallPresented: isPaywallPresented,
type: .presentation
)
await internallyPresent(presentationRequest).asyncNoValue()
case .disallowedEventAsTrigger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,21 @@ enum TrackingLogic {
return .dontTriggerPaywall
}

let presentedEventName = paywallViewController?.paywallInfo.presentedByEventWithName
// referring events in this set are not able to trigger another
// another paywall. prevents loops from occurring
let notAllowedReferringEventNames: Set<String> = [
SuperwallEventObjc.transactionAbandon.description,
SuperwallEventObjc.transactionFail.description,
SuperwallEventObjc.paywallDecline.description
]

if let referringEventName = paywallViewController?.paywallInfo.presentedByEventWithName,
notAllowedReferringEventNames.contains(referringEventName) {
return .dontTriggerPaywall
}

if let event = event as? TrackableSuperwallEvent,
case .transactionAbandon = event.superwallEvent,
presentedEventName != SuperwallEventObjc.transactionAbandon.description {
case .transactionAbandon = event.superwallEvent {
return .closePaywallThenTriggerPaywall
}

Expand All @@ -160,6 +171,11 @@ enum TrackingLogic {
return .closePaywallThenTriggerPaywall
}

if let event = event as? TrackableSuperwallEvent,
case .paywallDecline = event.superwallEvent {
return .closePaywallThenTriggerPaywall
}

if paywallViewController != nil {
return .dontTriggerPaywall
}
Expand Down
Loading

0 comments on commit a616836

Please sign in to comment.