home / skills / onekeyhq / app-monorepo / 1k-sentry-analysis

1k-sentry-analysis skill

/.claude/skills/1k-sentry-analysis

This skill analyzes Sentry crash reports, identifies root causes, and prepares evidence-based bug analysis logs before requesting user confirmation.

npx playbooks add skill onekeyhq/app-monorepo --skill 1k-sentry-analysis

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.8 KB
---
name: 1k-sentry-analysis
description: Analyze and fix production errors from Sentry crash reports (AppHang, ANR, crashes, stacktraces).
allowed-tools: Read, Grep, Glob, Write, Edit, Bash
disable-model-invocation: true
---

# Sentry Error Analysis & Fixes

Complete workflow for analyzing and fixing production errors from Sentry crash reports.

## Workflow Overview

```
1. Obtain Sentry JSON log
   ↓
2. Analyze error
   ↓
3. Identify root cause
   ↓
4. Generate bug analysis log
   ↓
🚨 WAIT FOR USER CONFIRMATION 🚨
   ↓
5. Implement fix (only after approval)
   ↓
6. Test & verify
   ↓
7. Create PR
```

## Critical Requirements

**MUST follow these rules:**

1. βœ… **Always create a bug analysis log** in `node_modules/.cache/bugs/` before implementing fixes
2. 🚨 **MUST wait for user confirmation** before starting any code changes
3. βœ… **Bug analysis must be complete** with all sections filled
4. βœ… **Use evidence-based methodology** (ηŽ―ηŽ―η›Έζ‰£οΌŒι€ζ­₯ι€’θΏ›)

## Quick Reference

### Common Error Types

| Type | Description | Common Causes |
|------|-------------|---------------|
| AppHang | iOS app frozen >5s | Too many concurrent requests, main thread blocking |
| ANR | Android Not Responding | Heavy operations on main thread, deadlocks |
| Crash | App terminated | Null pointer, memory issues, unhandled exceptions |
| Exception | Handled error | Network failures, validation errors, state issues |

### Analysis Methodology

Use **6 types of proof** to establish causation:

1. **Stack Trace Evidence** - Error location in code
2. **Breadcrumbs Evidence** - User actions leading to error
3. **Code Logic Evidence** - Why the code causes the issue
4. **Timing Evidence** - When and how often it occurs
5. **Device/Platform Evidence** - Affected platforms/devices
6. **Fix Verification** - Testing confirms fix works

### Common Fix Patterns

```typescript
// Pattern 1: Concurrent request control
async function executeBatched<T>(
  tasks: Array<() => Promise<T>>,
  concurrency = 3,
): Promise<Array<PromiseSettledResult<T>>> {
  const results: Array<PromiseSettledResult<T>> = [];
  for (let i = 0; i < tasks.length; i += concurrency) {
    const batch = tasks.slice(i, i + concurrency);
    const batchResults = await Promise.allSettled(
      batch.map((task) => task()),
    );
    results.push(...batchResults);
  }
  return results;
}

// Pattern 2: Main thread offloading (React Native)
import { InteractionManager } from 'react-native';

InteractionManager.runAfterInteractions(() => {
  // Heavy operation here
});

// Pattern 3: Error boundary
<ErrorBoundary fallback={<ErrorFallback />}>
  <Component />
</ErrorBoundary>
```

## Detailed Guide

For comprehensive Sentry error analysis workflow, see [fix-sentry-errors.md](references/rules/fix-sentry-errors.md).

Topics covered:
- Obtaining Sentry JSON logs
- Python-based quick analysis
- Bug analysis log template
- 6 types of proof methodology
- Root cause identification
- Common fix patterns (AppHang, ANR, Crashes)
- Real-world case studies
- Testing and verification
- PR creation workflow

## Key Files

| Purpose | Location |
|---------|----------|
| Bug analysis logs | `node_modules/.cache/bugs/` |
| Sentry config | `packages/shared/src/modules/sentry/` |
| Error boundaries | `packages/kit/src/components/ErrorBoundary/` |

## When to Use This Skill

- Analyzing iOS AppHang errors (5+ second freezes)
- Fixing Android ANR (Application Not Responding)
- Investigating crash reports with stack traces
- Understanding user actions before crashes (breadcrumbs)
- Creating evidence-based bug analysis reports
- Implementing fixes for production errors

## Related Skills

- `/1k-performance` - Performance optimization patterns
- `/1k-error-handling` - Error handling best practices
- `/1k-sentry` - Sentry configuration and filtering
- `/1k-code-quality` - Lint fixes and code quality

Overview

This skill analyzes Sentry crash reports and produces evidence-based bug analysis logs, then guides safe fixes for AppHang, ANR, crash, and exception reports. It focuses on reproducible root-cause identification, a required pre-change analysis artifact, and a gated workflow that waits for developer approval before code edits. The goal is reliable, testable fixes for mobile and desktop crypto wallet codebases.

How this skill works

Ingest a Sentry JSON log and extract stack traces, breadcrumbs, device metadata, and timestamps. Produce a complete bug analysis log in node_modules/.cache/bugs/ that contains six types of proof (stack trace, breadcrumbs, code logic, timing, device, and fix verification). After user confirmation, recommend or implement fixes using common patterns (concurrency control, main-thread offload, error boundaries) and provide testing and PR guidance.

When to use it

  • Investigating iOS AppHang events (UI frozen >5s)
  • Resolving Android ANR reports tied to main-thread work or deadlocks
  • Analyzing crashes with native or JavaScript stack traces
  • Gathering evidence from breadcrumbs and device metrics before fixes
  • Preparing an auditable bug analysis log required for production changes

Best practices

  • Always create a complete bug analysis log in node_modules/.cache/bugs/ before coding
  • Do not start code changes until explicit user or maintainer confirmation is given
  • Use the six-proof methodology to tie error to root cause with measurable evidence
  • Prefer non-invasive fixes first: limit concurrency, offload heavy work, add error boundaries
  • Include regression tests or manual verification steps and document verification results

Example use cases

  • Limit concurrent network requests when AppHang reports show many simultaneous calls
  • Offload heavy initialization work with InteractionManager.runAfterInteractions in React Native to fix ANRs
  • Add ErrorBoundary wrappers around unstable components to catch UI exceptions
  • Investigate a native crash by correlating device model and OS version from Sentry metadata
  • Generate a reproducible test case and verification checklist before creating a PR

FAQ

Do I have to create a bug analysis log every time?

Yes. A complete bug analysis log saved under node_modules/.cache/bugs/ is required before any code changes.

When can fixes be implemented?

Only after the analysis log is reviewed and explicit user or maintainer confirmation is received.

What evidence should the analysis include?

Include stack trace, breadcrumbs, code logic explanation, timing/frequency data, affected devices/platforms, and a planned verification method.