Skip to content

Add placement and targeting context to paywall events#3253

Open
dpannasch wants to merge 7 commits intomainfrom
feat/paywall-events-placement-targeting
Open

Add placement and targeting context to paywall events#3253
dpannasch wants to merge 7 commits intomainfrom
feat/paywall-events-placement-targeting

Conversation

@dpannasch
Copy link
Copy Markdown

@dpannasch dpannasch commented Mar 17, 2026

Include presentedOfferingContext (placementIdentifier, targetingRevision, targetingRuleId) in paywall event serialization so that events & charts can utilize those dimensions.

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-ios and hybrids

Motivation

Description


Note

Medium Risk
Adds a new optional presented_offering_context payload 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_context object (placement identifier, targeting revision, targeting rule id).

Both PaywallStoredEvent.toBackendEvent() and PaywallEvent.toBackendStoredEvent() populate this field only when placement/targeting data exists (otherwise it remains null), 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.

@rickvdl rickvdl added the pr:feat A new feature label Mar 20, 2026
dpannasch and others added 2 commits March 20, 2026 16:18
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.
@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from 2f8a6fe to a7a725f Compare March 20, 2026 15:23
rickvdl added 3 commits March 20, 2026 16:36
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
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.41%. Comparing base (b6b6349) to head (9b96692).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...revenuecat/purchases/common/events/BackendEvent.kt 90.90% 0 Missing and 1 partial ⚠️
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.
📢 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.

Align naming with iOS for cross-platform consistency.
@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from 12fc978 to d872299 Compare March 23, 2026 12:43
@rickvdl rickvdl marked this pull request as ready for review March 23, 2026 12:47
@rickvdl rickvdl requested review from a team as code owners March 23, 2026 12:47
@rickvdl rickvdl changed the title DRAFT: Add placement and targeting rule to paywall events Add placement and targeting context to paywall events Mar 23, 2026
Copy link
Copy Markdown
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Looking great! If we've tested this and the backend is already accepting the new propert, let's 🚢

- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants