Skill站外收录 @skilllib/skill-2014279418900852738
ignoring-sentry-errors
提供 Sentry 错误的精细化过滤能力,支持按错误类型、完整消息或部分关键词匹配进行屏蔽,兼顾桌面、移动端、网页及浏览器插件等多平台环境,确保仅上报真正影响用户体验的问题。
开发运维 AI 技能
Skills.MD
# Ignoring Sentry Errors
Follow this workflow to add new error filters to Sentry configuration.
## Key File
All error filtering logic is centralized in:
```
packages/shared/src/modules3rdParty/sentry/basicOptions.ts
```
## Workflow
### 1) Analyze the error
Identify the error pattern:
- **Error type** (e.g., `Error`, `TypeError`, `AxiosError`)
- **Error message/value** (the text content)
- **Platform** (desktop/mobile/web/extension or all)
- **Frequency** (sporadic vs constant)
- **Impact** (blocks users or just noise)
### 2) Choose filtering strategy
**Option A: Filter by error type** (recommended for known error classes)
Add to `FILTERED_ERROR_TYPES` Set:
```typescript
const FILTERED_ERROR_TYPES = new Set([
'AxiosError',
'HTTPClientError',
// Add your error type here
'YourErrorType',
]);
```
**Option B: Filter by exact message match**
Add to `FILTER_ERROR_VALUES` array:
```typescript
const FILTER_ERROR_VALUES = ['AbortError: AbortError', 'cancel timeout'];
```
**Option C: Filter by partial message match** (for dynamic messages)
Add to `isFilterErrorAndSkipSentry` function:
```typescript
// Platform-specific filter (group with existing platform checks)
if (platformEnv.isDesktop && error.value) {
if (error.value.includes('YOUR_ERROR_PATTERN')) {
return true;
}
}
// Cross-platform filter
if (error.value && error.value.includes('YOUR_ERROR_PATTERN')) {
return true;
}
```
### 3) Implementation pattern
For platform-specific errors, group checks to minimize redundant conditions:
```typescript
// Desktop-specific error filters (grouped)
if (platformEnv.isDesktop && error.value) {
// Filter 1
if (error.value.includes('Pattern1')) {
return true;
}
// Filter 2 (check shorter string first for performance)
if (
error.value.includes('ShortPattern') &&
error.value.includes('LongerPatternForSpecificity')
) {
return true;
}
}
```
### 4) Verify changes
```bash
yarn eslint packages/shared/src/modules3rdParty/sentry/basicOptions.ts --quiet
```
## Platform Detection
Use `platformEnv` for platform-specific filtering:
```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
```
## Best Practices
1. **Check shorter strings first** - Better performance for `includes()` chains
2. **Group platform checks** - Avoid redundant `platformEnv` evaluations
3. **Add comments** - Explain why the error is being filtered
4. **Preserve local logging** - Filtered errors still get logged via `onError` callback
5. **Be specific** - Use multiple `includes()` for dynamic messages to avoid false positives
## Example: Filtering Electron webview errors
```typescript
// Filter Electron webview connection closed error (network interruption during webview loading)
// Check shorter string first for better performance
if (
error.value.includes('ERR_CONNECTION_CLOSED') &&
error.value.includes('GUEST_VIEW_MANAGER_CALL')
) {
return true;
}
```
## Related Files
- Main Sentry config: `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`
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「ignoring-sentry-errors」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次