Add `Scope::setTransactionName()`
Another approach to fix https://github.com/getsentry/sentry-php/pull/1716.
Compared to other SDKs, like Python, the PHP SDK never exposed the transaction name on the scope.
With these changes, the transaction name will be synced with the scope when set on the transaction and vice versa. If an error happens while the transaction is still unfinished, we now set a proper transaction name on the error instead of relying on the user manually passing the name as part of the EventHint or relying on the TransactionIntegration setting $_SERVER['PATH_INFO'], which is a bad default.
// Before
$hint = EventHint::fromArray([
'extra' => [
'transaction' => 'GET /example',
],
]);
captureException($e, $hint);
// After
configureScope(function (Scope $scope) {
$scope->setTransactionName('GET /example');
});
captureException($e);
// After, in case of an active transaction
captureException($e);
Reliably setting the transaction name on all errors allows for some neat features, such as using Discover to create a query to group your transactions by error count.