Skip to content

Add placement and targeting rule to paywall events#6476

Merged
rickvdl merged 15 commits into
mainfrom
feat/paywall-events-placement-targeting
Apr 28, 2026
Merged

Add placement and targeting rule to paywall events#6476
rickvdl merged 15 commits into
mainfrom
feat/paywall-events-placement-targeting

Conversation

@dpannasch

@dpannasch dpannasch commented Mar 17, 2026

Copy link
Copy Markdown
Contributor

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-android and hybrids

Motivation

Description


Note

Medium Risk
Changes the JSON schema sent to the paywalls events endpoint by adding a new optional nested object, which could affect backend parsing/analytics if not handled, though the fields are additive and nil-safe.

Overview
Paywall feature events now include an optional presented_offering_context payload (placement + targeting rule metadata) when serialized and posted to the paywalls events backend.

This threads PresentedOfferingContext data from Offering/Package into PaywallEvent.Data, encodes it via a new PresentedOfferingContextData wrapper that omits the object when all fields are nil, and updates withPurchaseInfo to preserve these new fields. Unit + snapshot tests were added to cover placement-only, targeting-only, and combined cases, including end-to-end backend request snapshots across platforms.

Reviewed by Cursor Bugbot for commit 0ad31b9. Bugbot is set up for automated code reviews on this repo. Configure here.

@rickvdl rickvdl added the pr:feat A new feature label Mar 20, 2026
@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from df2f4e1 to b076fe1 Compare March 20, 2026 14:33
@emerge-tools

emerge-tools Bot commented Mar 20, 2026

Copy link
Copy Markdown

📸 Snapshot Test

327 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
PaywallsTester V1 swift-snapshot-testing
com.revenuecat.PaywallsTester.v1-snapshots
0 0 0 0 63 0 N/A
RevenueCat
com.revenuecat.PaywallsTester
0 0 0 0 264 0 N/A

🛸 Powered by Emerge Tools

@rickvdl

rickvdl commented Mar 20, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from 78c72b4 to f35f2bd Compare March 20, 2026 15:48
@emerge-tools

emerge-tools Bot commented Mar 20, 2026

Copy link
Copy Markdown

4 builds increased size

Name Version Download Change Install Change Approval
RevenueCat
com.revenuecat.PaywallsTester
1.0 (1) 17.8 MB ⬆️ 16.4 kB (0.09%) 64.1 MB ⬆️ 113.0 kB (0.18%) N/A
BinarySizeTest
com.revenuecat.binary-size-test.local-source
1.0 (1) 4.0 MB ⬆️ 5.1 kB (0.13%) 12.2 MB ⬆️ 23.2 kB (0.19%) N/A
BinarySizeTest
com.revenuecat.binary-size-test.cocoapods
1.0 (1) 6.1 MB ⬆️ 7.0 kB (0.11%) 26.9 MB ⬆️ 35.7 kB (0.13%) ⏳ Needs approval
BinarySizeTest
com.revenuecat.binary-size-test.spm
1.0 (1) 4.1 MB ⬆️ 6.9 kB (0.17%) 10.6 MB ⬆️ 23.2 kB (0.22%) N/A

RevenueCat 1.0 (1)
com.revenuecat.PaywallsTester

⚖️ Compare build
⏱️ Analyze build performance

Total install size change: ⬆️ 113.0 kB (0.18%)
Total download size change: ⬆️ 16.4 kB (0.09%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 17.3 kB
RevenueCat.InternalAPI.InternalAPI ⬆️ 3.3 kB
RevenueCatUI.PaywallViewController.PaywallViewController ⬆️ 2.9 kB
Code Signature ⬆️ 2.7 kB
RCPurchases.Objc Metadata ⬆️ 2.7 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.local-source

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 23.2 kB (0.19%)
Total download size change: ⬆️ 5.1 kB (0.13%)

Largest size changes

Item Install Size Change
RevenueCat.PurchasedTransactionDataEncodedWrapper.value witness ⬆️ 3.8 kB
RevenueCat.LocalTransactionMetadata.value witness ⬆️ 3.5 kB
RevenueCat.PaywallEvent.value witness ⬆️ 2.7 kB
RevenueCat.PurchasedTransactionData.value witness ⬆️ 2.5 kB
RevenueCat.PurchasesOrchestrator.CachedPurchaseContext.value witn... ⬆️ 2.5 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.cocoapods

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 35.7 kB (0.13%)
Total download size change: ⬆️ 7.0 kB (0.11%)

Largest size changes

Item Install Size Change
DYLD.String Table ⬆️ 10.3 kB
RevenueCat.PurchasedTransactionDataEncodedWrapper.value witness ⬆️ 3.8 kB
RevenueCat.LocalTransactionMetadata.value witness ⬆️ 3.5 kB
RevenueCat.PaywallEvent.value witness ⬆️ 2.7 kB
RevenueCat.PurchasedTransactionData.value witness ⬆️ 2.5 kB
View Treemap

Image of diff

BinarySizeTest 1.0 (1)
com.revenuecat.binary-size-test.spm

⚖️ Compare build
📦 Install build
⏱️ Analyze build performance

Total install size change: ⬆️ 23.2 kB (0.22%)
Total download size change: ⬆️ 6.9 kB (0.17%)

Largest size changes

Item Install Size Change
RevenueCat.PurchasedTransactionDataEncodedWrapper.value witness ⬆️ 3.8 kB
RevenueCat.LocalTransactionMetadata.value witness ⬆️ 3.5 kB
RevenueCat.PaywallEvent.value witness ⬆️ 2.7 kB
RevenueCat.PurchasedTransactionData.value witness ⬆️ 2.5 kB
RevenueCat.PurchasesOrchestrator.CachedPurchaseContext.value witn... ⬆️ 2.5 kB
View Treemap

Image of diff


🛸 Powered by Emerge Tools

Comment trigger: Size diff threshold of 100.00kB exceeded

@rickvdl

rickvdl commented Mar 23, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from f35f2bd to 7b9caf4 Compare March 23, 2026 08:08
@rickvdl

rickvdl commented Mar 23, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

@rickvdl rickvdl marked this pull request as ready for review March 23, 2026 12:27
@rickvdl rickvdl requested a review from a team as a code owner March 23, 2026 12:27
@rickvdl rickvdl changed the title DRAFT: Add placement and targeting rule to paywall events Add placement and targeting rule to paywall events Mar 23, 2026

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

Looks great!

Comment thread Sources/Paywalls/Events/Networking/EventsRequest+Paywall.swift

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

Looks great!

Comment on lines +331 to +336
var copy = self
copy.packageId = packageId
copy.productId = productId
copy.errorCode = errorCode
copy.errorMessage = errorMessage
return copy

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.

Nice!

@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from e41d6de to 4e979b8 Compare April 16, 2026 13:28
@rickvdl rickvdl requested a review from a team as a code owner April 16, 2026 13:28
@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from 4e979b8 to edf9e61 Compare April 16, 2026 13:41
@rickvdl

rickvdl commented Apr 16, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

1 similar comment
@rickvdl

rickvdl commented Apr 20, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from edf9e61 to 5e39a87 Compare April 20, 2026 07:43
@rickvdl

rickvdl commented Apr 20, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

dpannasch and others added 8 commits April 28, 2026 12:20
Include presentedOfferingContext (placementIdentifier, targetingRevision,
targetingRuleId) in paywall event serialization so the backend can
calculate conversion rates per placement.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move PresentedOfferingContextData from nested struct inside
FeatureEventsRequest.PaywallEvent to an extension to avoid
exceeding the 1-level nesting limit.
Move nil-checking logic into a failable initializer on
PresentedOfferingContextData, simplifying the call site.
RCGitBot and others added 7 commits April 28, 2026 12:20
…rectly

Replace three separate placement/targeting parameters with a single
PresentedOfferingContext? parameter in the internal init, removing
duplicated property extraction across all four public initializers.
Also simplify withPurchaseInfo to use var copy.
- Add round-trip test with placement/targeting through serialize →
  deserialize → backend event pipeline
- Add placement-only test (no targeting)
- Add targeting-only test (no placement)
…eting

Verify that events serialized before placement/targeting fields were
added still deserialize correctly and produce nil presentedOfferingContext.
@rickvdl rickvdl force-pushed the feat/paywall-events-placement-targeting branch from 5e39a87 to 0ad31b9 Compare April 28, 2026 10:21
@rickvdl

rickvdl commented Apr 28, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

@rickvdl rickvdl merged commit 658d12d into main Apr 28, 2026
41 of 42 checks passed
@rickvdl rickvdl deleted the feat/paywall-events-placement-targeting branch April 28, 2026 11:43
This was referenced Apr 30, 2026
rickvdl added a commit to RevenueCat/purchases-js that referenced this pull request Jun 2, 2026
## Summary
- Include `placement_identifier`, `targeting_revision`, and
`targeting_rule_id` in paywall events under a
`presented_offering_context` nested object
- Field is omitted when no placement or targeting data exists
- Consistent with iOS and Android implementations

## Related PRs
- iOS: RevenueCat/purchases-ios#6476
- Android: RevenueCat/purchases-android#3253

## Test plan
- [x] Unit tests for all context permutations (full, placement-only,
targeting-only, none, empty string)
- [x] JSON round-trip serialization tests
- [x] Integration test verifying context flows from offering to event
payload
- [x] Manual testing with targeting rules and placements in demo app
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.

5 participants