Stats registry
Stats consumers receive a StatsEvent whenever a download starts, completes, or fails. The registry is a fan-out: every registered consumer sees every event. Consumers decide what to do. Increment a counter, ship to an analytics backend, write a log line.
| Key | Value |
|---|---|
| Container key | mc_dm.stats_registry |
| Event | mc_dm_stats_handlers |
Built-in consumers
| ID | Class | What it does |
|---|---|---|
built_in_aggregator | MC\DownloadsManager\Stats\BuiltInAggregator | Increments xf_mc_dm_download.download_count and writes per-day rows for AdminCP analytics. |
Interface
namespace MC\DownloadsManager\Stats;
interface StatsConsumer
{
public function consume(StatsEvent $event): void;
}
StatsEvent carries the event type (started, completed, failed), the Download, the DownloadVersion, the DownloadFile, the visitor, and the bytes-served count (for completed).
Wiring an adapter
public static function statsHandlers(StatsRegistry $registry)
{
$registry->register('plausible', new YourAddon\Stats\PlausibleConsumer($apiKey));
}
Stats consumers run after the lifecycle event fires. A consumer that throws will not roll back the download. Failures are caught and logged.