Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 47 additions & 43 deletions src/Http/SentryClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
/**
* @implements \Cake\Event\EventDispatcherInterface<\CakeSentry\Http\SentryClient>
*/
class SentryClient implements EventDispatcherInterface

Check failure on line 28 in src/Http/SentryClient.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

TooManyTemplateParams

src/Http/SentryClient.php:28:31: TooManyTemplateParams: CakeSentry\Http\SentryClient has too many template params when extending Cake\Event\EventDispatcherInterface, expecting 0 (see https://psalm.dev/184)

Check failure on line 28 in src/Http/SentryClient.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

PHPDoc tag `@implements` contains generic type Cake\Event\EventDispatcherInterface<CakeSentry\Http\SentryClient> but interface Cake\Event\EventDispatcherInterface is not generic.
{
/** @use \Cake\Event\EventDispatcherTrait<\CakeSentry\Http\SentryClient> */
use EventDispatcherTrait;

Check failure on line 31 in src/Http/SentryClient.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

TooManyTemplateParams

src/Http/SentryClient.php:31:9: TooManyTemplateParams: CakeSentry\Http\SentryClient has too many template params when extending Cake\Event\EventDispatcherTrait, expecting 0 (see https://psalm.dev/184)

Check failure on line 31 in src/Http/SentryClient.php

View workflow job for this annotation

GitHub Actions / Coding Standard & Static Analysis

PHPDoc tag `@use` contains generic type Cake\Event\EventDispatcherTrait<CakeSentry\Http\SentryClient> but trait Cake\Event\EventDispatcherTrait is not generic.

protected HubInterface $hub;

Expand Down Expand Up @@ -122,22 +122,24 @@
?ServerRequestInterface $request = null,
?array $extras = null,
): void {
$eventManager = $this->getEventManager();
$event = new Event('CakeSentry.Client.beforeCapture', $this, compact('exception', 'request'));
$eventManager->dispatch($event);

if ($extras !== null) {
$this->hub->configureScope(function (Scope $scope) use ($extras): void {
$scope->setExtras($extras);
});
}
$this->hub->withScope(function () use ($exception, $request, $extras): void {
$eventManager = $this->getEventManager();
$event = new Event('CakeSentry.Client.beforeCapture', $this, compact('exception', 'request'));
$eventManager->dispatch($event);

if ($extras !== null) {
$this->hub->configureScope(function (Scope $scope) use ($extras): void {
$scope->setExtras($extras);
});
}

$this->getQueryLoggers();
$this->addQueryBreadcrumbs();
$this->getQueryLoggers();
$this->addQueryBreadcrumbs();

$lastEventId = captureException($exception);
$event = new Event('CakeSentry.Client.afterCapture', $this, compact('exception', 'request', 'lastEventId'));
$eventManager->dispatch($event);
$lastEventId = captureException($exception);
$event = new Event('CakeSentry.Client.afterCapture', $this, compact('exception', 'request', 'lastEventId'));
$eventManager->dispatch($event);
});
}

/**
Expand All @@ -153,37 +155,39 @@
?ServerRequestInterface $request = null,
?array $extras = null,
): void {
$eventManager = $this->getEventManager();
$event = new Event('CakeSentry.Client.beforeCapture', $this, compact('error', 'request'));
$eventManager->dispatch($event);

if ($extras !== null) {
$this->hub->configureScope(function (Scope $scope) use ($extras): void {
$scope->setExtras($extras);
});
}
$this->hub->withScope(function () use ($error, $request, $extras): void {
$eventManager = $this->getEventManager();
$event = new Event('CakeSentry.Client.beforeCapture', $this, compact('error', 'request'));
$eventManager->dispatch($event);

if ($extras !== null) {
$this->hub->configureScope(function (Scope $scope) use ($extras): void {
$scope->setExtras($extras);
});
}

$this->getQueryLoggers();
$this->addQueryBreadcrumbs();

$client = $this->hub->getClient();
if ($client) {
/** @var list<array{function?: string, line?: int, file?: string, class?: class-string, type?: string, args?: array}> $trace */
$trace = $this->cleanedTrace($error->getTrace());
$stacktrace = $client->getStacktraceBuilder()
->buildFromBacktrace($trace, $error->getFile() ?? 'unknown file', $error->getLine() ?? 0);
$hint = EventHint::fromArray([
'stacktrace' => $stacktrace,
]);
}
$this->getQueryLoggers();
$this->addQueryBreadcrumbs();

$client = $this->hub->getClient();
if ($client) {
/** @var list<array{function?: string, line?: int, file?: string, class?: class-string, type?: string, args?: array}> $trace */
$trace = $this->cleanedTrace($error->getTrace());
$stacktrace = $client->getStacktraceBuilder()
->buildFromBacktrace($trace, $error->getFile() ?? 'unknown file', $error->getLine() ?? 0);
$hint = EventHint::fromArray([
'stacktrace' => $stacktrace,
]);
}

$lastEventId = captureMessage(
$error->getMessage(),
Severity::fromError($error->getCode()),
$hint ?? null,
);
$event = new Event('CakeSentry.Client.afterCapture', $this, compact('error', 'request', 'lastEventId'));
$eventManager->dispatch($event);
$lastEventId = captureMessage(
$error->getMessage(),
Severity::fromError($error->getCode()),
$hint ?? null,
);
$event = new Event('CakeSentry.Client.afterCapture', $this, compact('error', 'request', 'lastEventId'));
$eventManager->dispatch($event);
});
}

/**
Expand Down