-
-
Notifications
You must be signed in to change notification settings - Fork 635
Expand file tree
/
Copy pathTrackExternalRegistrationClickAction.php
More file actions
41 lines (35 loc) · 1.23 KB
/
TrackExternalRegistrationClickAction.php
File metadata and controls
41 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace HiEvents\Http\Actions\Events;
use HiEvents\Http\Actions\BaseAction;
use HiEvents\Services\Domain\EventStatistics\EventStatisticsIncrementService;
use Illuminate\Http\JsonResponse;
use Psr\Log\LoggerInterface;
use Throwable;
class TrackExternalRegistrationClickAction extends BaseAction
{
public function __construct(
private readonly EventStatisticsIncrementService $eventStatisticsIncrementService,
private readonly LoggerInterface $logger,
)
{
}
public function __invoke(int $eventId): JsonResponse
{
try {
$this->eventStatisticsIncrementService->incrementExternalRegistrationClick($eventId);
return $this->successResponse();
} catch (Throwable $e) {
// Silent failure - log error but don't block user
$this->logger->error(
'Failed to track external registration click',
[
'event_id' => $eventId,
'exception' => $e::class,
'message' => $e->getMessage(),
]
);
// Still return success to not block the user's navigation
return $this->successResponse();
}
}
}