diff --git a/config/request-analytics.php b/config/request-analytics.php index 670eac9..76e9667 100644 --- a/config/request-analytics.php +++ b/config/request-analytics.php @@ -61,7 +61,6 @@ 'privacy' => [ 'anonymize_ip' => env('REQUEST_ANALYTICS_ANONYMIZE_IP', false), - 'respect_dnt' => env('REQUEST_ANALYTICS_RESPECT_DNT', true), // Respect Do Not Track header ], 'cache' => [ diff --git a/src/Traits/CaptureRequest.php b/src/Traits/CaptureRequest.php index cc93cf0..a21eb46 100644 --- a/src/Traits/CaptureRequest.php +++ b/src/Traits/CaptureRequest.php @@ -17,11 +17,6 @@ public function capture(Request $request, Response $response, string $requestCat return null; } - // Respect Do Not Track header if enabled - if (config('request-analytics.privacy.respect_dnt') && $request->header('DNT') === '1') { - return null; - } - // Skip bot traffic unless explicitly enabled if ($this->isBot($request) && ! config('request-analytics.capture.bots', false)) { return null; diff --git a/tests/Feature/BaseFeatureTestCase.php b/tests/Feature/BaseFeatureTestCase.php index a2df38d..1bb1d9d 100644 --- a/tests/Feature/BaseFeatureTestCase.php +++ b/tests/Feature/BaseFeatureTestCase.php @@ -6,6 +6,7 @@ use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Support\Facades\Cache; use MeShaon\RequestAnalytics\Contracts\CanAccessAnalyticsDashboard; use MeShaon\RequestAnalytics\Tests\TestCase; use Mockery; @@ -35,6 +36,8 @@ protected function setUp(): void $this->actingAs($user); // $this->withoutExceptionHandling(); + + Cache::flush(); } protected function tearDown(): void diff --git a/tests/Unit/Middleware/RequestCaptureMiddlewareTest.php b/tests/Unit/Middleware/RequestCaptureMiddlewareTest.php index 863527d..624b2f0 100644 --- a/tests/Unit/Middleware/RequestCaptureMiddlewareTest.php +++ b/tests/Unit/Middleware/RequestCaptureMiddlewareTest.php @@ -102,26 +102,7 @@ public function web_middleware_terminates_and_queues_job_when_queue_enabled(): v Queue::assertPushed(ProcessData::class); } - #[Test] - public function middleware_does_not_capture_when_dnt_header_is_present(): void - { - Queue::fake(); - - config([ - 'request-analytics.privacy.respect_dnt' => true, - 'request-analytics.capture.bots' => true, - ]); - - $middleware = new APIRequestCapture; - $request = Request::create('/api/test', 'GET'); - $request->headers->set('DNT', '1'); - $request->headers->set('User-Agent', 'Test Browser Mozilla'); - $response = new Response('API Response'); - - $middleware->terminate($request, $response); - - Queue::assertNothingPushed(); - } + #[Test] public function middleware_does_not_capture_bots_when_bot_capture_disabled(): void