I designed this co-sell motion to show how Cursor's agent supercharges Sentry's error tracking, automating the path from captured exception to deployed patch.
Enterprises get more value from their existing Sentry investment when Cursor automates the resolution step. Scalable across any Sentry customer.
Scroll to experience the workflow
Sentry captures an unhandled TypeError in production. The error count is spiking and users are being affected on the order submission flow.
TypeError: Cannot read properties of undefined (reading 'chargeId')
processPayment • src/services/payment.ts • line 47
Events
1,847
+4,200% from baseline
Users Affected
312
In last 47 minutes
Level
P1
Auto-escalated
Stack Trace
Breadcrumbs
The on-call engineer pastes the Sentry error into Cursor. Cursor loads the relevant files and begins tracing the issue through the codebase.
You
I'm seeing this Sentry error in production: TypeError: Cannot read properties of undefined (reading 'chargeId') at processPayment (src/services/payment.ts:47:12) 1,847 events affecting 312 users. Can you help me find the root cause?
Cursor AI
I'll analyze the error and trace it through your codebase. Let me look at the payment service and the calling code. Loading context from: - src/services/payment.ts - src/api/orders/create.ts - src/types/payment.ts
Cursor traces the error across multiple files, pinpointing that a Stripe SDK upgrade changed the response shape without updating the mapping layer.
Scanning codebase
38 files analyzed
Tracing call chain
4 related paths found
Identifying root cause
Missing property mapping
Generating fix plan
Map id to chargeId + null guard
Cursor generates the targeted fix in the Stripe client mapping, adds a safety guard in the payment service, and writes a regression test to prevent recurrence.
Fix: Stripe Client Mapping
1// Map Stripe response shape to internal payment type2const charge = await stripe.charges.create(params);3+return {+chargeId: charge.id, // was: charge.chargeId (pre-v4)6status: charge.status,7amount: charge.amount,8currency: charge.currency,9};
Guard: Null Check
1export async function processPayment(order: Order) {2const response = await stripeClient.charge(order);++if (!response?.chargeId) {+throw new PaymentError(+'Missing chargeId in payment response',+{ orderId: order.id, response }+);9}1011return confirmCharge(response.chargeId);12}
Regression Test
+describe('processPayment', () => {+it('handles missing chargeId gracefully', async () => {+mockStripe.charges.create.mockResolvedValue({+id: 'ch_test_123',+status: 'succeeded',+// Note: no chargeId field (Stripe v4 shape)+});++const order = createTestOrder();+const result = await processPayment(order);+expect(result.chargeId).toBe('ch_test_123');+});++it('throws PaymentError when response is null', async () => {+mockStripe.charges.create.mockResolvedValue(null);++await expect(processPayment(createTestOrder()))+.rejects.toThrow(PaymentError);19});20});
The Stripe SDK v4 upgrade changed the charge response shape: the chargeId field was renamed to id. The stripe-client mapping layer was not updated to reflect this, causing processPayment to receive undefined when accessing chargeId. The fix maps charge.id to chargeId in the client layer, and adds a defensive null check in the payment service to catch similar issues in the future.
6 min
Time to generate fix + test
3 files
Changed with full context
2 tests
Regression coverage added
Sentry captures runtime errors with full stack traces, breadcrumbs, and user context the moment they occur in production.
Cursor analyzes the entire codebase to trace the root cause and generates targeted fixes with defensive guards.
Cursor writes regression tests and identifies similar patterns elsewhere in the codebase before they surface as new errors.
Reduction in Time from Error to Patch
When error capture and intelligent code analysis work together, debugging transforms from hours of log-diving to minutes of guided resolution.