fix(revenuecat): align tools and block with REST v1 API spec#4486
fix(revenuecat): align tools and block with REST v1 API spec#4486waleedlatif1 wants to merge 4 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Fixes and extends key operations: Hardens tool behavior by trimming IDs in URLs, adding centralized Reviewed by Cursor Bugbot for commit e999b64. Configure here. |
Greptile SummaryThis PR aligns all 10 RevenueCat tools and the block UI with the REST v1 API spec, fixing two incorrect endpoints (
Confidence Score: 4/5Safe to merge after addressing the empty subscriber output in update_subscriber_attributes. The new apps/sim/tools/revenuecat/update_subscriber_attributes.ts — the Important Files Changed
Sequence DiagramsequenceDiagram
participant Block as RevenueCat Block
participant Params as params() transform
participant Tool as Tool (e.g. create_purchase)
participant RC as RevenueCat REST v1
Block->>Params: raw UI fields (purchasePlatform, extendByDays, etc.)
Params->>Tool: normalised params (platform, numbers coerced, storeTransactionId mapped)
Tool->>RC: HTTP request (correct URL + X-Platform header)
RC-->>Tool: "200 OK / 4xx {code, message}"
Tool->>Tool: throwIfRevenueCatError(response.clone())
Tool->>Tool: "response.json() -> extractSubscriber / extractCustomer"
Tool-->>Block: "{ success, output: { subscriber, metadata, ... } }"
Reviews (3): Last reviewed commit: "fix(revenuecat): align tools with v1 doc..." | Re-trigger Greptile |
|
@greptile |
|
@cursor review |
- Unwrap {value:{subscriber}} envelope across post-receipts, attributes, entitlements, and Google sub endpoints
- Trim entitlement output to documented fields (expires_date, grace_period_expires_date, product_identifier, purchase_date)
- Add subscriber output fields: last_seen, original_application_version, other_purchases, subscriber_attributes
- create_purchase: productId optional (Google-only required), add introductoryPrice, attributes, updated_at_ms; surface customer + subscriber
- update_subscriber_attributes: read response and surface subscriber
- defer_google_subscription: enforce XOR(extendByDays, expiryTimeMs) and 1-365 range
- get_customer: count active subs by expiry/refund instead of object-key length
|
@greptile |
|
@cursor review |
|
Closing in favor of fresh branch with consolidated changes. |
| }, | ||
|
|
||
| transformResponse: async (response, params) => { | ||
| await throwIfRevenueCatError(response) | ||
| const data = await response.json().catch(() => ({})) | ||
| const subscriber = shapeSubscriber(extractSubscriber(data)) | ||
| return { | ||
| success: response.ok, | ||
| success: true, | ||
| output: { | ||
| updated: response.ok, | ||
| app_user_id: params?.appUserId ?? '', | ||
| updated: true, | ||
| app_user_id: subscriber.original_app_user_id || (params?.appUserId ?? ''), | ||
| subscriber, | ||
| }, |
There was a problem hiding this comment.
subscriber output is always empty for this endpoint
RevenueCat's POST /v1/subscribers/{app_user_id}/attributes returns 200 OK with an empty body (the .catch(() => ({})) guard on line 61 exists precisely because .json() would throw on an empty body). This means extractSubscriber({}) returns {} and shapeSubscriber({}) fills every field with its zero-value default: first_seen: '', original_app_user_id: '', subscriptions: {}, entitlements: {}, etc.
Any downstream block reading output.subscriber.original_app_user_id or output.subscriber.entitlements will always receive empty data, silently. The pre-existing app_user_id output correctly falls back to params?.appUserId, but the new subscriber field cannot: there is no response body to populate it from. Removing subscriber from the output (and its declaration in the outputs spec) or documenting it as always-empty would prevent callers from relying on it.
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e999b64. Configure here.
Summary
refund_google_subscriptionto use/transactions/{storeTransactionId}/refunddelete_customerto readdeletedfield (waswas_deleted)create_purchaseX-Platform required; addedpresentedOfferingIdentifier,paymentModegrant_entitlement:durationnow optional, addedendTimeMs(one-of)defer_google_subscription:extendByDaysnow optional, addedexpiryTimeMs(one-of)throwIfRevenueCatErrorhelper for{code, message}error envelopetools.config.tool→tools.config.paramsto preserve dynamic refstwo_weekduration option; correctedlist_offeringsX-Platform valuesupdate_subscriber_attributesdescription to note requiredupdated_at_msType of Change
Testing
Tested manually; type-check clean
Checklist