Analytics Events
Use this skill to keep analytics instrumentation accurate, consistent, and release-ready.
When to Use
- A feature needs new or updated product analytics tracking.
- Event naming/properties have drifted and require normalization.
- You need pre-release verification for event quality.
Workflow
- Define analytics goals and map them to concrete user/system events.
- Standardize schema: event names, required properties, types, and ownership.
- Implement instrumentation at reliable trigger points with minimal duplication.
- Validate payloads locally/staging against schema and expected cardinality.
- Add monitoring for event volume anomalies and ingestion failures.
- Document taxonomy updates and communicate downstream reporting impacts.
Event Taxonomy Patterns
Use object_action naming: button_clicked, page_viewed, form_submitted, item_added_to_cart. Object is the UI element or entity; action is the verb. Avoid generic names like click or event_1. Examples: checkout_started, payment_method_selected, subscription_cancelled.
Schema Governance
JSON Schema validation: Define a schema per event type with required properties, types, and enums. Validate payloads at SDK send time and in a pipeline stage before ingestion. Reject invalid events with clear error codes.
Breaking change detection: Version event schemas. Treat new required properties, removed properties, or type changes as breaking. Use a compatibility matrix and deprecation windows. Run schema diff in CI before merge.
Instrumentation Patterns
SDK initialization: Initialize once at app load with api_key, endpoint, and options. Set user_id, session_id, and environment in context. Do not re-initialize per event.
Batching: Buffer events and flush on interval (e.g., 5s) or batch size (e.g., 10). Reduces network calls and improves throughput. Ensure flush on page unload or app background.
Retry: Retry failed sends with exponential backoff. Use a dead-letter queue or local persistence for events that fail after max retries. Do not drop silently.
Common Pitfalls
- Event naming inconsistency: Mixing
button_click and ButtonClicked and btn_clicked breaks aggregation. Enforce snake_case and object_action in lint rules.
- Missing required properties: Omitting
user_id, timestamp, or event-specific required fields causes pipeline rejection or null joins. Validate before send.
- PII leakage: Emailing full names, IPs, or raw identifiers in event properties. Sanitize or hash; use allowlists for approved fields.
- High-cardinality dimensions: Using free-text or unbounded values (e.g.,
search_query) as dimensions explodes storage and slows queries. Use buckets or separate tables for high-cardinality data.
- Silent failures in event pipeline: No alerts on drop rate or validation errors. Add metrics for sent, accepted, rejected, and failed events; alert on anomalies.
Event Specification Pattern
For each event: name, trigger (user action or system condition), required_properties (with types), optional_properties, owner, schema_version. Example: checkout_completed | trigger: user clicks "Place Order" | required: order_id (string), total_amount (number), currency (string) | optional: coupon_code (string) | owner: checkout-team | v1.
Output / Checklist
- Event specification table (name, trigger, properties, owner, schema version).
- Instrumentation points, SDK config (batching, retry), and deduplication strategy.
- JSON Schema snippet or validation rules for each event type.
- Breaking change assessment if modifying existing events.
- Validation evidence from staging/test environments.
- Post-release watchlist: volume metrics, validation error rate, drop rate.
Constraints
- Do not emit PII or sensitive fields without explicit approval.
- Avoid event spam; keep high-cardinality fields intentional and controlled.
- Preserve compatibility with existing dashboards where possible.
1---2id: analytics-events3name: analytics-events4description: Use this skill when keeping analytics instrumentation accurate, consistent, and release-ready across event definitions, tracking plans, schemas, implementation, QA, and governance.5category: DevOps6---78# Analytics Events910Use this skill to keep analytics instrumentation accurate, consistent, and release-ready.1112## When to Use1314- A feature needs new or updated product analytics tracking.15- Event naming/properties have drifted and require normalization.16- You need pre-release verification for event quality.1718## Workflow19201. Define analytics goals and map them to concrete user/system events.212. Standardize schema: event names, required properties, types, and ownership.223. Implement instrumentation at reliable trigger points with minimal duplication.234. Validate payloads locally/staging against schema and expected cardinality.245. Add monitoring for event volume anomalies and ingestion failures.256. Document taxonomy updates and communicate downstream reporting impacts.2627## Event Taxonomy Patterns2829Use **object_action** naming: `button_clicked`, `page_viewed`, `form_submitted`, `item_added_to_cart`. Object is the UI element or entity; action is the verb. Avoid generic names like `click` or `event_1`. Examples: `checkout_started`, `payment_method_selected`, `subscription_cancelled`.3031## Schema Governance3233**JSON Schema validation:** Define a schema per event type with required properties, types, and enums. Validate payloads at SDK send time and in a pipeline stage before ingestion. Reject invalid events with clear error codes.3435**Breaking change detection:** Version event schemas. Treat new required properties, removed properties, or type changes as breaking. Use a compatibility matrix and deprecation windows. Run schema diff in CI before merge.3637## Instrumentation Patterns3839**SDK initialization:** Initialize once at app load with `api_key`, `endpoint`, and `options`. Set `user_id`, `session_id`, and `environment` in context. Do not re-initialize per event.4041**Batching:** Buffer events and flush on interval (e.g., 5s) or batch size (e.g., 10). Reduces network calls and improves throughput. Ensure flush on page unload or app background.4243**Retry:** Retry failed sends with exponential backoff. Use a dead-letter queue or local persistence for events that fail after max retries. Do not drop silently.4445## Common Pitfalls4647- **Event naming inconsistency:** Mixing `button_click` and `ButtonClicked` and `btn_clicked` breaks aggregation. Enforce snake_case and object_action in lint rules.48- **Missing required properties:** Omitting `user_id`, `timestamp`, or event-specific required fields causes pipeline rejection or null joins. Validate before send.49- **PII leakage:** Emailing full names, IPs, or raw identifiers in event properties. Sanitize or hash; use allowlists for approved fields.50- **High-cardinality dimensions:** Using free-text or unbounded values (e.g., `search_query`) as dimensions explodes storage and slows queries. Use buckets or separate tables for high-cardinality data.51- **Silent failures in event pipeline:** No alerts on drop rate or validation errors. Add metrics for sent, accepted, rejected, and failed events; alert on anomalies.5253## Event Specification Pattern5455For each event: `name`, `trigger` (user action or system condition), `required_properties` (with types), `optional_properties`, `owner`, `schema_version`. Example: `checkout_completed` | trigger: user clicks "Place Order" | required: `order_id` (string), `total_amount` (number), `currency` (string) | optional: `coupon_code` (string) | owner: checkout-team | v1.5657## Output / Checklist5859- Event specification table (name, trigger, properties, owner, schema version).60- Instrumentation points, SDK config (batching, retry), and deduplication strategy.61- JSON Schema snippet or validation rules for each event type.62- Breaking change assessment if modifying existing events.63- Validation evidence from staging/test environments.64- Post-release watchlist: volume metrics, validation error rate, drop rate.6566## Constraints6768- Do not emit PII or sensitive fields without explicit approval.69- Avoid event spam; keep high-cardinality fields intentional and controlled.70- Preserve compatibility with existing dashboards where possible.