Skip to content

Extract Attribution logic out of Purchases#1693

Merged
taquitos merged 7 commits into
mainfrom
attributes
Jun 14, 2022
Merged

Extract Attribution logic out of Purchases#1693
taquitos merged 7 commits into
mainfrom
attributes

Conversation

@taquitos

@taquitos taquitos commented Jun 11, 2022

Copy link
Copy Markdown
Contributor

Move all Purchases.setX attribution-related things into their own namespace Purchases.Attribution.setX
We can deprecate the current ones and easily have Xcode fixes for them all when we release RCv5 (whenever that is)
I think extracting API from Purchases into Purchases. makes a lot of sense and is more discoverable/friendly for docs, too.

Resolves CSDK-128

@taquitos taquitos requested a review from a team June 11, 2022 00:12

@aboedo aboedo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

absolutely love it so far. We should get the API testers updated as well

Comment thread Sources/Purchasing/Purchases/Attribution.swift Outdated
Comment thread Sources/Purchasing/Purchases/Attribution.swift Outdated
Comment thread Sources/Purchasing/Purchases/Purchases.swift Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👏 👏 👏 👏

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

Just a few issues with API testers, but I love this refactor.

Comment thread Sources/Misc/Deprecations.swift Outdated

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.

Awesome.
These probably create a bunch new deprecation warnings when compiling SwiftAPITester.
Could you add an annotation to checkPurchasesSubscriberAttributesAPI like I did in #1631?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ohhhh good idea.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Suggested change
* Attribution object that is responsible for all explicit attribution APIs
* ``Attribution`` object that is responsible for all explicit attribution APIs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

What do you mean by this?

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.

Oooh I think you meant

Suggested change
* - Note: Calling this static property or to instance property has the same effect.
* - Note: Calling this static property or the instance property has the same effect.

I wonder if we actually need this static one though. I'm usually not a big fan of offering two ways of doing the same thing, leads to users potentially wondering "what's the difference?", and IMO it doesn't add much.

And considering that this one implicitly relies on the SDK being already configured, I think that can be made explicit by forcing users to call it on Purchases.shared.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Cool, I was leaning towards removing it, so I'm glad you agree 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Suggested change
* Attribution object that is responsible for all explicit attribution APIs
* ``Attribution`` object that is responsible for all explicit attribution APIs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 170 to 192

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.

Wait, but these methods STILL need to be available because they're deprecated and not obsoleted, so we should check that they're still available by leaving this as is.

You can add

@available(*, deprecated) // Ignore deprecation warnings

To silence the warnings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

💯

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

This is missing

RCAttribution *attribution = [p attribution];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 148 to 173

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.

All these are already checked by RCAttributionAPI, so I'd remove them?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

This file is just missing:

let attribution: Attribution = purchases.attribution

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


@available(*, deprecated) // Ignore deprecation warnings
private func checkPurchasesSubscriberAttributesAPI(purchases: Purchases) {
_ = purchases.attribution

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.

This needs to check the type:

Suggested change
_ = purchases.attribution
let _: Attribution = purchases.attribution

And I would move this out of this method since it's not deprecated (and if it were, we wouldn't want to ignore that warning)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

touche

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Move purchases.attribution from deprecation section to current api
@joshdholtz

Copy link
Copy Markdown
Member

@beylmk Mentioning you here because I think we will want to rework the AdServices public API into what is going on in this PR? 🤷‍♂️

@taquitos taquitos merged commit 29f96df into main Jun 14, 2022
@taquitos taquitos deleted the attributes branch June 14, 2022 21:37
NachoSoto added a commit that referenced this pull request Jun 19, 2022
NachoSoto added a commit that referenced this pull request Jun 21, 2022
@joshdholtz joshdholtz mentioned this pull request Jun 22, 2022
NachoSoto added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Jun 23, 2022
NachoSoto added a commit that referenced this pull request Jul 4, 2022
### Changes:
* Replaced `CustomerInfo.nonSubscriptionTransactions` with a new non-`StoreTransaction` type (#1733) via NachoSoto (@NachoSoto)
* `Purchases.configure`: added overload taking a `Configuration.Builder` (#1720) via NachoSoto (@NachoSoto)
* Extract Attribution logic out of Purchases (#1693) via Joshua Liebowitz (@taquitos)
* Remove create alias (#1695) via Joshua Liebowitz (@taquitos)

All attribution APIs can now be accessed from `Purchases.shared.attribution`.

### Improvements:
* Improved purchasing logs, added promotional offer information (#1725) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator`: don't log attribute errors if there are none (#1742) via NachoSoto (@NachoSoto)
* `FatalErrorUtil`: don't override `fatalError` on release builds (#1736) via NachoSoto (@NachoSoto)
* `SKPaymentTransaction`: added more context to warnings about missing properties (#1731) via NachoSoto (@NachoSoto)
* New SwiftUI Purchase Tester example (#1722) via Josh Holtz (@joshdholtz)
* update docs for `showManageSubscriptions` (#1729) via aboedo (@aboedo)
* `PurchasesOrchestrator`: unify finish transactions between SK1 and SK2 (#1704) via NachoSoto (@NachoSoto)
* `SubscriberAttribute`: converted into `struct` (#1648) via NachoSoto (@NachoSoto)
* `CacheFetchPolicy.notStaleCachedOrFetched`: added warning to docstring (#1708) via NachoSoto (@NachoSoto)
* Clear cached offerings and products after Storefront changes (2/4) (#1583) via Juanpe Catalán (@Juanpe)
* `ROT13`: optimized initialization and removed magic numbers (#1702) via NachoSoto (@NachoSoto)

### Fixes:
* `logIn`/`logOut`: sync attributes before aliasing (#1716) via NachoSoto (@NachoSoto)
* `Purchases.customerInfo(fetchPolicy:)`: actually use `fetchPolicy` parameter (#1721) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator`: fix behavior dealing with `nil` `SKPaymentTransaction.productIdentifier` during purchase (#1680) via NachoSoto (@NachoSoto)
* `PurchasesOrchestrator.handlePurchasedTransaction`: always refresh receipt data (#1703) via NachoSoto (@NachoSoto)
NachoSoto added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Jul 4, 2022
NachoSoto added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Jul 4, 2022
NachoSoto added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Jul 4, 2022
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.

4 participants