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

Paywall events: Send paywall data with post receipt requests #1452

Merged
merged 3 commits into from
Nov 10, 2023

Conversation

tonidero
Copy link
Contributor

@tonidero tonidero commented Nov 9, 2023

Description

This sends the paywall data during the post receipt requests to make sure we attribute purchases to paywalls. We do this by caching the paywall events as needed.

@tonidero tonidero marked this pull request as ready for review November 9, 2023 15:23
@tonidero tonidero requested a review from a team November 9, 2023 15:23
Copy link

codecov bot commented Nov 9, 2023

Codecov Report

Attention: 38 lines in your changes are missing coverage. Please review.

Comparison is base (65a2ed2) 83.99% compared to head (cc98c49) 84.00%.
Report is 2 commits behind head on main.

❗ Current head cc98c49 differs from pull request most recent head ff488da. Consider uploading reports for the commit ff488da to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1452   +/-   ##
=======================================
  Coverage   83.99%   84.00%           
=======================================
  Files         206      208    +2     
  Lines        6843     6888   +45     
  Branches      992      999    +7     
=======================================
+ Hits         5748     5786   +38     
- Misses        705      712    +7     
  Partials      390      390           
Files Coverage Δ
...tlin/com/revenuecat/purchases/PostReceiptHelper.kt 94.56% <100.00%> (+0.24%) ⬆️
...otlin/com/revenuecat/purchases/PurchasesFactory.kt 85.48% <100.00%> (+0.23%) ⬆️
.../com/revenuecat/purchases/PurchasesOrchestrator.kt 81.60% <100.00%> (+0.03%) ⬆️
...otlin/com/revenuecat/purchases/common/AppConfig.kt 82.25% <100.00%> (ø)
...t/purchases/common/diagnostics/DiagnosticsEntry.kt 100.00% <100.00%> (ø)
...chases/common/diagnostics/DiagnosticsFileHelper.kt 100.00% <100.00%> (ø)
...ases/common/diagnostics/DiagnosticsSynchronizer.kt 94.11% <100.00%> (ø)
...purchases/common/diagnostics/DiagnosticsTracker.kt 93.42% <100.00%> (ø)
...revenuecat/purchases/common/networking/Endpoint.kt 100.00% <100.00%> (ø)
...nuecat/purchases/paywalls/PaywallPresentedCache.kt 100.00% <100.00%> (ø)
... and 10 more

... and 3 files with indirect coverage changes

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

import com.revenuecat.purchases.paywalls.events.PaywallEventType

@OptIn(ExperimentalPreviewRevenueCatPurchasesAPI::class)
internal class PaywallPresentedCache {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nice abstraction!

Comment on lines +15 to +18
val event = lastPaywallImpressionEvent
lastPaywallImpressionEvent = null
return event
Copy link
Contributor

Choose a reason for hiding this comment

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

This is technically a race condition. Is it possible to synchronize getAndRemovePresentedEvent instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right! We can synchronize the methods instead. Great catch!

storeAppUserID = any(),
marketplace = any(),
initiationSource = any(),
paywallPostReceiptData = expectedPaywallData,
Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome

@tonidero tonidero force-pushed the toniricodiez/pwl-321-paywall-events-5 branch from ecf55d6 to 20707b9 Compare November 10, 2023 09:35
Base automatically changed from toniricodiez/pwl-321-paywall-events-5 to main November 10, 2023 09:52
@tonidero tonidero force-pushed the toniricodiez/pwl-321-paywall-events-6 branch from cc98c49 to ff488da Compare November 10, 2023 09:55
@tonidero tonidero enabled auto-merge (squash) November 10, 2023 09:55
@tonidero tonidero merged commit e1653d2 into main Nov 10, 2023
@tonidero tonidero deleted the toniricodiez/pwl-321-paywall-events-6 branch November 10, 2023 10:11
tonidero pushed a commit that referenced this pull request Nov 10, 2023
**This is an automatic release.**

### RevenueCatUI
* `Paywalls`: improve error log when images fail to load (#1454) via
NachoSoto (@NachoSoto)
### Other Changes
* Paywall events: Send paywall data with post receipt requests (#1452)
via Toni Rico (@tonidero)
* Paywalls: Track paywall events (#1447) via Toni Rico (@tonidero)
* Paywall events: Handle errors parsing specific paywall event lines
(#1451) via Toni Rico (@tonidero)
* Paywalls: Move logic for events file helper to common generic class
(4) (#1446) via Toni Rico (@tonidero)
* Paywalls: Add paywall events flush logic and tests (3) (#1445) via
Toni Rico (@tonidero)
* Paywalls: Support sending paywall events to servers (2) (#1442) via
Toni Rico (@tonidero)
* `CircleCI`: fix `record-revenuecatui-snapshots` (#1455) via NachoSoto
(@NachoSoto)
* Lower request jitter log level from warning to debug (#1453) via Toni
Rico (@tonidero)

Co-authored-by: revenuecat-ops <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants