error-tracking-android
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePostHog error tracking for Android
适用于Android的PostHog错误追踪
This skill helps you add PostHog error tracking to Android applications.
本技能可帮助你为Android应用添加PostHog错误追踪功能。
Reference files
参考文件
- - Android error tracking installation - docs
references/android.md - - Fingerprints - docs
references/fingerprints.md - - Send error tracking alerts - docs
references/alerts.md - - Monitor and search issues - docs
references/monitoring.md - - Assign issues to teammates - docs
references/assigning-issues.md - - Upload source maps - docs
references/upload-source-maps.md
Consult the documentation for API details and framework-specific patterns.
- - Android错误追踪安装文档
references/android.md - - 指纹识别文档
references/fingerprints.md - - 发送错误追踪告警文档
references/alerts.md - - 监控与搜索问题文档
references/monitoring.md - - 向团队成员分配问题文档
references/assigning-issues.md - - 上传源文件映射文档
references/upload-source-maps.md
如需API详情和特定框架模式,请查阅相关文档。
Key principles
核心原则
- Environment variables: Always use environment variables for PostHog keys and host URLs. Never hardcode them.
- Minimal changes: Add error tracking alongside existing error handling. Don't replace or restructure existing error handling code.
- Autocapture first: Enable exception autocapture in the SDK initialization before adding manual captures.
- Source maps: Upload source maps so stack traces resolve to original source code, not minified bundles.
- Manual capture for boundaries: Use at error boundaries and catch blocks for errors that don't propagate to the global handler.
captureException()
- 环境变量:始终使用环境变量存储PostHog密钥和主机URL,切勿硬编码。
- 最小改动:在现有错误处理基础上添加错误追踪,不要替换或重构现有错误处理代码。
- 自动捕获优先:在SDK初始化时启用异常自动捕获,再添加手动捕获。
- 源文件映射:上传源文件映射,以便将堆栈跟踪解析为原始源代码而非压缩包代码。
- 边界处手动捕获:在错误边界和catch块中使用捕获那些不会传播到全局处理器的错误。
captureException()
Framework guidelines
框架指南
- Adapt dependency configuration to the appropriate build.gradle(.kts) file according to the project gradle version
- Call only once in the Application class's
PostHogAndroid.setup()method, so it's initialized as early as possible and only once.onCreate() - Initialize PostHog in the Application class's method
onCreate() - Ensure every activity has a to accurately track screen views.
android:label
- 根据项目gradle版本,将依赖配置适配到对应的build.gradle(.kts)文件中
- 仅在Application类的方法中调用一次
onCreate(),确保尽早且仅初始化一次。PostHogAndroid.setup() - 在Application类的方法中初始化PostHog
onCreate() - 确保每个Activity都设置了,以准确追踪屏幕视图。
android:label