trypost/app/Jobs/PostHog/SendEvent.php
Paulo Castellano ff23b5084b chore: drop verbose docblocks across PostHog and billing files
Class names and method signatures already explain what these classes
do. Project guideline (CLAUDE.md): comments only when the WHY is
non-obvious — implementation details belong in commits, not noise on
top of every class. Kept the one comment that earns it: the (int)
cast in HasUsage::cachedPostCount, which documents the load-bearing
workaround for Laravel's Redis cache numeric optimisation.
2026-05-07 16:03:12 -03:00

49 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Jobs\PostHog;
use App\Services\PostHogService;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use PostHog\PostHog;
class SendEvent implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public int $timeout = 15;
/**
* @param array<string, mixed> $payload
*/
public function __construct(
public string $method,
public array $payload,
) {
$this->onQueue('posthog');
}
public function handle(): void
{
if (! PostHogService::isEnabled()) {
return;
}
match ($this->method) {
'capture' => PostHog::capture($this->payload),
'identify' => PostHog::identify($this->payload),
'groupIdentify' => PostHog::groupIdentify($this->payload),
default => Log::warning('PostHog SendEvent: unknown method', ['method' => $this->method]),
};
PostHog::flush();
}
}