Add presentedOfferingContext support to custom paywall impression events#1796
Add presentedOfferingContext support to custom paywall impression events#1796rickvdl wants to merge 1 commit into
Conversation
| const presentedOfferingContext = | ||
| params?.presentedOfferingContext ?? | ||
| params?.offering?.availablePackages?.[0]?.presentedOfferingContext; | ||
| const offeringId = |
There was a problem hiding this comment.
Since the offeringId parameter is now deprecated (and will eventually be removed) I figured it made more sense consider the Offering the source of truth if passed, and we don't consider the passed offeringId as an 'override'.
tonidero
left a comment
There was a problem hiding this comment.
A couple of small things but looking good!
| if (params?.paywallId !== undefined) { | ||
| eventData.paywallId = params.paywallId; | ||
| } | ||
| if (offeringId !== undefined) { |
There was a problem hiding this comment.
I think this could also be null, so same as above.
There was a problem hiding this comment.
Good point, I've simplified all of this now :)
b3812f9 to
f227237
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 f227237. Configure here.
a2f4f10 to
c1e7a3d
Compare
c1e7a3d to
52d2ac9
Compare

Based on PHC PR RevenueCat/purchases-hybrid-common#1665.
API
We will now send the
presentedOfferingContextfrom the passedOfferingalong with the event. This PR adds the new API variant that takes anOfferinginstead of a plain stringofferingId. The latter is now deprecated in favor of this new API variant. We will derive thepresentedOfferingContextfrom thisOfferingand send it along with the request.Note
Low Risk
Analytics-only API extension with backward-compatible
offeringId; main risk is slightly different native event payloads if callers relied on omitted keys instead of nulls.Overview
Custom paywall impression tracking now accepts an optional
PurchasesOffering(stringofferingIdis deprecated) and forwardspresentedOfferingContextto native alongsidepaywallIdandofferingId. The JS layer always builds a normalized payload with explicitnullfor missing fields; context is taken from the first package on the offering when present, and an passedofferingwins over legacyofferingId.Native bridges strip null entries before hybrid common on Android (
toNonNullHashMap, also reused for Appstack attribution) and mapNSNullto nil on iOS for this call. Tests, API testers, Jest mocks, a web no-op stub, and the purchase tester Custom Paywall screen (track with/without offering, event listener) were updated to match.Reviewed by Cursor Bugbot for commit 52d2ac9. Bugbot is set up for automated code reviews on this repo. Configure here.