PHPackages                             teaminfinitydev/laravel-activity-log-discord - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. teaminfinitydev/laravel-activity-log-discord

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

teaminfinitydev/laravel-activity-log-discord
============================================

Laravel package for activity logging with Discord webhook integration

1.0.0(10mo ago)632MITPHPPHP ^8.1CI failing

Since Jun 18Pushed 10mo ago2 watchersCompare

[ Source](https://github.com/teaminfinitydev/laravel-activity-log-discord)[ Packagist](https://packagist.org/packages/teaminfinitydev/laravel-activity-log-discord)[ RSS](/packages/teaminfinitydev-laravel-activity-log-discord/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Laravel Activity Log Discord
============================

[](#laravel-activity-log-discord)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7755156dccc520468ae1e7bbbc7820a774f621e3fea190a63f709f3aff89ef25/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465616d696e66696e6974796465762f6c61726176656c2d61637469766974792d6c6f672d646973636f72642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teaminfinitydev/laravel-activity-log-discord)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8c459a31bbdfbd4ae80fdff84dc40d9bf2a5a7b1194dec2e84e1879596f9f04d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7465616d696e66696e6974796465762f6c61726176656c2d61637469766974792d6c6f672d646973636f72642f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/teaminfinitydev/laravel-activity-log-discord/actions?query=workflow%3Atests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a365ee1a81b5e6e350b7153a3e3610d5c9032b6651ddeb6883286850d3e02fcb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7465616d696e66696e6974796465762f6c61726176656c2d61637469766974792d6c6f672d646973636f72642f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/teaminfinitydev/laravel-activity-log-discord/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/5a5173df37ab706efb7c35834db5170547dfaf4929756b40c201cf40de47edfb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7465616d696e66696e6974796465762f6c61726176656c2d61637469766974792d6c6f672d646973636f72642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teaminfinitydev/laravel-activity-log-discord)

A powerful Laravel package that logs user activities and system events, then sends beautiful notifications to Discord channels via webhooks. Perfect for monitoring your application's important events in real-time.

🌟 Features
----------

[](#-features)

- **📝 Comprehensive Activity Logging** - Track user actions, model changes, and custom events
- **🎯 Discord Integration** - Send rich embed notifications to Discord channels
- **🚀 Queue Support** - Asynchronous processing for better performance
- **🎨 Customizable Embeds** - Configurable colors, icons, and formatting
- **🔧 Easy Configuration** - Environment-based settings with sensible defaults
- **📊 Database Storage** - Store activity logs with full relationship tracking
- **🏷️ Auto-Model Tracking** - Simple trait-based automatic logging
- **🔍 Event Filtering** - Enable/disable specific event types
- **⚡ Performance Optimized** - Efficient database queries and caching
- **🧪 Test Webhook** - Built-in webhook testing functionality
- **🚀 Bootup Messages** - Optional application startup notifications
- **🛡️ Error Handling** - Robust error handling and logging
- **🔒 Security** - Automatic sensitive data masking

📋 Requirements
--------------

[](#-requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher
- GuzzleHTTP 7.0 or higher

🚀 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require teaminfinitydev/laravel-activity-log-discord
```

Publish the configuration file:

```
php artisan vendor:publish --provider="teaminfinitydev\ActivityLogDiscord\ActivityLogDiscordServiceProvider" --tag="config"
```

Publish and run the migrations:

```
php artisan vendor:publish --provider="teaminfinitydev\ActivityLogDiscord\ActivityLogDiscordServiceProvider" --tag="migrations"
php artisan migrate
```

⚙️ Configuration
----------------

[](#️-configuration)

### Discord Webhook Setup

[](#discord-webhook-setup)

1. Go to your Discord server settings
2. Navigate to **Integrations** → **Webhooks**
3. Create a new webhook for your desired channel
4. Copy the webhook URL

### Environment Configuration

[](#environment-configuration)

Add the following to your `.env` file:

```
# Discord Configuration
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/your-webhook-url-here
DISCORD_BOT_NAME="App Activity Logger"
DISCORD_AVATAR_URL=https://your-app.com/logo.png

# Package Configuration
ACTIVITY_LOG_DISCORD_ENABLED=true
ACTIVITY_LOG_QUEUE=true
ACTIVITY_LOG_QUEUE_CONNECTION=default
ACTIVITY_LOG_QUEUE_NAME=discord-notifications
ACTIVITY_LOG_LEVEL=info

# Bootup Messages (Optional)
ACTIVITY_LOG_SEND_BOOTUP=false
```

### SSL Configuration

[](#ssl-configuration)

By default, this package uses SSL verification when connecting to Discord webhooks. This is recommended for production environments.

#### For Production Environments (Default):

[](#for-production-environments-default)

The package uses the following Guzzle configuration by default, which includes SSL verification:

```
$this->client = new Client([
    'timeout' => 30,
    'connect_timeout' => 10,
    'verify' => true, // SSL verification enabled
]);
```

#### For Local Development or Troubleshooting:

[](#for-local-development-or-troubleshooting)

If you're having connection issues in a local development environment or behind certain corporate firewalls, you may need to disable SSL verification temporarily:

1. Open `src/Services/DiscordWebhookService.php`
2. Find the client initialization in the constructor
3. Change the `verify` option to `false`:

```
$this->client = new Client([
    'timeout' => 30,
    'connect_timeout' => 10,
    'verify' => false, // SSL verification disabled
]);
```

⚠️ **IMPORTANT SECURITY WARNING**: Only disable SSL verification in local development environments. Never disable SSL verification in production as it makes your application vulnerable to man-in-the-middle attacks.

### Test Your Integration

[](#test-your-integration)

After configuration, test your webhook integration:

```
# Basic test
php artisan activity-log:test-webhook

# Detailed test with configuration info
php artisan activity-log:test-webhook --detailed
```

📖 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

#### Manual Logging

[](#manual-logging)

```
use teaminfinitydev\ActivityLogDiscord\Facades\ActivityLogger;

// Simple event logging
ActivityLogger::log('user.action', 'User performed a custom action');

// Detailed logging with subject and causer
ActivityLogger::log(
    'order.completed',
    'Order #1234 has been completed',
    $order,        // Subject (the order)
    $user,         // Causer (who performed the action)
    ['total' => 99.99, 'items' => 3] // Additional properties
);
```

#### Built-in Helper Methods

[](#built-in-helper-methods)

```
// User activity logging
ActivityLogger::logUserLogin($user);
ActivityLogger::logUserLogout($user);

// Model activity logging
ActivityLogger::logModelCreated($post, $user);
ActivityLogger::logModelUpdated($post, $changes, $user);
ActivityLogger::logModelDeleted($post, $user);

// System events
ActivityLogger::logWebAppBootup();

// Test webhook
$success = ActivityLogger::testWebhook();
```

### Automatic Model Tracking

[](#automatic-model-tracking)

Add the `LogsActivity` trait to your models for automatic tracking:

```
