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 and summarize database stat changes over time. Create a stats class, call increase/decrease on events, then query totals and deltas over ranges grouped by day/week/month for easy reporting.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. Buy: Eliminates the need to build custom analytics pipelines for tracking incremental/decremental metrics (e.g., subscriptions, orders, user activity). Reduces technical debt by leveraging a battle-tested, open-source solution.
  • Feature Roadmap:
    • Real-time dashboards: Integrate with Laravel Nova/Forge for visualizing trends (e.g., MRR/ARR growth).
    • Multi-tenancy: Extend StatsWriter to support tenant-aware metrics (e.g., per-tenant subscription counts).
    • Alerting: Trigger notifications (e.g., Slack/email) when metrics cross thresholds (e.g., churn spikes).
    • Export/Reporting: Add endpoints to export stats to CSV/Excel or sync with BI tools (e.g., Google Data Studio).
  • Use Cases:
    • Subscription SaaS: Track churn, upgrades/downgrades, and revenue recognition.
    • E-commerce: Monitor order volume, cancellations, and cart abandonment.
    • Gaming/Engagement: Measure daily active users (DAU), sessions, or in-app events.
    • API/External Integrations: Sync stats from third-party APIs (e.g., Stripe, PayPal) via set() method.

When to Consider This Package

  • Adopt if:

    • You need lightweight, time-series tracking of incremental/decremental metrics (no full analytics suite required).
    • Your team lacks resources to build a custom solution (e.g., no dedicated data team).
    • You’re using Laravel and want to avoid reinventing the wheel for basic metric tracking.
    • You need granular time-based aggregation (minute/day/week/month/year) without complex setup.
    • Your use case aligns with simple counters (e.g., "subscriptions," "orders," "logins") rather than complex event tracking (consider Laravel Scout or custom event stores for those).
  • Look elsewhere if:

    • You need real-time analytics (e.g., live dashboards with sub-second updates) → Consider Laravel Echo + Pusher or GraphQL subscriptions.
    • You require advanced segmentation (e.g., cohort analysis, funnel tracking) → Evaluate Mixpanel, Amplitude, or Laravel Analytics.
    • Your metrics are non-numeric (e.g., text logs, JSON blobs) → Use Laravel Logging or ELK Stack.
    • You’re on a non-Laravel stack (e.g., Django, Node.js) → Use framework-specific alternatives.
    • You need scalability beyond 10M+ events/month → Consider TimescaleDB or ClickHouse with custom instrumentation.

How to Pitch It (Stakeholders)

For Executives:

*"This package lets us track critical business metrics (e.g., subscriptions, revenue, user activity) with minimal engineering effort. Instead of spending weeks building a custom analytics system, we can:

  • Reduce churn risk by monitoring real-time trends (e.g., cancellations, upgrades).
  • Cut costs by avoiding paid tools for basic metrics (e.g., Stripe + custom scripts).
  • Enable data-driven decisions with historical trends (e.g., 'Our DAU dropped 15% last month—why?'). It’s lightweight, open-source, and integrates seamlessly with Laravel. For ~$0 in licensing, we gain visibility into our core KPIs without hiring a data team."*

Ask: "Which metrics would give us the most insight if we could track them in real time?"


For Engineering:

*"This is a drop-in solution for tracking incremental/decremental metrics in Laravel. Key benefits:

  • Zero setup for basic use cases: Just extend BaseStats and call increase()/decrease() in your business logic.
  • Flexible querying: Fetch trends by minute/day/week/month with a fluent API (e.g., SubscriptionStats::query()->groupByWeek()->get()).
  • Extensible: Supports:
    • Custom models (e.g., StatsWriter::for(MyModel::class)).
    • Relationships (e.g., per-tenant stats via StatsWriter::for($tenant->orders)).
    • Time-travel adjustments (e.g., increase(1, $pastDate) for backfilling).
  • Performance: Optimized for read-heavy workloads (e.g., dashboards) with minimal write overhead.
  • Future-proof: Actively maintained (Laravel 10/11/13 support), MIT-licensed, and community-backed.

Trade-offs:

  • Not a full analytics suite (no user segmentation, event tracking, or real-time dashboards).
  • Requires manual integration into business logic (e.g., calling increase() in subscription controllers).

Proposal:

  1. Pilot: Track 2–3 high-priority metrics (e.g., subscriptions, orders) for 2 weeks.
  2. Integrate: Add a StatsService facade to centralize metric calls (e.g., Stats::track('subscriptions')).
  3. Extend: Build a simple Laravel Nova resource to visualize trends.

Ask: "Which metrics should we prioritize for the MVP, and where should we hook into existing code?""*

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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai