mixpanel-analytics
MixPanel analytics tracking implementation and review Skill for Django4Lyfe optimo_analytics module. Implements new events following established patterns and reviews implementations for PII protection, schema design, and code quality.
What this skill does
# MixPanel Analytics Skill
## When to Use This Skill
Use this Skill in the Django4Lyfe backend when working with MixPanel analytics
tracking in the `optimo_analytics` module:
- `/mixpanel-analytics:implement` – to **implement** new MixPanel tracking events
or update existing ones following established patterns (7-step checklist).
- `/mixpanel-analytics:review` – to **review** MixPanel implementations for
correctness, PII protection, and adherence to Django4Lyfe standards.
## Example Prompts
### Implement Mode
- "Use `/mixpanel-analytics:implement` to add a new event for tracking when a
user completes their profile setup."
- "Run `/mixpanel-analytics:implement svc.surveys.reminder_sent` to add tracking
for survey reminder notifications."
- "Implement MixPanel tracking for the new HRIS CSV validation feature using
`/mixpanel-analytics:implement`."
### Review Mode
- "Run `/mixpanel-analytics:review staged` to check my staged MixPanel changes
for PII violations and pattern compliance."
- "Use `/mixpanel-analytics:review branch` to audit all analytics changes on
this feature branch."
- "Review the entire optimo_analytics module with `/mixpanel-analytics:review all`."
## Modes
This Skill behaves differently based on how it is invoked:
- `implement` mode – invoked via `/mixpanel-analytics:implement`:
- Guides implementation of new MixPanel events through 7 steps.
- Creates constants, schemas, registry entries, service methods, and tests.
- Enforces PII protection and code patterns.
- `review` mode – invoked via `/mixpanel-analytics:review`:
- Audits existing implementations for compliance.
- Checks PII protection, schema design, service patterns, and test coverage.
- Generates structured review reports with severity tags.
## Environment & Context Gathering
When this Skill runs, gather context first:
```bash
# Git context
git branch --show-current
git status --porcelain
git diff --cached --name-only | grep -E "optimo_analytics|mixpanel"
# Analytics module stats
grep -c "^ [A-Z_]* = " optimo_analytics/constants.py 2>/dev/null || echo "0"
grep -c "^class Mxp" optimo_analytics/schemas.py 2>/dev/null || echo "0"
grep -c "MixPanelEvent\." optimo_analytics/registry.py 2>/dev/null || echo "0"
ls -1 optimo_analytics/service/*.py 2>/dev/null | xargs -I{} basename {} .py
```
Read key reference files:
- `optimo_analytics/AGENTS.md` – module-level rules and PII guidelines
- `optimo_analytics/schemas.py` – existing schema patterns
- `optimo_analytics/service/AGENTS.md` – service layer patterns
- `optimo_analytics/tests/AGENTS.md` – test patterns
---
# Implementation Mode
## 7-Step Implementation Checklist
For each new event, complete these steps in order:
### Step 1: Add Event Constant (`optimo_analytics/constants.py`)
```python
# Event naming convention: {prefix}.{object}.{action}[.error]
# Examples:
# - svc.surveys.survey_delivered
# - svc.map.action_plan_created
# - svc.hris_csv.upload.analysis_completed
#
# NOTE: Do NOT include "cron" in event names - use is_cron_job property instead
class MixPanelEvent:
# Add under appropriate section with comment
NEW_EVENT_NAME = "svc.domain.action_name"
```
### Step 2: Create Schema (`optimo_analytics/schemas.py`)
```python
# Schema naming: Mxp{Domain}{Action}EventSchema
# CRITICAL RULES:
# - All UUIDs MUST be strings (str, not UUID)
# - NO PII: no names, emails, phone numbers
# - organization_name IS allowed (business approved)
# - Use STRICT_MODEL_CONFIG (no aliases) or ALIASED_MODEL_CONFIG ($ aliases)
class MxpNewEventSchema(MixpanelSuperEventPropertiesSchema):
"""Properties for svc.domain.action_name event.
Tracked when [describe when this event fires].
"""
# Required fields (no defaults)
employee_id: str = Field(description="Employee UUID as string")
organization_id: str = Field(description="Organization UUID as string")
organization_name: str = Field(description="Organization name for analytics")
role: SystemRole | None = Field(description="User role")
impersonation: bool = Field(description="Is impersonated session")
# Event-specific fields
custom_field: str = Field(description="What this field represents")
# Use STRICT_MODEL_CONFIG for internal-only schemas
# Use ALIASED_MODEL_CONFIG when field names need $ prefix for MixPanel (e.g., $device_id)
model_config = STRICT_MODEL_CONFIG
```
### Step 3: Register in Registry (`optimo_analytics/registry.py`)
```python
# Add import at top
from optimo_analytics.schemas import MxpNewEventSchema
# Add to _EVENT_SCHEMA_REGISTRY dict
_EVENT_SCHEMA_REGISTRY: dict[str, type[MixpanelSuperEventPropertiesSchema]] = {
# ... existing entries ...
MixPanelEvent.NEW_EVENT_NAME: MxpNewEventSchema,
}
```
### Step 4: Add Tracking Helper (`optimo_analytics/service/{domain}.py`)
Choose appropriate service file or create new one:
- `auth.py` - Authentication events
- `survey.py` - Survey lifecycle events
- `risk.py` - Risk calculation events
- `map.py` - Manager Action Pipeline events
- `core.py` - Core/HRIS events
```python
class OptimoMixpanel{Domain}TrackHelper:
"""Helper class for {Domain} event tracking."""
@classmethod
def track_new_event(
cls,
*, # CRITICAL: Force keyword-only arguments
employee_id: str,
# ... other params ...
) -> None:
"""
Track new event (svc.domain.action_name).
Tracked when [describe trigger condition].
Args:
employee_id: Employee UUID as string
"""
try:
cls._track_new_event(
employee_id=employee_id,
# ... pass all args ...
)
except Exception:
# Fire-and-forget: log but don't propagate
logger.exception(
"mixpanel_new_event_tracking_failed",
employee_id=employee_id,
)
@staticmethod
def _track_new_event(
*,
employee_id: str,
# ... other params ...
) -> None:
"""Track new event implementation."""
emp_info = OptimoMixpanelService._fetch_required_emp_info(
employee_id=employee_id
)
properties = MxpNewEventSchema(
employee_id=employee_id,
organization_id=str(emp_info.organization.uuid),
organization_name=emp_info.organization.name,
role=emp_info.role,
impersonation=False,
# ... event-specific fields ...
)
# distinct_id fallback hierarchy:
# 1. User's UUID (primary)
# 2. org_<organization_uuid> (fallback when no user)
# 3. Context-specific: slack_<id>, apikey_<id>, webhook_<id>
distinct_id = employee_id # or f"org_{org_uuid}" if no user
OptimoMixpanelService.track_event(
distinct_id=distinct_id,
event_name=MixPanelEvent.NEW_EVENT_NAME,
properties=properties,
)
```
### Step 5: Export from `__init__.py` (`optimo_analytics/service/__init__.py`)
```python
# Add to imports
from optimo_analytics.service.{domain} import OptimoMixpanel{Domain}TrackHelper
# Add to __all__
__all__ = [
# ... existing ...
"OptimoMixpanel{Domain}TrackHelper",
]
```
### Step 6: Add Tests (`optimo_analytics/tests/test_{event}_event.py`)
```python
"""Tests for {Event} MixPanel tracking."""
from unittest.mock import patch
from uuid import uuid4
import pytest
from optimo_analytics.constants import MixPanelEvent
from optimo_analytics.registry import EVENT_SCHEMA_REGISTRY, is_event_registered
from optimo_analytics.schemas import MxpNewEventSchema
from optimo_analytics.service import OptimoMixpanel{Domain}TrackHelper
pytestmark = [pytest.mark.django_db]
@pytest.fixture(autouse=True)
def eager_jobs(settings):
"""Force synchronous job execution."""
settings.OPTIMO_JOBS_EAGER_MODE = True
yield
settings.OPTIMO_JOBS_EAGER_MODE = False
@pytest.fixtRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.