Add placement and targeting context to paywall events#3253
Open
Add placement and targeting context to paywall events#3253
Conversation
Include presentedOfferingContext (placementIdentifier, targetingRevision, targetingRuleId) in BackendEvent.Paywalls serialization so the backend can calculate conversion rates per placement. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add fromContext factory on PresentedOfferingContextBackend that encapsulates the nil-check logic, removing duplication between BackendStoredEvent and PaywallStoredEvent conversion paths.
2f8a6fe to
a7a725f
Compare
Verify that placement and targeting context survives the full PaywallStoredEvent serialize → deserialize → toBackendEvent flow, and that events without placement produce null backend context.
- Add placement-only round-trip test (no targeting) - Add targeting-only round-trip test (no placement) - Add test through PaywallEvent.toBackendStoredEvent() path verifying placement and targeting are preserved
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3253 +/- ##
==========================================
+ Coverage 79.38% 79.41% +0.02%
==========================================
Files 357 357
Lines 14347 14362 +15
Branches 1959 1963 +4
==========================================
+ Hits 11389 11405 +16
+ Misses 2154 2152 -2
- Partials 804 805 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Align naming with iOS for cross-platform consistency.
12fc978 to
d872299
Compare
tonidero
approved these changes
Mar 23, 2026
Contributor
tonidero
left a comment
There was a problem hiding this comment.
Looking great! If we've tested this and the backend is already accepting the new propert, let's 🚢
purchases/src/main/kotlin/com/revenuecat/purchases/common/events/BackendEvent.kt
Outdated
Show resolved
Hide resolved
purchases/src/main/kotlin/com/revenuecat/purchases/common/events/BackendEvent.kt
Show resolved
Hide resolved
...ses/src/test/java/com/revenuecat/purchases/paywalls/events/PaywallEventSerializationTests.kt
Outdated
Show resolved
Hide resolved
purchases/src/main/kotlin/com/revenuecat/purchases/common/events/BackendEvent.kt
Show resolved
Hide resolved
- Use import instead of fully-qualified name for PresentedOfferingContext - Assert full PresentedOfferingContextData objects instead of individual fields - Add backward compat test for old stored events without presented_offering_context
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Include presentedOfferingContext (placementIdentifier, targetingRevision, targetingRuleId) in paywall event serialization so that events & charts can utilize those dimensions.
Checklist
purchases-iosand hybridsMotivation
Description
Note
Medium Risk
Adds a new optional
presented_offering_contextpayload to paywall events; while backwards-compatible in the client, it changes analytics/telemetry schema and could impact backend ingestion or downstream parsing if not handled.Overview
Paywall event payloads now optionally include placement and targeting metadata via a new
presented_offering_contextobject (placement identifier, targeting revision, targeting rule id).Both
PaywallStoredEvent.toBackendEvent()andPaywallEvent.toBackendStoredEvent()populate this field only when placement/targeting data exists (otherwise it remainsnull), and tests are expanded to validate request bodies, round-trip serialization, and backwards-compatible deserialization of older stored events without the new field.Written by Cursor Bugbot for commit 9b96692. This will update automatically on new commits. Configure here.