Skip to content

Paywalls: Move logic for events file helper to common generic class (4)#1446

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

Paywalls: Move logic for events file helper to common generic class (4)#1446
tonidero merged 4 commits into
mainfrom
toniricodiez/pwl-321-paywall-events-4

Conversation

@tonidero

@tonidero tonidero commented Nov 8, 2023

Copy link
Copy Markdown
Contributor

Description

I was working on sharing logic between diagnostics and paywall events, but there were quite a few differences that made this tricky. Diagnostics doesn't use kotlin serialization, it anonymizes the events, and has a bunch of other logic that we need to remove to be able to share most of the code with paywall events.

In this first PR, I abstracted most of the logic of PaywallEventsFileHelper and DiagnosticsFileHelper to a common EventsFileHelper.

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.

Had to make this nullable since for diagnostics we don't parse the file back to DiagnosticEntry objects, as we do for PaywallStoredEvent. So had to add another read method that reads the file as JSONObject.

The alternative was to make diagnostics use kotlin serialization, but as I started on that, I noticed I would have to rewrite a lot of things and didn't want to spend a lot of time there.

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.

Maybe

Suggested change
private val stringToEventConverter: ((String) -> T)? = null,
private val eventDeserializer: ((String) -> T)? = null,

And I would leave a comment for how this behaves if it's null.

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.

This is the only method remaining here. I want to finish paywall events before dedicating more time to rewriting the whole thing for diagnostics.

@tonidero tonidero force-pushed the toniricodiez/pwl-321-paywall-events-4 branch from e7607fe to cf6223f Compare November 8, 2023 11:33
@codecov

codecov Bot commented Nov 8, 2023

Copy link
Copy Markdown

Codecov Report

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

Comparison is base (530b61b) 83.62% compared to head (643fa77) 84.03%.
Report is 1 commits behind head on main.

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1446      +/-   ##
==========================================
+ 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     
Files Coverage Δ
...otlin/com/revenuecat/purchases/PurchasesFactory.kt 85.24% <100.00%> (+0.32%) ⬆️
...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%> (+16.66%) ⬆️
...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%> (ø)
.../purchases/paywalls/events/PaywallEventsManager.kt 100.00% <100.00%> (+7.69%) ⬆️
...at/purchases/paywalls/events/PaywallStoredEvent.kt 94.44% <100.00%> (+81.11%) ⬆️
...t/purchases/common/networking/RCHTTPStatusCodes.kt 66.66% <0.00%> (ø)
... and 5 more

... and 5 files with indirect coverage changes

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

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

I think this makes sense as a first refactor

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.

Love it

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.

+1

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

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.

+1

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 public?
Also I'd add a docstring

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.

Maybe

Suggested change
private val stringToEventConverter: ((String) -> T)? = null,
private val eventDeserializer: ((String) -> T)? = null,

And I would leave a comment for how this behaves if it's null.

@tonidero tonidero force-pushed the toniricodiez/pwl-321-paywall-events-3 branch from 6dbfdc1 to 795838c Compare November 10, 2023 08:55
Base automatically changed from toniricodiez/pwl-321-paywall-events-3 to main November 10, 2023 09:12
@tonidero tonidero force-pushed the toniricodiez/pwl-321-paywall-events-4 branch from 643fa77 to af4c529 Compare November 10, 2023 09:16
@tonidero tonidero enabled auto-merge (squash) November 10, 2023 09:17
@tonidero tonidero merged commit 65a2ed2 into main Nov 10, 2023
@tonidero tonidero deleted the toniricodiez/pwl-321-paywall-events-4 branch November 10, 2023 09:34
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