Skip to content

Add presented_workflow_id and presented_step_id to /receipts#3603

Open
vegaro wants to merge 5 commits into
mainfrom
cesar/receipt-presented-paywall-workflow-ids
Open

Add presented_workflow_id and presented_step_id to /receipts#3603
vegaro wants to merge 5 commits into
mainfrom
cesar/receipt-presented-paywall-workflow-ids

Conversation

@vegaro

@vegaro vegaro commented Jun 15, 2026

Copy link
Copy Markdown
Member

Motivation

The backend needs workflow and paywall identifiers on paywall events and post-receipt requests to properly attribute purchases and impressions to specific paywalls and workflow steps. This PR adds it to the post receipt

Source https://revenuecat.slack.com/archives/C0AGDQGUZ97/p1781206585550989

Example posted data:

Captura de pantalla 2026-06-16 a las 15 15 07

Note

Medium Risk
Touches the purchase receipt pipeline and attribution caching; incorrect workflow/step metadata could misattribute revenue, but changes are additive optional fields with tests covering payload shape and workflow re-presentation.

Overview
Post-receipt requests now include presented_workflow_id and presented_step_id at the top level of the /receipts body so purchases can be attributed to workflow steps. Workflow context is carried separately from the nested paywall object (paywall IDs stay there; workflow fields are not duplicated inside paywall).

A new WorkflowMetadata type is cached in LocalTransactionMetadata and resolved from the purchase-initiated paywall event when posting receipts (including unsynced retries). PaywallEvent.Data gains optional stepId alongside existing workflowId, with serialization support for stored events.

RevenueCat UI records the current workflow step on paywall events and refreshes workflow/step on repeated impressions when the visual fingerprint is unchanged, so a purchase after advancing to another workflow step still posts the correct step metadata.

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

@vegaro vegaro changed the base branch from main to cesar/sdk-data-paywall-workflow-ids June 15, 2026 13:41
@vegaro vegaro changed the title Add paywall and workflow IDs to paywall events and post-receipt Add presented_workflow_id and presented_step_id to /receipts Jun 15, 2026
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.47%. Comparing base (4ade8e4) to head (264d2e9).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...tlin/com/revenuecat/purchases/PostReceiptHelper.kt 57.14% 0 Missing and 3 partials ⚠️
...uecat/purchases/common/caching/WorkflowMetadata.kt 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3603   +/-   ##
=======================================
  Coverage   80.46%   80.47%           
=======================================
  Files         382      383    +1     
  Lines       15594    15619   +25     
  Branches     2166     2175    +9     
=======================================
+ Hits        12548    12569   +21     
  Misses       2172     2172           
- Partials      874      878    +4     

☔ View full report in Codecov by Harness.
📢 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.

Base automatically changed from cesar/sdk-data-paywall-workflow-ids to main June 16, 2026 08:39
The paywall-events workflow attribution (workflowId on PaywallEvent.Data and
the events payload) is already on main. This adds the post-receipt path so
native-store workflow purchases attribute to the exact screen, matching how
web funnels already attribute via presented_step_id on the RC Billing checkout
path.

- PaywallPostReceiptData carries workflowId and stepId as @transient fields so
  they are sent only as top-level presented_workflow_id / presented_step_id and
  do not leak into the nested paywall object (paywall_id stays in `paywall`).
- PaywallEvent.Data gains stepId with full serializer support; the step id is
  sourced from the current workflow step in PaywallViewModel.

presented_step_id is a no-op until khepri's /receipts endpoint accepts it
(WFL-336).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vegaro vegaro force-pushed the cesar/receipt-presented-paywall-workflow-ids branch from 1919b00 to f52062a Compare June 16, 2026 10:21
@vegaro vegaro marked this pull request as ready for review June 16, 2026 12:56
@vegaro vegaro requested review from a team as code owners June 16, 2026 12:56
workflowId and stepId were @transient on PaywallPostReceiptData, so they
were lost when the transaction was cached to disk. On retry or sync from
cached metadata, presented_workflow_id and presented_step_id would be
sent as null.

Introduces WorkflowMetadata (workflowId, stepId) as a first-class field
on LocalTransactionMetadata so the values survive disk round-trips.
PaywallPostReceiptData is now purely about the paywall; Backend reads
presented_workflow_id and presented_step_id from WorkflowMetadata instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@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 b2bfd86. Configure here.

@vegaro vegaro force-pushed the cesar/receipt-presented-paywall-workflow-ids branch from f149079 to 9e22cc1 Compare June 18, 2026 15:21
@vegaro vegaro force-pushed the cesar/receipt-presented-paywall-workflow-ids branch from 9e22cc1 to 264d2e9 Compare June 18, 2026 16:38
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.

1 participant