1. Go to this page and download the library: Download cboxdk/statamic-telemetry library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cboxdk / statamic-telemetry example snippets
use Cbox\StatamicTelemetry\Hooks;
use Cbox\StatamicTelemetry\Support\CacheKeys;
use Cbox\StatamicTelemetry\Support\Content;
Telemetry::resolveUserUsing(fn ($user, $guard) => [
...Hooks::userAttributes($user, $guard),
'user.plan' => $user->plan ?? null,
]);
Telemetry::nameRequestsUsing(fn ($request, $response) =>
$request->is('api/*') ? 'API '.$request->method() : Content::spanName($request)
);
Telemetry::classifyCacheKeysUsing(fn (string $store, string $key) =>
str_starts_with($key, 'tenant:') ? 'tenant' : CacheKeys::classify($store, $key)
);
// The addon claims resolveRouteUsing (it overrides http.route with the
// logical content route). Compose if you want a different route identity:
Telemetry::resolveRouteUsing(fn ($request, $response) =>
$request->is('api/*') ? 'api' : Content::routeLabel($request)
);