2.13.1 Analytics — Platform Analytics — Usage and Performance
Platform Analytics provides a unified view of how the system is used and how it performs across tenants, modules, and time. Metrics are collected in a consistent, low-overhead manner and aggregated into queryable datasets suitable for dashboards, reports, and automated monitoring.
Metrics Collection Model
Analytics events are emitted by modules using a standardized schema. Collection is asynchronous to avoid impacting user-facing latency.
Collected dimensions typically include:
Tenant and organization identifiers
Module and feature identifiers
Event type and action
Timestamps and execution context
Example event emission:
event(new AnalyticsEvent([ 'tenant_id' => tenant('id'), 'module' => 'inbox', 'action' => 'message_sent', ]));Aggregation and Storage
Raw events are aggregated into time-series and summary tables optimized for read-heavy workloads. Aggregation windows are deterministic and reproducible.
Aggregation supports:
Hourly and daily rollups
Per-tenant and cross-tenant views
Module-level and feature-level breakdowns
Example rollup job:
AnalyticsAggregator::daily()->run();Usage Metrics
Usage metrics describe how features are consumed rather than how they perform.
Common usage indicators:
Active users per period
Messages sent and received
Content created or published
Automation executions
These metrics inform capacity planning, billing enforcement, and product decisions.
Performance Metrics
Performance metrics capture system behavior under load.
Tracked indicators:
Request latency
Queue processing time
Job failure rates
Resource utilization
Example latency capture:
$timer = microtime(true); $service->execute(); Analytics::latency('service.execute', microtime(true) - $timer);Querying and Dashboards
Analytics data is exposed through read-optimized queries used by dashboards and exports. Queries are scoped and permission-aware.
Example query:
Analytics::query() ->forTenant(tenant('id')) ->where('module', 'notifications') ->sum('count');Retention and Data Governance
Analytics retention follows tenant-level policies. Raw events may be expired earlier than aggregated data to balance insight depth and storage cost.
Retention guarantees:
Predictable expiration
No silent truncation
Audit-friendly aggregation
Security and Isolation
All analytics data is tenant-scoped by default. Cross-tenant analytics is restricted to authorized system roles only. Sensitive identifiers are hashed or omitted where not required.
Access to analytics APIs and dashboards is enforced through role-based permissions.