Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Stats Laravel Package

spatie/laravel-stats

Lightweight Laravel package to track stat changes in your app over time. Create a stats class, call increase/decrease on events (e.g., subscriptions), then query totals, increments, decrements, and differences grouped by day/week/month for any date range.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Data-Driven Decision Making: Enables tracking and analyzing key business metrics (e.g., subscriptions, user growth, revenue) over time, empowering teams to make informed decisions with real-time or historical data.
  • Roadmap Prioritization: Justifies building analytics dashboards or reporting tools by providing a structured, scalable way to collect and aggregate metrics without reinventing the wheel.
  • Build vs. Buy: Avoids custom development for basic stat-tracking logic, reducing engineering effort and maintenance overhead. Ideal for teams prioritizing speed over bespoke solutions.
  • Use Cases:
    • Subscription/Revenue Analytics: Track churn, sign-ups, or cancellations (e.g., SaaS metrics).
    • User Engagement: Monitor active/inactive users, feature adoption, or session trends.
    • Operational Metrics: Measure API calls, error rates, or system performance over time.
    • A/B Testing: Compare stat changes between user groups or experiments.
  • Scalability: Supports granular queries (e.g., daily/weekly/monthly aggregations) without heavy database load, making it suitable for both startups and enterprises.

When to Consider This Package

  • Adopt When:
    • You need lightweight, real-time tracking of discrete metrics (e.g., counts, increments/decrements) without complex aggregations.
    • Your team lacks dedicated analytics infrastructure (e.g., no Mixpanel, Amplitude, or custom ETL pipelines).
    • You’re building a Laravel-based product and want to avoid over-engineering stat collection.
    • You require historical trend analysis (e.g., "How did sign-ups change over the last 6 months?").
    • Compliance or data sovereignty requires self-hosted solutions over third-party tools.
  • Look Elsewhere If:
    • You need real-time dashboards with live updates (consider Laravel Echo + custom frontend integration).
    • Metrics require complex calculations (e.g., averages, medians, or multi-dimensional analysis)—opt for a dedicated analytics DB like ClickHouse or PostgreSQL with TimescaleDB.
    • You’re tracking non-numeric data (e.g., text logs, unstructured events)—use Laravel Logging or ELK Stack.
    • Your scale demands sub-second latency for high-frequency queries (e.g., 10K+ events/sec)—evaluate specialized time-series databases like InfluxDB.
    • You need user segmentation or cohort analysis—combine with Laravel Scout or a dedicated tool like PostHog.

How to Pitch It (Stakeholders)

For Executives:

"This package lets us track critical business metrics—like subscriptions, churn, or user growth—with minimal engineering lift. Instead of spending months building custom analytics, we can deploy a lightweight, self-hosted solution in days. It gives us the data to measure success (e.g., ‘Are we hitting our MRR targets?’) and iterate faster. For example, we could track cancellations in real-time and identify trends before they become problems. It’s cost-effective, scalable, and keeps our data under our control—no vendor lock-in."

For Engineering:

*"Spatie’s Laravel Stats is a battle-tested, MIT-licensed package that handles the boilerplate of incrementing/decrementing metrics and querying historical trends. It’s:

  • Lightweight: No heavy dependencies; integrates seamlessly with Laravel’s ecosystem.
  • Flexible: Supports custom stat classes (e.g., SubscriptionStats, ErrorRateStats) and granular time-based queries (daily/weekly/monthly).
  • Maintainable: Well-documented, actively updated (last release: March 2025), and backed by Spatie’s reputation.
  • Extensible: Can later connect to dashboards (e.g., Laravel Nova, Chart.js) or export to data warehouses.

Use case: If we’re tracking SaaS metrics, we’d define SubscriptionStats::increase() in our checkout flow and SubscriptionStats::decrease() in cancellation logic. Queries like ->groupByWeek()->get() give us the trends we need for reports. It’s a no-brainer for MVP analytics or augmenting existing tools."*

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport