brain-nucleus / client
Official Brain Nucleus event client for Laravel - monitoring, analytics, and incident management
Installs: 71
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/brain-nucleus/client
Requires
- php: ^8.1
- illuminate/http: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
README
Official PHP client for sending events to Brain Nucleus - monitoring, analytics, and incident management.
Installation
composer require brain-nucleus/client
Configuration
Add to your .env:
BRAIN_BASE_URL=https://again.com.au BRAIN_API_KEY=your-api-key-here
Add to config/services.php:
'brain' => [ 'base_url' => env('BRAIN_BASE_URL'), 'api_key' => env('BRAIN_API_KEY'), ],
Usage
Basic Usage
use Brain\Client\BrainEventClient; $client = new BrainEventClient( config('services.brain.base_url'), config('services.brain.api_key') ); // Send an event $client->send('user.signup', [ 'email' => $user->email, 'name' => $user->name, ]);
Service Provider (Recommended)
Register as a singleton in AppServiceProvider:
use Brain\Client\BrainEventClient; public function register(): void { $this->app->singleton(BrainEventClient::class, function ($app) { return new BrainEventClient( config('services.brain.base_url'), config('services.brain.api_key') ); }); }
Then inject anywhere:
public function __construct(private BrainEventClient $brain) {} public function store() { $this->brain->send('quote.created', ['amount' => 1000]); }
Async Events
Fire and forget (uses Laravel queues):
$client->sendAsync('analytics.page_view', ['url' => '/dashboard']);
Health Checks
Send heartbeats to let Brain know your app is alive:
// In a scheduled command (every 5 minutes) $client->send('health.ping', [ 'site' => config('app.name'), 'environment' => config('app.env'), ]);
Version Tracking
Brain tracks which client version each project uses:
$client->getVersion(); // Returns "1.0.0" $client->checkVersion(); // Checks if update is available
License
MIT License. See LICENSE for details.
Releasing New Versions
When you make changes to the client:
1. Update the Version Constant
// src/BrainEventClient.php public const CLIENT_VERSION = '1.1.0'; // Bump version
2. Update the Changelog
## [1.1.0] - 2024-12-23 ### Added - New feature description
3. Commit and Tag
git add -A git commit -m "Release v1.1.0 - description" git tag -a v1.1.0 -m "Description of changes" git push origin main --tags
Packagist will automatically detect the new tag and make it available!
4. Update Client Projects
composer update brain-nucleus/client
Semantic Versioning
- MAJOR (2.0.0): Breaking changes
- MINOR (1.1.0): New features, backward compatible
- PATCH (1.0.1): Bug fixes, backward compatible