S
+
C

From Error to Patch

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

Act 1

Sentry Catches an Error

Sentry captures an unhandled TypeError in production. The error count is spiking and users are being affected on the order submission flow.

S
Sentry Issues
Last 24hUnresolved

TypeError: Cannot read properties of undefined (reading 'chargeId')

processPayment • src/services/payment.ts • line 47

1,847 events 312 users affectedFirst seen 47m ago
Error Frequency1,847 events
-24hnow

Events

1,847

+4,200% from baseline

Users Affected

312

In last 47 minutes

Level

P1

Auto-escalated

Stack Trace

>processPaymentsrc/services/payment.ts:47:12
handleOrderSubmitsrc/api/orders/create.ts:89:8
OrderController.createsrc/controllers/order.ts:34:5
routeHandlersrc/middleware/router.ts:112:3

Breadcrumbs

14:23:01navigation/dashboard
14:23:03ui.clickbutton#submit-order
14:23:03fetchPOST /api/orders/create
14:23:04fetch200 GET /api/inventory/check
14:23:04fetchPOST /api/payments/charge
14:23:05errorTypeError: Cannot read properties of undefined
Act 2

Engineer Opens Cursor

The on-call engineer pastes the Sentry error into Cursor. Cursor loads the relevant files and begins tracing the issue through the codebase.

payment.ts
Cursor

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
Act 3

Cursor Traces the Root Cause

Cursor traces the error across multiple files, pinpointing that a Stripe SDK upgrade changed the response shape without updating the mapping layer.

src/services/payment.tsL47
src/services/stripe-client.tsL23
src/types/payment.tsL12
src/api/orders/create.tsL89

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 AI Analysis
Act 4

Fix + Regression Test

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

stripe-client.ts (lines 23-31)
1 // Map Stripe response shape to internal payment type
2 const charge = await stripe.charges.create(params);
3
+ return {
+ chargeId: charge.id, // was: charge.chargeId (pre-v4)
6 status: charge.status,
7 amount: charge.amount,
8 currency: charge.currency,
9 };

Guard: Null Check

payment.ts (lines 44-55)
1export async function processPayment(order: Order) {
2 const response = await stripeClient.charge(order);
+
+ if (!response?.chargeId) {
+ throw new PaymentError(
+ 'Missing chargeId in payment response',
+ { orderId: order.id, response }
+ );
9 }
10
11 return confirmCharge(response.chargeId);
12}

Regression Test

payment.test.ts
+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});

Cursor's Explanation

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

Act 5

Better Together

S
C

Capture Every Error

Sentry captures runtime errors with full stack traces, breadcrumbs, and user context the moment they occur in production.

Fix with Full Context

Cursor analyzes the entire codebase to trace the root cause and generates targeted fixes with defensive guards.

Prevent Regression

Cursor writes regression tests and identifies similar patterns elsewhere in the codebase before they surface as new errors.

0%

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.