justanalyticsapp / justanalytics-php
JustAnalytics PHP SDK for distributed tracing, error tracking, logging, and infrastructure metrics
Package info
github.com/specifiedcodes/justanalytics-php
pkg:composer/justanalyticsapp/justanalytics-php
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
- guzzlehttp/guzzle: ^7.0
- illuminate/http: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
- phpunit/phpunit: ^10.0
- symfony/config: ^6.0|^7.0
- symfony/dependency-injection: ^6.0|^7.0
- symfony/http-kernel: ^6.0|^7.0
Suggests
- guzzlehttp/guzzle: Required for Guzzle HTTP auto-instrumentation (^7.0)
- illuminate/support: Required for Laravel integration (^10.0|^11.0)
- symfony/http-kernel: Required for Symfony integration (^6.0|^7.0)
This package is not auto-updated.
Last update: 2026-05-11 03:06:20 UTC
README
Official PHP SDK for JustAnalytics — distributed tracing, error tracking, logging, and infrastructure metrics for PHP applications.
Requirements
- PHP 8.1+
- ext-json
- ext-curl
Installation
composer require justanalyticsapp/justanalytics-php
Quick Start
use JustAnalytics\JustAnalytics; JustAnalytics::init([ 'siteId' => 'your-site-id', 'apiKey' => 'ja_sk_your_api_key', 'serviceName' => 'my-php-app', 'environment' => 'production', ]); // Create spans $result = JustAnalytics::startSpan('process-order', 'internal', [], function ($span) { $span->setAttribute('order.id', '12345'); return processOrder(); }); // Capture exceptions try { riskyOperation(); } catch (\Throwable $e) { JustAnalytics::captureException($e, ['tags' => ['module' => 'payments']]); } // Capture messages JustAnalytics::captureMessage('User exceeded rate limit', 'warning'); // Set user context JustAnalytics::setUser(['id' => 'user-123', 'email' => 'alice@example.com']); // Set tags JustAnalytics::setTag('feature', 'checkout'); // Flush at end of request JustAnalytics::flush();
Laravel Integration
The SDK auto-discovers in Laravel via the service provider. Add your credentials to .env:
JUSTANALYTICS_SITE_ID=your-site-id JUSTANALYTICS_API_KEY=ja_sk_your_api_key JUSTANALYTICS_SERVICE_NAME=my-laravel-app
Publish the config file:
php artisan vendor:publish --tag=justanalytics-config
The middleware is auto-registered and creates server spans for every HTTP request.
Symfony Integration
Register the bundle in config/bundles.php:
return [ JustAnalytics\Integrations\Symfony\JustAnalyticsBundle::class => ['all' => true], ];
Add configuration in config/packages/just_analytics.yaml:
just_analytics: site_id: '%env(JUSTANALYTICS_SITE_ID)%' api_key: '%env(JUSTANALYTICS_API_KEY)%' service_name: '%env(JUSTANALYTICS_SERVICE_NAME)%'
Guzzle Auto-Instrumentation
use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use JustAnalytics\Integrations\Guzzle\GuzzleMiddleware; $stack = HandlerStack::create(); $stack->push(GuzzleMiddleware::create(), 'justanalytics'); $client = new Client(['handler' => $stack]);
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
siteId |
string | required | Site ID from dashboard |
apiKey |
string | required | API key (ja_sk_...) |
serviceName |
string | required | Service identifier |
environment |
string | null | Deployment environment |
release |
string | null | Release/version |
serverUrl |
string | production URL | JustAnalytics server |
debug |
bool | false | Enable debug logging |
enabled |
bool | true | Enable/disable SDK |
async |
bool | false | Use shutdown function |
maxBatchSize |
int | 100 | Max batch size |
timeout |
int | 5 | HTTP timeout (seconds) |
License
MIT