fix(billing): cleanup 4 Copilot nits on subscription_changed analytics (#3772)#3773
Conversation
#3772) - Remove redundant try/catch around AnalyticsService.capture() — never throws - Fix comment: billing.plan.changed → plan.changed (matches billingEvents.emit) - Fix stale-event fixture: add previous_attributes.items so stale guard fires - Add same-plan test: exercises previousPlan === newPlan guard with items present
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR removes local error handling from the ChangesSubscription update analytics capture
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Pull request overview
Cleans up four Copilot nits left from PR #3769's subscription_changed analytics emit: removes a dead try/catch, fixes a comment naming mismatch, and tightens two unit tests so they actually exercise the intended guard branches.
Changes:
- Drop redundant try/catch around
AnalyticsService.capture()(the service swallows its own errors) and correct the adjacent comment frombilling.plan.changedtoplan.changed. - Update the stale-event test fixture to include
previous_attributes.itemsso theupdateIfEventNewer → nullguard is what actually prevents capture. - Add a same-plan test case where
previous_attributes.itemsis present butpreviousPlan === newPlan, exercising that explicit guard.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| modules/billing/services/billing.webhook.service.js | Remove dead try/catch around AnalyticsService.capture(); fix comment to reference plan.changed. |
| modules/billing/tests/billing.webhook.subscription-changed-analytics.unit.tests.js | Tighten stale-event fixture and add same-plan guard coverage. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3773 +/- ##
==========================================
+ Coverage 90.15% 90.18% +0.03%
==========================================
Files 151 151
Lines 5006 5003 -3
Branches 1590 1589 -1
==========================================
- Hits 4513 4512 -1
+ Misses 388 386 -2
Partials 105 105
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Summary
Addresses the 4 Copilot nits from issue #3772 left over from the
subscription_changedanalytics PR (#3769):AnalyticsService.capture()— the service wrapsclient.capturein its owncatch (_) {}and is documented to never throw; the outer catch was dead codebilling.plan.changedbut the code emitsplan.changedviabillingEvents.emit('plan.changed', …); updated to match for grep/trace correctness_mkEvent()with noprevious_attributes.items, which skipped the plan-change branch before reaching the stale guard; fixture now includesprevious_attributes.itemsso theupdateIfEventNewer → nullguard is what prevents captureprevious_attributes.items; added a second case where items IS present andpreviousPlan === newPlanis the guard that firesTest plan
npm run test:unit -- modules/billing/tests/billing.webhook— all 6 tests in the analytics suite pass (verified locally: 1753/1753 total)Summary by CodeRabbit