Daily Metric Calculation Cron #
The daily metric calculation is the most important background job in DMSI Analytics. It transforms raw events into the pre-calculated metrics that power all dashboard charts.
Schedule #
| Property | Value |
|---|---|
| WP-Cron hook | dmsi_analytics_calculate_metrics |
| Frequency | Daily |
| Time | 2:00 AM (server timezone) |
What It Calculates #
The Metric_Calculator orchestrates calculations in this order:
- Revenue (MRR, ARR, total revenue, growth, by-product)
- Customers (count, new, churned, cohorts)
- Licenses (utilization, lifecycle, types)
- Downloads (volume, geo distribution, bandwidth, failures)
- MRR Trends (month-over-month MRR with delta)
- Churn Rate (monthly and cohort churn)
- LTV (per-customer and portfolio average)
- Goals (updates goal progress values)
- Anomaly Detection (checks all monitored metrics for deviations)
- Churn Scores (updates 0-100 risk score for all customers)
Result Storage #
All calculated metrics are stored in wp_dmsilm_analytics_metrics using UPSERT (INSERT … ON DUPLICATE KEY UPDATE). Re-running the calculation for the same day overwrites the earlier results for that period.
Triggering Manually #
To run the calculation outside its schedule:
- Go to DDLS > Analytics > Settings > Data & Maintenance
- Click Run Metric Calculation Now
Or via WP-CLI:
wp cron event run dmsi_analytics_calculate_metrics
How Long It Takes #
On a typical site (thousands of events), the calculation completes in under 30 seconds. On very large sites (hundreds of thousands of events), it may take several minutes. The query profiler logs any queries taking more than 0.5 seconds.
