Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion config/request-analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
5 changes: 0 additions & 5 deletions src/Traits/CaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/BaseFeatureTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,6 +36,8 @@ protected function setUp(): void
$this->actingAs($user);

// $this->withoutExceptionHandling();

Cache::flush();
}

protected function tearDown(): void
Expand Down
21 changes: 1 addition & 20 deletions tests/Unit/Middleware/RequestCaptureMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down