Skip to content

Paywalls: Add paywall events flush logic and tests (3)#1445

Merged
tonidero merged 4 commits into
mainfrom
toniricodiez/pwl-321-paywall-events-3
Nov 10, 2023
Merged

Paywalls: Add paywall events flush logic and tests (3)#1445
tonidero merged 4 commits into
mainfrom
toniricodiez/pwl-321-paywall-events-3

Conversation

@tonidero

@tonidero tonidero commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

Description

This adds the code to the PaywallEventsManager class to actually send the events to the backend and clear them locally once finished.

@tonidero tonidero changed the title Paywalls: Add paywall events flush logic and tests Paywalls: Add paywall events flush logic and tests (3) Nov 8, 2023
@codecov

codecov Bot commented Nov 8, 2023

Copy link
Copy Markdown

Codecov Report

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

Comparison is base (782f093) 83.95% compared to head (6dbfdc1) 84.03%.
Report is 1 commits behind head on main.

❗ Current head 6dbfdc1 differs from pull request most recent head 795838c. Consider uploading reports for the commit 795838c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1445      +/-   ##
==========================================
+ Coverage   83.95%   84.03%   +0.08%     
==========================================
  Files         203      206       +3     
  Lines        6712     6842     +130     
  Branches      974      993      +19     
==========================================
+ Hits         5635     5750     +115     
- Misses        697      706       +9     
- Partials      380      386       +6     
Files Coverage Δ
...otlin/com/revenuecat/purchases/PurchasesFactory.kt 85.00% <100.00%> (+0.08%) ⬆️
...otlin/com/revenuecat/purchases/common/AppConfig.kt 82.25% <100.00%> (+0.29%) ⬆️
...revenuecat/purchases/common/networking/Endpoint.kt 100.00% <100.00%> (ø)
.../purchases/paywalls/events/PaywallEventsManager.kt 100.00% <100.00%> (+7.69%) ⬆️
...at/purchases/paywalls/events/PaywallStoredEvent.kt 93.33% <100.00%> (+26.66%) ⬆️
...t/purchases/common/networking/RCHTTPStatusCodes.kt 66.66% <0.00%> (-33.34%) ⬇️
...t/purchases/paywalls/events/PaywallEventRequest.kt 66.66% <66.66%> (ø)
...evenuecat/purchases/utils/JsonElementExtensions.kt 68.18% <68.18%> (ø)
...t/purchases/paywalls/events/PaywallBackendEvent.kt 60.00% <60.00%> (ø)
.../kotlin/com/revenuecat/purchases/common/Backend.kt 83.78% <76.31%> (-1.07%) ⬇️

... and 6 files with indirect coverage changes

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

@tonidero tonidero marked this pull request as ready for review November 8, 2023 15:16
@tonidero tonidero requested a review from a team November 8, 2023 15:17

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

Looks great!
I want to make sure this handles (and tests) a specific use case that's tested in iOS:

See PaywallEventStoreTests.testFetchEventsWithUnrecognizedLines:
That's basically testing that this code:

return try await self.handler.readLines()
    .prefix(count)
    .compactMap { try? PaywallEventSerializer.decode($0) }

Is written like that, instead of

return try await self.handler.readLines()
    .compactMap { try? PaywallEventSerializer.decode($0) }
    .prefix(count)

Notice prefix happens first

So that if invalid lines are found, they still get removed from the store.

@tonidero

tonidero commented Nov 8, 2023

Copy link
Copy Markdown
Contributor Author

Nope, I didn't have that logic. Thanks for mentioning it! I will fix that and add some tests tomorrow

@tonidero

tonidero commented Nov 9, 2023

Copy link
Copy Markdown
Contributor Author

Made changes to handle this in #1451

Base automatically changed from toniricodiez/pwl-321-paywall-events-2 to main November 10, 2023 08:53
@tonidero tonidero force-pushed the toniricodiez/pwl-321-paywall-events-3 branch from 6dbfdc1 to 795838c Compare November 10, 2023 08:55
@tonidero tonidero enabled auto-merge (squash) November 10, 2023 08:55
@tonidero tonidero merged commit 0035b62 into main Nov 10, 2023
@tonidero tonidero deleted the toniricodiez/pwl-321-paywall-events-3 branch November 10, 2023 09:12
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 <ops@revenuecat.com>
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