From 4f4c19d711f4159e79ca2bfbe99328f335cdf64d Mon Sep 17 00:00:00 2001 From: Srinath Reddy Dudi Date: Wed, 30 Sep 2026 23:58:48 -0400 Subject: [PATCH] fixed bug where custom events stopped recording --- src/Helpers/FilterHelper.php | 7 +++ src/Laritor.php | 3 +- src/Override/DefaultOverride.php | 5 +++ src/Override/LaritorOverride.php | 2 + stubs/ExceptionsOnlyDataFilter.stub | 5 +++ stubs/FullObservabilityDataFilter.stub | 5 +++ stubs/IssuesOnlyDataFilter.stub | 59 ++++++++++---------------- 7 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/Helpers/FilterHelper.php b/src/Helpers/FilterHelper.php index e45b225..e7bb05f 100644 --- a/src/Helpers/FilterHelper.php +++ b/src/Helpers/FilterHelper.php @@ -229,6 +229,13 @@ public static function recordOutboundRequestResponseBody($url, $status_code, $du }, false); } + public static function recordCustomEvent(string $name, array $meta = []): bool + { + return static::recordEvent(function () use ($name, $meta) { + return app(LaritorOverride::class)->recordCustomEvent($name, $meta); + }); + } + public static function whitelistedVendors(): array { return []; diff --git a/src/Laritor.php b/src/Laritor.php index d95d6ac..179f4b4 100644 --- a/src/Laritor.php +++ b/src/Laritor.php @@ -23,7 +23,7 @@ class Laritor { - public const VERSION = '4.0.3'; + public const VERSION = '4.1.0'; /** * @var array @@ -412,6 +412,7 @@ public function filterEvents() RequestRecorder::$eventType => FilterHelper::recordRequest($event['request_instance'], $event['response_instance'], $event['response']['status_code'], $event['request']['duration']), ScheduledTaskRecorder::$eventType => FilterHelper::recordCommandOrScheduledTask($event['task'], $event['status'], $event['duration'] ?? 0), SchedulerRecorder::$eventType => FilterHelper::recordTaskScheduler(), + self::CUSTOM_EVENT => FilterHelper::recordCustomEvent($event['name'], $event), default => false }; diff --git a/src/Override/DefaultOverride.php b/src/Override/DefaultOverride.php index e2051a4..bac2c28 100644 --- a/src/Override/DefaultOverride.php +++ b/src/Override/DefaultOverride.php @@ -283,4 +283,9 @@ public function whitelistedVendors(): array { return []; } + + public function recordCustomEvent(string $name, array $meta = []): bool + { + return true; + } } \ No newline at end of file diff --git a/src/Override/LaritorOverride.php b/src/Override/LaritorOverride.php index 8455130..a81b5c6 100644 --- a/src/Override/LaritorOverride.php +++ b/src/Override/LaritorOverride.php @@ -146,5 +146,7 @@ public function recordOutboundRequestResponseHeaders($url, $status_code, $durati public function recordOutboundRequestResponseBody($url, $status_code, $duration): bool; + public function recordCustomEvent(string $name, array $meta = []): bool; + public function whitelistedVendors(): array; } \ No newline at end of file diff --git a/stubs/ExceptionsOnlyDataFilter.stub b/stubs/ExceptionsOnlyDataFilter.stub index b130ef2..a610874 100644 --- a/stubs/ExceptionsOnlyDataFilter.stub +++ b/stubs/ExceptionsOnlyDataFilter.stub @@ -351,4 +351,9 @@ class LaritorDataFilter extends DefaultOverride { return parent::whitelistedVendors(); } + + public function recordCustomEvent(string $name, array $meta = []): bool + { + return Laritor::hasException(); + } } \ No newline at end of file diff --git a/stubs/FullObservabilityDataFilter.stub b/stubs/FullObservabilityDataFilter.stub index 73052fd..6246af7 100644 --- a/stubs/FullObservabilityDataFilter.stub +++ b/stubs/FullObservabilityDataFilter.stub @@ -350,4 +350,9 @@ class LaritorDataFilter extends DefaultOverride { return parent::whitelistedVendors(); } + + public function recordCustomEvent(string $name, array $meta = []): bool + { + return true; + } } \ No newline at end of file diff --git a/stubs/IssuesOnlyDataFilter.stub b/stubs/IssuesOnlyDataFilter.stub index a62030e..8b26f28 100644 --- a/stubs/IssuesOnlyDataFilter.stub +++ b/stubs/IssuesOnlyDataFilter.stub @@ -36,11 +36,7 @@ class LaritorDataFilter extends DefaultOverride $laritor->getCommandDuration() >= 300000; } - /** - * @param string $cacheKey - * @return bool - */ - public function recordCacheHit($cacheKey): bool + public function hasIssue(): bool { return $this->hasFailedRequest() || @@ -49,6 +45,15 @@ class LaritorDataFilter extends DefaultOverride Laritor::hasException(); } + /** + * @param string $cacheKey + * @return bool + */ + public function recordCacheHit($cacheKey): bool + { + return $this->hasIssue(); + } + /** * @param \Throwable $exception * @return bool @@ -67,10 +72,7 @@ class LaritorDataFilter extends DefaultOverride public function recordOutboundRequest($url, $status_code, $duration): bool { return - $this->hasFailedRequest() || - $this->hasFailedJob() || - $this->hasFailedCommand() || - Laritor::hasException() || + $this->hasIssue() || $status_code >= 300 || $duration >= 1000; } @@ -84,10 +86,7 @@ class LaritorDataFilter extends DefaultOverride public function recordQuery($query, $duration, $path): bool { return - $this->hasFailedRequest() || - $this->hasFailedJob() || - $this->hasFailedCommand() || - Laritor::hasException() || + $this->hasIssue() || $duration >= 200; } @@ -102,9 +101,7 @@ class LaritorDataFilter extends DefaultOverride public function recordQueuedJob(string $connection, string $queue, string $job, string $status, $duration): bool { return - $this->hasFailedRequest() || - $this->hasFailedCommand() || - Laritor::hasException() || + $this->hasIssue() || strtolower($status) === 'failed' || $duration >= 60000; } @@ -152,11 +149,7 @@ class LaritorDataFilter extends DefaultOverride */ public function recordMail($mailable, $to, $subject): bool { - return - $this->hasFailedRequest() || - $this->hasFailedJob() || - $this->hasFailedCommand() || - Laritor::hasException(); + return $this->hasIssue(); } /** @@ -166,11 +159,7 @@ class LaritorDataFilter extends DefaultOverride */ public function recordNotification($notifiable, $notification): bool { - return - $this->hasFailedRequest() || - $this->hasFailedJob() || - $this->hasFailedCommand() || - Laritor::hasException(); + return $this->hasIssue(); } /** @@ -180,11 +169,7 @@ class LaritorDataFilter extends DefaultOverride */ public function recordFeatureFlag($flag, $scope): bool { - return - $this->hasFailedRequest() || - $this->hasFailedJob() || - $this->hasFailedCommand() || - Laritor::hasException(); + return $this->hasIssue(); } /** @@ -195,12 +180,7 @@ class LaritorDataFilter extends DefaultOverride */ public function recordLog($level, $message, array $context = []): bool { - return - $this->hasFailedRequest() || - $this->hasFailedJob() || - $this->hasFailedCommand() || - Laritor::hasException() || - !in_array(strtoupper($level), ['INFO','DEBUG']); + return $this->hasIssue() || !in_array(strtoupper($level), ['INFO','DEBUG']); } /** @@ -418,4 +398,9 @@ class LaritorDataFilter extends DefaultOverride { return parent::whitelistedVendors(); } + + public function recordCustomEvent(string $name, array $meta = []): bool + { + return $this->hasIssue(); + } } \ No newline at end of file