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

1k-sentry skill

/.claude/skills/1k-sentry

This skill helps you configure Sentry across desktop, mobile, and web, filter errors, and analyze crash reports for OneKey.

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

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

Files (2)
SKILL.md
3.1 KB
---
name: 1k-sentry
description: Sentry error tracking and monitoring for OneKey. Use when configuring Sentry, filtering errors, analyzing crash reports, or debugging production issues. Covers platform-specific setup (desktop/mobile/web/extension) and error filtering strategies.
---

# Sentry Integration

OneKey uses Sentry for error tracking across all platforms.

## Architecture Overview

```
apps/
├── desktop/app/sentry.ts          # Desktop main process
├── ext/                           # Extension (uses shared)
├── mobile/                        # Mobile (uses shared)
└── web/                           # Web (uses shared)

packages/shared/src/modules3rdParty/sentry/
├── index.ts                       # Web/Extension entry
├── index.native.ts                # React Native entry
├── index.desktop.ts               # Desktop renderer entry
├── basicOptions.ts                # Shared config & error filtering
└── instance.ts                    # Sentry client instance
```

## Platform Detection

```typescript
import platformEnv from '@onekeyhq/shared/src/platformEnv';

platformEnv.isDesktop    // Electron desktop app
platformEnv.isNative     // React Native (iOS/Android)
platformEnv.isWeb        // Web browser
platformEnv.isExtension  // Browser extension
platformEnv.isWebEmbed   // Embedded web components
```

## Common Tasks

### Filter/Ignore Errors

See: [references/rules/ignoring-errors.md](references/rules/ignoring-errors.md)

Key file: `packages/shared/src/modules3rdParty/sentry/basicOptions.ts`

### Analyze Crash Reports

1. Get crash details from Sentry dashboard
2. Identify error type, message, and stack trace
3. Check platform-specific context
4. Use related skills for fixes:
   - Native crashes → `/1k-patching-native-modules`
   - JS errors → Fix in codebase

### Add Custom Context

```typescript
import * as Sentry from '@sentry/react-native'; // or @sentry/browser

// Add breadcrumb
Sentry.addBreadcrumb({
  category: 'action',
  message: 'User clicked button',
  level: 'info',
});

// Set user context
Sentry.setUser({ id: 'user-id' });

// Set tags
Sentry.setTag('feature', 'swap');

// Capture exception with context
Sentry.captureException(error, {
  extra: { additionalData: 'value' },
});
```

## Key Files

| Purpose | File |
|---------|------|
| Error filtering | `packages/shared/src/modules3rdParty/sentry/basicOptions.ts` |
| Desktop main | `apps/desktop/app/sentry.ts` |
| Desktop renderer | `packages/shared/src/modules3rdParty/sentry/index.desktop.ts` |
| Web/Extension | `packages/shared/src/modules3rdParty/sentry/index.ts` |
| Native | `packages/shared/src/modules3rdParty/sentry/index.native.ts` |

## Error Filtering Quick Reference

```typescript
// Filter by error type
const FILTERED_ERROR_TYPES = new Set(['AxiosError', 'HTTPClientError']);

// Filter by exact message
const FILTER_ERROR_VALUES = ['AbortError: AbortError'];

// Filter by pattern (in isFilterErrorAndSkipSentry function)
if (error.value?.includes('PATTERN')) return true;
```

## Related Skills

- `/1k-patching-native-modules` - Fix native crashes found in Sentry
- `/1k-coding-patterns` - Error handling best practices

Overview

This skill integrates Sentry error tracking into the OneKey codebase and documents platform-specific setup, filtering, and analysis workflows. It guides configuring Sentry across desktop, mobile, web, and extension builds and explains how to filter noise and enrich crash reports for faster triage. The goal is to reduce false positives and speed resolution of production issues.

How this skill works

The skill inspects Sentry client setup and shared configuration that runs per platform (desktop main/renderer, React Native, web/extension). It highlights the shared options, error filtering rules, and how to add context (breadcrumbs, tags, user) before capturing exceptions. It also shows how to interpret Sentry events and map them to follow-up fixes (native vs JavaScript).

When to use it

  • Setting up Sentry for a new OneKey platform build (desktop/mobile/web/extension).
  • Tuning error filters to reduce noisy or irrelevant Sentry events.
  • Analyzing crash reports to determine root cause and platform context.
  • Adding breadcrumbs, tags, or user context to improve event triage.
  • Deciding whether an event needs native module patches or code fixes.

Best practices

  • Centralize shared Sentry configuration and platform entry points to keep behavior consistent.
  • Use pattern and type-based filters to ignore known benign errors (e.g., network aborts).
  • Add concise breadcrumbs and tags around risky flows to speed investigation.
  • Set user context only when helpful and compliant with privacy rules.
  • Map Sentry stack traces to platform-specific follow-up skills (native vs JS) for faster remediation.

Example use cases

  • Configure Sentry for Electron: enable main/renderer clients and ensure desktop-specific options load.
  • Filter out frequent Axios/HTTP client noise by adding error types and exact message rules.
  • Investigate a mobile native crash: pull Sentry event, check native context, then open the native patching workflow.
  • Instrument a swap flow with breadcrumbs and tags so later errors show relevant user actions.
  • Add extra metadata before captureException to help correlate errors with feature flags or experiments.

FAQ

How do I ignore a recurring benign error?

Add its type or exact message to the filtering sets or pattern checks in the shared basicOptions filter to skip sending to Sentry.

Which platform should I inspect first for a crash?

Check the platform flag in the Sentry event—native crashes should be handled by native patching workflows, while JS stack traces point to code fixes in the shared or platform renderer code.