Changed javascipt exception tracker method..

This commit is contained in:
Cüneyt Şentürk
2022-11-21 16:26:13 +03:00
parent 8602a1f478
commit 1c93c7a11e
14 changed files with 263 additions and 79 deletions

View File

@ -2,6 +2,7 @@
namespace App\Exceptions\Trackers;
use App\Traits\Trackers as Base;
use Illuminate\Support\Str;
use Sentry\Event;
use Sentry\EventHint;
@ -9,17 +10,15 @@ use Sentry\Tracing\SamplingContext;
class Sentry
{
use Base;
public static function beforeSend(Event $event, ?EventHint $hint): ?Event
{
$event->setRelease(version('short'));
$event->setTags([
'company_id' => (string) company_id(),
'locale' => (string) app()->getLocale(),
'timezone' => (string) config('app.timezone'),
'app_type' => (string) static::getAppType(),
'route_name' => (string) static::getRouteName(),
]);
$tags = $this->getTrackerTags();
$event->setTags($tags);
return $event;
}
@ -49,28 +48,4 @@ class Sentry
return false;
}
public static function getAppType(): string
{
$hostname = gethostname();
if (Str::contains($hostname, '-queue-')) {
$app_type = 'queue';
} elseif (Str::contains($hostname, '-cron-')) {
$app_type = 'cron';
} elseif (request()->isApi()) {
$app_type = 'api';
} elseif (app()->runningInConsole()) {
$app_type = 'console';
} else {
$app_type = 'ui';
}
return $app_type;
}
public static function getRouteName(): ?string
{
return request()->route()?->getName();
}
}