refactor: extract Offering.presentedOfferingContext() helper and apply across SDK#3513
Conversation
tonidero
left a comment
There was a problem hiding this comment.
Many thanks for doing this!! 🙇 Just some comments regarding the API and location.
| package com.revenuecat.purchases | ||
|
|
||
| @InternalRevenueCatAPI | ||
| public fun Offering.presentedOfferingContext(): PresentedOfferingContext? = |
There was a problem hiding this comment.
Hmm does this need to be an extension function? Could it just be part of the Offering itself?
There was a problem hiding this comment.
Additionally, maybe it could be a computed property, like
@InternalRevenueCatAPI
public val presentedOfferingContext: PresentedOfferingContext?
get() = availablePackages.firstOrNull()?.presentedOfferingContext
Feels nicer as a property :)
There was a problem hiding this comment.
Agree, thanks for the suggestion 🙌 Updated
a4ed790 to
7564901
Compare
075e454 to
32d7a2d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 32d7a2d. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3513 +/- ##
=======================================
Coverage 80.03% 80.04%
=======================================
Files 370 370
Lines 15048 15049 +1
Branches 2074 2074
=======================================
+ Hits 12044 12046 +2
Misses 2161 2161
+ Partials 843 842 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
**This is an automatic release.** ## RevenueCat SDK ### ✨ New Features * Add presented offering context to custom paywall events (RevenueCat#3424) via Rick (@rickvdl) * Add Workflows list endpoint (RevenueCat#3509) via Cesar de la Vega (@vegaro) ## RevenueCatUI SDK ### Paywalls_v2 #### 🐞 Bugfixes * Fix 1px seam between sliding multipage paywall pages (RevenueCat#3526) via Cesar de la Vega (@vegaro) ### 🔄 Other Changes * refactor: extract Offering.presentedOfferingContext() helper and apply across SDK (RevenueCat#3513) via Rick (@rickvdl) * Add JSON Logic string + array operators (RevenueCat#3485) via Antonio Pallares (@ajpallares) * Add ForbiddenPublicSealedClass detekt rule (RevenueCat#3503) via Toni Rico (@tonidero) * Update baseline profiles (RevenueCat#3519) via RevenueCat Git Bot (@RCGitBot) * build(deps): bump fastlane-plugin-revenuecat_internal from `af7bb5c` to `ce6a7ef` (RevenueCat#3515) via dependabot[bot] (@dependabot[bot]) * Add JSON Logic comparison operators (<, <=, >, >=) (RevenueCat#3484) via Antonio Pallares (@ajpallares) * Add JSON Logic arithmetic operators (+, -, *, /, %) (RevenueCat#3483) via Antonio Pallares (@ajpallares) * Add WorkflowEvent model and backend serialization (RevenueCat#3486) via Cesar de la Vega (@vegaro) * RulesEngine: add JSON Logic predicate evaluator (RevenueCat#3482) via Antonio Pallares (@ajpallares) * Add :rules-engine-internal skeleton module (RevenueCat#3478) via Antonio Pallares (@ajpallares) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Version bump and changelog/docs/CI path updates only; no application logic changes in the diff. > > **Overview** > This **automatic release** finalizes **Android SDK 10.8.0** by replacing **`10.8.0-SNAPSHOT`** with **`10.8.0`** across versioning (`gradle.properties`, `.version`, `Config.frameworkVersion`), sample apps, and changelog files. > > Release notes for **10.8.0** are recorded in **`CHANGELOG.md`** / **`CHANGELOG.latest.md`** (workflows list API, paywall offering context on custom events, multipage paywall seam fix, rules-engine/JSON Logic work, etc.). **Docs publishing** now targets **`10.8.0`** on S3, and **`docs/index.html`** redirects to the new doc URL. > > There are **no functional code changes** in this diff beyond version strings and release metadata. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c3048b8. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->

Added a small helper function for getting the
PresentedOfferingContextfrom an Offering object as a follow up on #3424 (comment)Replacing all occurrences of
with the use of the new helper
Note
Low Risk
Mechanical refactor with equivalent semantics for offerings with packages; empty offerings still yield null context where callers pass it through directly.
Overview
Adds an
@InternalRevenueCatAPIOffering.presentedOfferingContextproperty (placement/targeting from the first available package, or null when there are no packages) and updates the public API stub files accordingly.Call sites across purchases and RevenueCat UI that previously inlined
availablePackages.firstOrNull()?.presentedOfferingContextnow useoffering.presentedOfferingContext, including custom paywall impressions, paywall activity launch options, and embedded paywall views.PaywallViewModelkeeps a localpresentedOfferingContextOrDefaultextension that falls back toPresentedOfferingContext(identifier)for paywall analytics when the offering has no packages.Unit tests cover the new property and the empty-offering case for
CustomPaywallImpressionParams.Reviewed by Cursor Bugbot for commit 184c137. Bugbot is set up for automated code reviews on this repo. Configure here.