Skip to content

refactor: extract Offering.presentedOfferingContext() helper and apply across SDK#3513

Merged
rickvdl merged 2 commits into
mainfrom
rickvdl/offering-presented-context-helper
Jun 2, 2026
Merged

refactor: extract Offering.presentedOfferingContext() helper and apply across SDK#3513
rickvdl merged 2 commits into
mainfrom
rickvdl/offering-presented-context-helper

Conversation

@rickvdl

@rickvdl rickvdl commented May 28, 2026

Copy link
Copy Markdown
Member

Added a small helper function for getting the PresentedOfferingContext from an Offering object as a follow up on #3424 (comment)

Replacing all occurrences of

offering.availablePackages.firstOrNull()?.presentedOfferingContext

with the use of the new helper

offering.presentedOfferingContext

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 @InternalRevenueCatAPI Offering.presentedOfferingContext property (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()?.presentedOfferingContext now use offering.presentedOfferingContext, including custom paywall impressions, paywall activity launch options, and embedded paywall views. PaywallViewModel keeps a local presentedOfferingContextOrDefault extension that falls back to PresentedOfferingContext(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.

@rickvdl rickvdl changed the title Rickvdl/offering presented context helper refactor: extract Offering.presentedOfferingContext() helper and apply across SDK May 28, 2026
@rickvdl rickvdl marked this pull request as ready for review May 28, 2026 14:55
@rickvdl rickvdl requested review from a team May 28, 2026 14:55

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

Many thanks for doing this!! 🙇 Just some comments regarding the API and location.

package com.revenuecat.purchases

@InternalRevenueCatAPI
public fun Offering.presentedOfferingContext(): PresentedOfferingContext? =

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.

Hmm does this need to be an extension function? Could it just be part of the Offering itself?

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.

Additionally, maybe it could be a computed property, like

@InternalRevenueCatAPI
public val presentedOfferingContext: PresentedOfferingContext?
   get() = availablePackages.firstOrNull()?.presentedOfferingContext

Feels nicer as a property :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agree, thanks for the suggestion 🙌 Updated

@rickvdl rickvdl force-pushed the rickvdl/add-presented-offering-context-to-custom-paywall-events branch from a4ed790 to 7564901 Compare June 1, 2026 10:26
Base automatically changed from rickvdl/add-presented-offering-context-to-custom-paywall-events to main June 2, 2026 06:59
@rickvdl rickvdl force-pushed the rickvdl/offering-presented-context-helper branch from 075e454 to 32d7a2d Compare June 2, 2026 09:43

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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

Comment thread purchases/src/main/kotlin/com/revenuecat/purchases/Offering.kt
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.04%. Comparing base (9bd3edd) to head (184c137).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rickvdl rickvdl added this pull request to the merge queue Jun 2, 2026
Merged via the queue into main with commit 834784a Jun 2, 2026
38 checks passed
@rickvdl rickvdl deleted the rickvdl/offering-presented-context-helper branch June 2, 2026 12:53
matteinn pushed a commit to matteinn/purchases-android that referenced this pull request Jun 5, 2026
**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 -->
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.

2 participants