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 Activitylog Laravel Package

spatie/laravel-activitylog

Log user and model activity in Laravel with an easy API. Manually record actions or automatically log Eloquent events, attach subjects/causers and custom properties, and query everything via the Activity model stored in the activity_log table.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Audit Logging for Compliance & Security

    • Enable GDPR, HIPAA, or SOC2 compliance by tracking user actions (e.g., CRUD operations, sensitive data access).
    • Justify "why" decisions with immutable logs (e.g., "User X deleted Record Y at Z time").
  • User Activity Tracking for Analytics

    • Power feature adoption dashboards (e.g., "Which users are engaging with X feature?").
    • Build "recent activity" feeds for admin panels or user profiles (e.g., "You updated your profile 2 hours ago").
  • Debugging & Operational Insights

    • Replace manual dd() debugging with structured logs for post-mortems (e.g., "Why did this order fail?").
    • Correlate user actions with system events (e.g., "User triggered a payment retry at [timestamp]").
  • Roadmap: Event-Driven Architecture

    • Decouple logging from business logic by emitting events (e.g., ActivityLogged) to trigger notifications, analytics, or workflows.
    • Example: Auto-generate Slack alerts for critical actions (e.g., "Admin deleted a customer record").
  • Build vs. Buy: Avoid Custom Solutions

    • Replace ad-hoc logging (e.g., Log::info()) with a standardized, queryable audit trail.
    • Reduce dev time for features like:
      • "Show me all edits to this record."
      • "Who accessed this data in the last 30 days?"
  • Use Cases

    • Admin Panels: Activity feeds for user/admin actions (e.g., "Last login: 5 mins ago").
    • Customer Support: Reconstruct user sessions for troubleshooting (e.g., "User reported a bug after X action").
    • Fraud Detection: Flag unusual patterns (e.g., rapid-fire edits to a record).
    • Changelogs: Auto-generate release notes from model changes (e.g., "Updated price from $10 to $15").

When to Consider This Package

Adopt if:

  • Your Laravel app requires immutable audit trails for compliance, debugging, or analytics.
  • You need fine-grained control over what gets logged (e.g., only track Post updates, not Comment deletes).
  • Your team lacks time to build a scalable logging system from scratch (handles batch inserts, soft deletes, and custom properties).
  • You’re using Laravel 10+ (or plan to upgrade) and need PHP 8.2+ compatibility.
  • You want built-in querying (e.g., "Show me all activities for this user/model in the last week").

Look elsewhere if:

  • You need real-time streaming logs (consider Laravel Echo + custom WebSocket solution).
  • Your app is not Laravel-based (package is Laravel-specific).
  • You require cross-language support (e.g., logging from Node.js/Python).
  • You need advanced analytics (e.g., ML-based anomaly detection)—consider pairing with a dedicated tool like Sentry or Datadog.
  • Your logging needs are extremely high-volume (e.g., >10K ops/sec)—may need a dedicated time-series DB like ClickHouse.

How to Pitch It (Stakeholders)

For Executives:

*"This package lets us automatically track every critical action in our app—like a digital breadcrumb trail—without writing custom code. It’s like adding a ‘black box recorder’ to our software, which helps with:

  • Compliance: Prove we’re following GDPR/SOC2 rules if audited.
  • Trust: Show customers we’re transparent (e.g., ‘Here’s when your data was last accessed’).
  • Efficiency: Spend less time debugging by replaying user sessions.
  • Revenue: Identify which features drive engagement (e.g., ‘Users who use X convert 3x more’).

It’s free, battle-tested (used by 5K+ projects), and integrates seamlessly with our Laravel stack. The cost of not having this? Risk, inefficiency, and lost insights."*

For Engineers:

*"This solves three major pain points:

  1. No more ad-hoc logging: Replace Log::info() spaghetti with a structured, queryable audit log.
  2. Zero boilerplate: Auto-log model events (e.g., Post::updated) with one line of config.
  3. Flexible: Log custom properties, batch operations, and even failed jobs—all stored in a single table.

Example use cases we can tackle immediately:

  • Add an ‘Activity’ tab to admin panels in 2 hours.
  • Debug a production issue by replaying a user’s session in 10 minutes.
  • Build a ‘Last Updated’ timestamp for all models without manual code.

Trade-offs:

  • Adds a activity_log table (~50KB overhead per 1K entries).
  • Requires Laravel 10+ (but worth the upgrade for modern features).

Next steps:

  1. Spike: Install and log 3 key models (e.g., User, Order, Post).
  2. Build a simple query interface (e.g., Activity::forModel($post)->latest()->take(10)).
  3. Integrate with Laravel Horizon for async logging if volume is high.

Alternatives considered:

  • Custom solution: 3–5 dev days to build + maintain.
  • Third-party: Sentry/LogRocket add complexity and cost for this use case. Verdict: This is the lowest-effort, highest-value option."*
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