Docs · By hand
Send Symfony errors to Vinktar with the Sentry SDK
At the end the exceptions your Symfony app already reports arrive in Vinktar, next to product events on the same user id.
Before you start
You need a Symfony app with the Sentry SDK, or one you are about to add it to, and a Vinktar project. This guide was checked on sentry-symfony 5.13.0 with Symfony 8.1 and PHP 8.5.
1. Change the DSN
# was: SENTRY_DSN=https://abc123@o12345.ingest.sentry.io/451
SENTRY_DSN=https://vnk_pk_YOUR_KEY@in.vinktar.com/YOUR_PROJECT_IDcomposer config extra.symfony.allow-contrib true # the recipe is a contrib recipe
composer require sentry/sentry-symfony// What the recipe writes: the bundle runs in prod only, so nothing is sent from dev.
Sentry\SentryBundle\SentryBundle::class => ['prod' => true],The key is the project's public write key and the number is the project id. The finished DSN is on the project's Connect page under Manual, and an agent gets it from get_project_keys. No project yet? Create one free, no card needed. The recipe adds an empty SENTRY_DSN to .env and config/packages/sentry.yaml under when@prod. Without allow-contrib Composer installs the package and registers nothing.
2. Check it worked
APP_ENV=prod php bin/console sentry:test sends one message. Within a few seconds the project's Errors page lists Message: This is a test message from the Sentry bundle.
3. Set the release, environment and user
when@prod:
sentry:
dsn: '%env(SENTRY_DSN)%'
options:
release: '%env(SENTRY_RELEASE)%' # any env var; the Vinktar SDK below gets the same name
environment: '%kernel.environment%'use Sentry\State\Scope;
use function Sentry\configureScope;
// After sign-in, for example in a kernel.request listener. The same id identify() gets below.
configureScope(fn (Scope $scope) => $scope->setUser(['id' => (string) $user->getId()]));The release and environment are the Sentry SDK's own options and arrive on every error. The user id is what joins an error to a person: without setUser an error from a signed-in request is anonymous. Use the same id you will pass to identify() below.
4. Add product events
The DSN carries errors only. Product events come from vinktarhq/php, which is a beta: the API can still change before 0.2.0. It sends on the same write key, and the same release, environment and user id make the error and the person's events one record.
composer require vinktarhq/php:^0.2@betaservices:
Vinktar\Client:
arguments:
- { writeKey: '%env(VINKTAR_KEY)%', release: '%env(SENTRY_RELEASE)%', environment: '%kernel.environment%' }use Vinktar\Client;
public function __construct(private readonly Client $vinktar)
{
}
public function send(Invoice $invoice): void
{
$this->vinktar->identify((string) $invoice->getOwner()->getId()); // same id as setUser
$this->vinktar->track('invoice_sent', ['invoice_id' => $invoice->getId(), 'total' => $invoice->getTotal(), 'currency' => 'EUR']);
}
$this->vinktar->track('invoice_paid', ['invoice_id' => $invoice->getId(), 'total' => $invoice->getTotal()]);
$this->vinktar->track('plan_upgraded', ['from' => 'starter', 'to' => 'pro']);Event names and property keys are snake_case, the object then a past-tense action. Define each one as you add it, with define_event from your agent or in the project's data dictionary, so the name keeps one meaning. Under PHP-FPM what a request queues is sent when the request ends; a console command calls flush() before it returns, and the SDK README has a kernel.terminate subscriber for FrankenPHP workers.
What arrives, and what does not
Stored
- Uncaught exceptions and anything passed to
captureException: type, message and the 50 frames nearest the crash. A Symfony request stack is longer than that; the frames above are cut, not the error. captureMessagecalls, as an issue of typeMessage.- Release, environment, the user id and email on the scope, tags, breadcrumbs and the request URL and method.
- Levels
fatal,error,warningandinfo;debugis stored asinfo.
Accepted and dropped
Transactions, spans, profiles, sessions, cron check-ins, logs, metrics and attachments get a 200 and are discarded, so the SDK reports no failure. There is no tracing or cron product behind the DSN; keep Sentry for those if you use them.
Everything stored goes through the same pipeline as /v1/errors: the same per-error caps, error rate limit and monthly error budget, described on Switch from Sentry and in section 11 of api.md.