-
Notifications
You must be signed in to change notification settings - Fork 275
fix: parse subscriptionOffers for iOS subscription products #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add _parseSubscriptionOffersIOS helper function - Parse subscriptionOffers from native iOS data in ProductSubscriptionIOS - Add unit test for subscriptionOffers parsing Fixes #616 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdded numeric-coercion helpers and a new private Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #617 +/- ##
==========================================
+ Coverage 67.68% 68.11% +0.43%
==========================================
Files 7 7
Lines 1479 1521 +42
==========================================
+ Hits 1001 1036 +35
- Misses 478 485 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary of ChangesHello @hyochan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug where iOS subscription offers were not being correctly parsed and exposed in "ProductSubscriptionIOS" objects. By introducing a new helper function and integrating it into the product parsing flow, it ensures that all relevant details of introductory and promotional offers, including their payment modes, types, and periods, are now accurately extracted from native iOS data. This enhancement provides a more complete and reliable representation of subscription products for iOS. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly implements the parsing of subscriptionOffers for iOS subscription products, which was previously missing. A new helper function, _parseSubscriptionOffersIOS, is introduced to handle this, and it's accompanied by a solid unit test. The parsing logic is robust, with good error handling for different data formats. I've suggested a couple of minor refactorings in the new helper to remove redundant logic in the fallback switch statements, which will improve code clarity and maintainability. Overall, this is a great fix.
Remove cases already handled by fromJson normalization. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@lib/helpers.dart`:
- Around line 713-728: The SubscriptionOffer builder uses direct `as num?` casts
for price, periodCount, timestampIOS, and numberOfPeriodsIOS which will throw if
the platform channel returns numeric values as strings; replace those casts by
calling the existing parse helper(s) (e.g., reuse parsePrice for double-valued
fields such as `price` and `timestampIOS`, and add/use a safe parseInt-like
helper for `periodCount` and `numberOfPeriodsIOS`) when constructing
gentype.SubscriptionOffer so both String and num inputs are handled; if those
helpers are local, hoist them to file-level private functions so they can be
reused in the SubscriptionOffer construction.
🧹 Nitpick comments (1)
lib/helpers.dart (1)
694-711: Nit: rename localvaluetoperiodValuefor clarity.
valueon Line 699 is a very generic name in a function that also processes othermap[…]entries. A more descriptive name reduces cognitive load.♻️ Suggested rename
- final value = (periodMap['value'] as num?)?.toInt() ?? 1; + final periodValue = (periodMap['value'] as num?)?.toInt() ?? 1; gentype.SubscriptionPeriodUnit? unit; if (unitRaw != null) { try { unit = gentype.SubscriptionPeriodUnit.fromJson(unitRaw); } catch (_) { // ignore } } if (unit != null) { - period = gentype.SubscriptionPeriod(unit: unit, value: value); + period = gentype.SubscriptionPeriod(unit: unit, value: periodValue); }
Replace direct `as num?` casts with _toDouble/_toInt helpers to handle both num and String inputs from platform channels. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@lib/helpers.dart`:
- Line 713: The cast on periodMap['value'] is unsafe for String inputs; replace
the explicit "(periodMap['value'] as num?)?.toInt() ?? 1" with a call to the
existing _toInt helper (e.g. "final value = _toInt(periodMap['value']) ?? 1") so
it handles numeric and string cases consistently with how
periodCount/numberOfPeriodsIOS are parsed.
🧹 Nitpick comments (1)
lib/helpers.dart (1)
687-706:WIN_BACKis silently mapped toPromotional— consider documenting or logging this lossy mapping.iOS StoreKit 2 distinguishes win-back offers from promotional offers. Mapping
WIN_BACK/WINBACKtoPromotionalloses that distinction. If theDiscountOfferTypeenum doesn't have aWinBackvariant today, this is the best you can do, but a brief comment explaining why would help future maintainers.
Replace direct cast with _toInt helper for consistency. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
ProductSubscriptionIOS.subscriptionOffersalways being nullsubscriptionOffersfrom native dataChanges
_parseSubscriptionOffersIOShelper function inhelpers.dartsubscriptionOffersfield when creatingProductSubscriptionIOSRelated
Test plan
dart format --set-exit-if-changed .passesflutter analyzepassesflutter testpasses (208 tests)Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation