feature-flags-android
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePostHog feature flags for Android
适用于Android应用的PostHog功能开关
This skill helps you add PostHog feature flags to Android applications.
本技能可帮助你在Android应用中集成PostHog功能开关。
Reference files
参考文件
- - Android feature flags installation - docs
references/android.md - - Adding feature flag code - docs
references/adding-feature-flag-code.md - - Feature flag best practices - docs
references/best-practices.md
Consult the documentation for API details and framework-specific patterns.
- - Android功能开关安装文档
references/android.md - - 添加功能开关代码文档
references/adding-feature-flag-code.md - - 功能开关最佳实践文档
references/best-practices.md
如需了解API详情和特定框架的实现模式,请查阅相关文档。
Key principles
核心原则
- Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
- Minimal changes: Add feature flag code alongside existing logic. Don't replace or restructure existing code.
- Boolean flags first: Default to boolean flag checks unless the user specifically asks for multivariate flags.
- Server-side when possible: Prefer server-side flag evaluation to avoid UI flicker.
- 环境变量:始终使用环境变量存储PostHog密钥,切勿硬编码。
- 最小化改动:在现有逻辑旁添加功能开关代码,不要替换或重构现有代码。
- 优先使用布尔型开关:默认采用布尔型开关检查,除非用户明确要求多变量开关。
- 尽可能使用服务端评估:优先采用服务端开关评估,以避免UI闪烁。
PostHog MCP tools
PostHog MCP工具
Check if a PostHog MCP server is connected. If available, look for tools related to feature flag management (creating, listing, updating, deleting flags). Use these tools to manage flags directly in PostHog rather than requiring the user to do it manually in the dashboard.
检查是否已连接PostHog MCP服务器。如果已连接,查找与功能开关管理相关的工具(创建、列出、更新、删除开关)。使用这些工具直接在PostHog中管理开关,无需用户在控制面板中手动操作。
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