一键导入
analytics
Use when implementing product analytics, event tracking, user metrics, funnels, or A/B testing in Go, Python, or React applications
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when implementing product analytics, event tracking, user metrics, funnels, or A/B testing in Go, Python, or React applications
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when the user wants to free disk space, investigate disk usage, clean caches, remove unused artifacts, or when disk capacity is high. Also use when asked to "clean up", "free space", "disk full", or "what's using disk space". Always uses AskUserQuestion for every deletion decision.
Use at the start of every conversation and for every user message — orchestrates the full engineering skills suite by understanding intent, clarifying requirements interactively, and invoking the right skills
Use when refactoring Go code, cleaning up legacy codebases, optimizing performance, or enforcing clean architecture boundaries in a Go/Fiber backend
Use when refactoring Python code, cleaning up legacy codebases, optimizing performance, enforcing type safety, or improving clean architecture in a FastAPI backend
Use when refactoring React components, cleaning up legacy frontends, optimizing performance, improving component architecture, or reducing bundle size
Use when reviewing changed code before committing or after completing a feature — checks performance, architecture, type safety, and code quality against project standards
| name | analytics |
| description | Use when implementing product analytics, event tracking, user metrics, funnels, or A/B testing in Go, Python, or React applications |
Instrument your product to understand user behavior. Track what matters, ignore vanity metrics.
Core principle: If you can't measure it, you can't improve it. But tracking everything is as bad as tracking nothing — be intentional.
[object]_[action] — past tense, snake_case
Examples:
user_signed_up
post_created
payment_completed
invitation_sent
feature_activated
interface AnalyticsEvent {
event: string // "user_signed_up"
user_id?: string // authenticated user
anonymous_id?: string // pre-auth (cookie/device)
timestamp: string // ISO 8601
properties: {
// Event-specific data
[key: string]: any
}
context: {
page_url?: string
referrer?: string
utm_source?: string
utm_medium?: string
utm_campaign?: string
device_type?: string // mobile, desktop, tablet
app_version?: string
}
}
| Category | Events | Why |
|---|---|---|
| Acquisition | page_viewed, signup_started, user_signed_up | Where do users come from? |
| Activation | onboarding_completed, first_action_taken, feature_activated | Do users get value? |
| Engagement | session_started, feature_used, content_created | Are users active? |
| Retention | user_returned (daily/weekly), subscription_renewed | Do users come back? |
| Revenue | payment_completed, plan_upgraded, plan_downgraded | Do users pay? |
| Referral | invitation_sent, invitation_accepted, share_clicked | Do users invite others? |
// src/shared/analytics.ts
type EventProperties = Record<string, string | number | boolean>
class Analytics {
private provider: AnalyticsProvider // PostHog, Mixpanel, or custom
track(event: string, properties?: EventProperties): void {
this.provider.track(event, {
...properties,
page_url: window.location.href,
timestamp: new Date().toISOString(),
})
}
identify(userId: string, traits?: Record<string, any>): void {
this.provider.identify(userId, traits)
}
page(name?: string): void {
this.provider.page(name)
}
}
export const analytics = new Analytics(provider)
Usage in components:
function SignupForm() {
const handleSubmit = async (data: SignupData) => {
analytics.track('signup_started', { method: 'email' })
try {
await signup(data)
analytics.track('user_signed_up', { method: 'email', plan: 'free' })
analytics.identify(user.id, { email: user.email, plan: 'free' })
} catch (err) {
analytics.track('signup_failed', { error: err.message })
}
}
}
Track page views:
// In router
useEffect(() => {
analytics.page()
}, [location.pathname])
type AnalyticsService struct {
client AnalyticsClient // PostHog, Segment, or custom
}
func (s *AnalyticsService) Track(ctx context.Context, userID uuid.UUID, event string, properties map[string]any) {
if err := s.client.Enqueue(analytics.Track{
UserId: userID.String(),
Event: event,
Properties: properties,
Timestamp: time.Now(),
}); err != nil {
slog.Error("analytics track failed", "event", event, "error", err)
}
}
// Usage in use case
func (uc *CreateUserUseCase) Execute(ctx context.Context, input CreateUserInput) (*User, error) {
user, err := uc.repo.Create(ctx, input)
if err != nil {
return nil, err
}
uc.analytics.Track(ctx, user.ID, "user_signed_up", map[string]any{
"method": input.SignupMethod,
"plan": "free",
})
return user, nil
}
class AnalyticsService:
def __init__(self, client: AnalyticsClient) -> None:
self._client = client
def track(self, user_id: UUID, event: str, properties: dict[str, Any] | None = None) -> None:
try:
self._client.track(
user_id=str(user_id),
event=event,
properties=properties or {},
timestamp=datetime.utcnow(),
)
except Exception as e:
logger.error("analytics_track_failed", event=event, error=str(e))
| Metric | Definition | How to Measure |
|---|---|---|
| DAU/MAU | Daily/Monthly active users | Unique users with session_started per day/month |
| Activation rate | % of signups who complete key action | users with first_action_taken / user_signed_up |
| Retention (D1/D7/D30) | % of users returning after N days | Users active on day N / users who signed up N days ago |
| Churn rate | % of users who stop using | Users inactive for 30 days / total active users |
| Conversion rate | % of users who pay | payment_completed / user_signed_up |
| ARPU | Average revenue per user | Total revenue / active users |
Page View → Signup Started → Signup Completed → Onboarding → First Value Action → Paid
1000 200 (20%) 150 (75%) 100 (67%) 60 (60%) 15 (25%)
Track drop-off at each step. The biggest drop-off is your biggest opportunity.
// Simple feature flag approach
function useFeatureFlag(flag: string): boolean {
const user = useCurrentUser()
// Hash user ID to get deterministic assignment
const hash = hashCode(`${flag}:${user.id}`) % 100
return hash < 50 // 50/50 split
}
// Usage
function PricingPage() {
const showNewPricing = useFeatureFlag('new-pricing-v2')
analytics.track('pricing_page_viewed', { variant: showNewPricing ? 'new' : 'control' })
return showNewPricing ? <NewPricing /> : <OldPricing />
}
product-spec (success metrics)go-feature / py-feature / react-feature