justanalyticsapp/justanalytics-php

JustAnalytics PHP SDK for distributed tracing, error tracking, logging, and infrastructure metrics

Maintainers

Package info

github.com/specifiedcodes/justanalytics-php

pkg:composer/justanalyticsapp/justanalytics-php

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-03-15 03:09 UTC

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