How Analytics Data Is Collected #
DMSI Analytics collects data through two mechanisms: real-time event capture and daily pre-calculation.
Mechanism 1: Real-Time Event Capture #
DMSI Analytics listens to 27 DDLS Core action hooks. When DDLS Core fires an action (a license is created, a download is logged), DMSI Analytics’ Event_Listener handles it immediately.
What happens:
1. DDLS Core fires a hook (e.g., dmsilm_license_activated)
2. Event_Listener::on_license_activated() runs
3. An event record is queued in memory (not yet in the database)
4. When the page request ends, Event_Collector::flush() bulk-inserts all queued events to wp_dmsilm_analytics_events
Why batch on shutdown? Writing one database row per event would be slow for pages with many actions. Batching to a single INSERT at the end of each page request is more efficient.
Mechanism 2: Daily Metric Pre-Calculation #
Raw events tell you what happened but are slow to query for aggregate metrics. DMSI Analytics runs a nightly calculation job that reads events and pre-calculates metrics like MRR, churn rate, and LTV. These pre-calculated values are stored in wp_dmsilm_analytics_metrics and are what power the dashboard charts.
Data Freshness #
| Data Type | Freshness |
|---|---|
| Events (Real-Time Dashboard) | Near-real-time (written at end of each page request) |
| Pre-calculated metrics (all other pages) | Updated nightly at 2:00 AM |
| Churn risk scores | Updated nightly |
| LTV predictions | Updated nightly |
