Product Decisions This Supports
- Build vs. Buy: Buy – Eliminates the need to build custom analytics pipelines for tracking business metrics (e.g., subscriptions, orders, users) over time. Reduces engineering effort by ~30-50% for teams needing granular, time-series data.
- Feature Roadmap:
- Business Intelligence (BI) Dashboards: Enables real-time or near-real-time metrics for SaaS platforms (e.g., MRR/ARR tracking, churn analysis).
- Multi-Tenant Analytics: Supports tenant-specific stats (e.g., per-customer usage metrics) via relationships.
- A/B Testing: Tracks incremental changes (e.g., feature adoption rates) by time periods.
- Compliance/Reporting: Precisely logs historical data for audits (e.g., GDPR, financial reporting).
- Use Cases:
- SaaS Metrics: Track active users, subscriptions, cancellations, or revenue by time (daily/weekly/monthly).
- E-Commerce: Monitor order volumes, conversions, or cart abandonment rates.
- Internal Tools: Log system events (e.g., API calls, background job executions) for operational insights.
- Custom Aggregations: Extend beyond default stats (e.g., track "premium feature usage" alongside core metrics).
When to Consider This Package
Adopt if:
- Your Laravel app needs time-series tracking of business-critical metrics (e.g., subscriptions, orders) with flexible granularity (minute → year).
- You require low-code integration for stats that update via events (e.g.,
SubscriptionStats::increase() on signup).
- Your team lacks bandwidth to build a custom solution (e.g., no dedicated data engineering resources).
- You need multi-dimensional stats (e.g., track metrics per tenant, user segment, or feature flag).
- Compliance or reporting demands immutable historical records of metric changes.
Look elsewhere if:
- You need real-time dashboards with sub-second latency (this package is optimized for batch queries).
- Your use case requires complex aggregations (e.g., percentiles, moving averages) beyond
increase/decrease/set.
- You’re using a non-Laravel stack (though the core logic could be adapted).
- You need high-frequency writes (e.g., IoT sensor data) – consider a dedicated time-series DB like InfluxDB.
- Your metrics are read-heavy with ad-hoc queries (e.g., "show me all stats for Q1 2023 where
value > 1000") – a data warehouse (e.g., PostgreSQL with TimescaleDB) may be better.
How to Pitch It (Stakeholders)
For Executives:
"This package lets us track critical business metrics—like subscriptions, orders, or user growth—automatically and accurately over time, without building a custom analytics system. For example, we can instantly see weekly/monthly trends in churn or revenue, enabling faster data-driven decisions. It’s lightweight, integrates seamlessly with Laravel, and supports multi-tenant analytics—perfect for scaling our SaaS metrics infrastructure with minimal engineering overhead."
Key Benefits:
- Speed: Deploy analytics in hours, not weeks.
- Accuracy: Immutable logs of metric changes for compliance/reporting.
- Flexibility: Track anything from users to transactions, with custom groupings (e.g., per tenant).
- Cost: Avoids hiring data engineers or licensing expensive BI tools for basic needs.
For Engineering:
"This is a battle-tested, MIT-licensed package by Spatie that handles the heavy lifting of time-series stats. It’s optimized for Laravel, supports relationships (e.g., tenant-specific metrics), and lets us query data by minute/day/week/month/year. We can extend it for custom use cases (e.g., feature flags) or integrate it with existing dashboards (e.g., Chart.js, Laravel Nova). The migration is trivial, and it plays well with Laravel’s ecosystem."
Trade-offs:
- Not real-time: Queries are optimized for batch analysis (e.g., "show me last 3 months of subscriptions").
- Limited to Laravel: If we ever migrate away, we’d need to rebuild or adapt the logic.
- Storage: Stats are stored in the app’s DB (but can be archived/pruned over time).
Call to Action:
"Let’s pilot this for one high-priority metric (e.g., subscription churn) and compare it to our current manual tracking. If it saves us 20+ hours of dev time and gives us better data, we can roll it out broadly."