Enforce Rules For Analytics enforce-rules-for-analytics
Design minimal, three-tier product analytics events in AIRI, separate client interactions, server funnel anchors, and read-only reporting, and get user confirmation before adding tracking. Use after finishing any new user-facing feature, or whenever you plan, add, edit, or review analytics events in `use-analytics.ts`, `packages/stage-ui/src/libs/product-signals/`, `apps/ui-server-auth/`, or `server/apps/api/`.
- Our test
- 9/10✓ Verified
- tested Dec 6, 2026
- GitHub stars
- 52k
- moeru-ai/airi
- Added by
- 0
- members
- Updated
- Dec 6
- commit f28d10e
- Content
- 1 file
- no scripts · 5 KB
- License
- MIT
- free to use
What our test found
The skill gives a clear, privacy-conscious workflow for proposing minimal, tiered analytics and requires user approval before implementation.
Limits spotted
- The skill assumes specific AIRI files and services exist, so it may need adaptation outside that repository.
- The 90-day removal rule may be too rigid for seasonal or infrequently used product events.
name: enforce-rules-for-analytics description: Design minimal, three-tier product analytics events in AIRI, separate client interactions, server funnel anchors, and read-only reporting, and get user confirmation before adding tracking. Use after finishing any new user-facing feature, or whenever you plan, add, edit, or review analytics events in `use-analytics.ts`, `packages/stage-ui/src/libs/product-signals/`, `apps/ui-server-auth/`, or `server/apps/api/`.
Enforce AIRI Product Analytics Rules
Product analytics providers bill by event volume. Redundant impressions and duplicate triggers raise monthly costs without improving decisions. Keep every tracking plan minimal, layered by source of truth, and approved by the user.
Three-Tier Ownership Model
Assign each metric to one tier before you propose an event.
| Tier | Owns | Emitted by | Examples | | --- | --- | --- | --- | | 1. Client interaction | UI behavior that the server cannot see | Client via useAnalytics() or auth analytics | announcement_viewed, announcement_action_clicked, pricing_page_viewed, onboarding_step_completed | | 2. Server funnel anchor | Low-volume business outcomes that join funnels and retention cohorts | Backend via productEventService | signup_completed, checkout_created, payment_completed, daily_checkin_completed | | 3. Read-only reporting and warehouse | Exact financial totals, budgets, operational telemetry, and state snapshots | Read-only Postgres, Data Warehouse sync, or Prometheus | Revenue totals, Flux ledger, LLM/TTS/ASR token counts, inbox delivery and read rates |
- Keep marketing funnels and retention cohorts out of the primary OLTP database. Emit one low-volume server anchor event when PostHog needs a business outcome for funnel or cohort joins.
- Keep exact revenue, billing reconciliation, and per-request AI telemetry in Tier 3. Client tracking loses 5 to 15 percent of events to blockers and disconnects.
- When analytics needs cross-table business joins inside PostHog, use incremental Data Warehouse sync from a read-only database. Never emit client mirror events for backend tables.
Core Principles
- Track for product decisions. Drop any event that informs no concrete decision.
- Put context such as
trigger,surface,source, orprocessorinto event properties. Keep one event per user moment. - Reuse existing events as denominators. Use
app_loadedor page views for reach. Never fire passive*_deliveredor*_exposedevents. - Never fire two concurrent events for one user moment. For example, fold
trigger: 'auto' | 'manual' | 'switch'intoannouncement_viewedand omitannouncement_opened. - Never emit client-side duplicates of confirmed business outcomes. Let the server emit the canonical anchor event once.
- Keep payloads low-cardinality. Send only stable IDs, booleans, counts, and enums. Never send user text, URLs, emails, or private data.
- Route client events through
useAnalytics()inpackages/stage-ui/src/composables/use-analytics.ts. Route server anchor events throughproductEventServiceinserver/apps/api/src/services/domain/product-events.ts.
Mandatory User Confirmation Gate
Do not add analytics events silently. After you implement a user-facing feature, follow this sequence:
- Check existing events in
use-analytics.ts,product-events.ts, and backend tables. - Assign each metric to Tier 1, Tier 2, or Tier 3. Remove any event that existing events or Tier 3 already cover.
- Present a compact proposal table to the user:
| Event | Tier | Trigger | Volume tier | Why needed | Decision informed | | --- | --- | --- | --- | --- | --- | | <object_action> | client / server | <exact moment> | low / medium / high | <reason> | <decision> |
- Ask the user which events to add, or whether to add none.
- Implement only the events that the user approves.
Naming and Hygiene
- Name events in lowercase
snake_caseusing theobject_actionformat, for exampleannouncement_viewedorpayment_completed. - Deduplicate client view events per open session so polling and re-renders emit one record.
- Deduplicate server anchor events with a stable
eventIdso webhook retries emit one record. - Do not add analytics events for bug fixes, copy or style updates, or internal refactors with unchanged behavior.
- During routine audits, remove custom events that no dashboard queried in the last 90 days. Update or remove downstream queries when you retire an event.
Review Checklist
- Did the user confirm every new event in this PR?
- Does each metric live in the right tier (client interaction, server anchor, or read-only reporting)?
- Can an existing event (
app_loaded, page views) supply the denominator without a passive event? - Does any user action fire two events at the same instant?
- Are all properties low-cardinality and free of user text, URLs, and private data?
- Does every client event go through
useAnalytics()with unit tests inuse-analytics.test.ts? - Does every server anchor event go through
productEventServicewith dedupe coverage?