-
Notifications
You must be signed in to change notification settings - Fork 54
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
Paywalls: Track paywall events #1447
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add tests and test it manually a bit more, but seems to be working.
@@ -50,15 +50,19 @@ fun PaywallDialog( | |||
val dismissRequest = { | |||
shouldDisplayDialog = false | |||
} | |||
val paywallOptions = paywallDialogOptions.toPaywallOptions(dismissRequest) | |||
|
|||
val viewModel = getPaywallViewModel(options = paywallOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed the viewmodel in order to track this event when dismissing the dialog correctly. It shouldn't cause duplications since we don't have keys anymore and it's the same model.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1447 +/- ##
==========================================
+ Coverage 83.62% 84.03% +0.40%
==========================================
Files 206 206
Lines 6811 6848 +37
Branches 989 993 +4
==========================================
+ Hits 5696 5755 +59
+ Misses 726 706 -20
+ Partials 389 387 -2
☔ View full report in Codecov by Sentry. |
@@ -44,9 +46,13 @@ internal fun InternalPaywall( | |||
options: PaywallOptions, | |||
viewModel: PaywallViewModel = getPaywallViewModel(options), | |||
) { | |||
viewModel.trackPaywallImpressionIfNeeded() | |||
BackHandler { | |||
viewModel.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is viewModel.close
called twice now with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the BackHandler
is only called when the user presses the back button/performs the back navigation gesture.
We only call close
manually when the user presses the X
button or dismisses the PaywallDialog (by tapping outside it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh so we weren't calling that then, good catch
...venuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/PaywallViewModel.kt
Outdated
Show resolved
Hide resolved
|
||
Dialog( | ||
onDismissRequest = { | ||
dismissRequest() | ||
viewModel.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to add tests to make sure we're calling these appropriately, but those would be UI tests, not snapshot tests, which might be a bit harder to write... Will try to write these tests after.
@@ -44,9 +46,13 @@ internal fun InternalPaywall( | |||
options: PaywallOptions, | |||
viewModel: PaywallViewModel = getPaywallViewModel(options), | |||
) { | |||
viewModel.trackPaywallImpressionIfNeeded() | |||
BackHandler { | |||
viewModel.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh so we weren't calling that then, good catch
@Suppress("ReturnCount") | ||
private fun createEventData(): PaywallEvent.Data? { | ||
val currentState = state.value | ||
if (currentState !is PaywallState.Loaded) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL !is
...venuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/PaywallViewModel.kt
Outdated
Show resolved
Hide resolved
...ecatui/src/test/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/PaywallViewModelTest.kt
Outdated
Show resolved
Hide resolved
643fa77
to
af4c529
Compare
ecf55d6
to
20707b9
Compare
**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]>
Description
This PR adds tracking of the
paywall_impression
,paywall_close
andpaywall_cancel
events to the paywalls.