1k-analytics
Analytics Event Tracking
OneKey uses a decorator-based logger system to track user behavior events. Events are routed to the analytics server (Mixpanel) via @LogToServer() decorator on scene methods. NEVER call analytics.trackEvent() directly.
Quick Reference
| Topic | Guide | Key Files |
|---|---|---|
| Adding events | adding-events.md | packages/shared/src/logger/scopes/ |
| Architecture | architecture.md | packages/shared/src/logger/base/ |
| Common pitfalls | pitfalls.md | — |
Critical Rules
- MUST use
@LogToServer()decorator — never callanalytics.trackEvent()directly - Event method names use camelCase — the method name becomes the event name sent to Mixpanel
- Methods MUST return params synchronously — never return a Promise
- Deduplicate high-frequency events — prevent Mixpanel usage spikes (e.g., use in-memory Set for per-session dedup)
- Add events to existing scopes when possible — only create new scopes for entirely new feature domains
More from onekeyhq/app-monorepo
react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
109implementing-figma-designs
Implements Figma designs 1:1 using OneKey component library (还原设计稿).
771k-coding-patterns
Coding patterns and best practices — React components, promise handling, and TypeScript conventions.
691k-code-quality
Code quality standards — lint (eslint/oxlint), type check (tsc), pre-commit hooks, and comment conventions. All comments must be in English.
681k-date-formatting
Date and time formatting — use OneKey dateUtils (formatDate/formatTime) instead of native JS date methods.
681k-git-workflow
Git workflow and conventions — branching, commit messages, and PR creation.
68