Update
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Jobs\TrackContentSelectionJob;
|
||||
use App\Jobs\TrackExportJob;
|
||||
use App\Jobs\TrackSaveJob;
|
||||
use App\Jobs\TrackSearchJob;
|
||||
use App\Jobs\UpdateExportStatusJob;
|
||||
use Carbon\Carbon;
|
||||
@@ -11,9 +12,9 @@
|
||||
class TrackingAnalyticsService
|
||||
{
|
||||
/**
|
||||
* Track a search action
|
||||
* Track a search action with full context
|
||||
*/
|
||||
public function trackSearch(
|
||||
public function trackSearchWithContext(
|
||||
string $deviceId,
|
||||
string $searchType,
|
||||
string $searchQuery,
|
||||
@@ -36,15 +37,14 @@ public function trackSearch(
|
||||
}
|
||||
|
||||
/**
|
||||
* Track a content selection action
|
||||
* Track a content selection action with full context
|
||||
*/
|
||||
public function trackContentSelection(
|
||||
public function trackContentSelectionWithContext(
|
||||
string $deviceId,
|
||||
string $contentType,
|
||||
int $contentId,
|
||||
string $contentName,
|
||||
string $selectionMethod,
|
||||
?string $searchQuery = null,
|
||||
?Carbon $actionAt = null,
|
||||
?string $userAgent = null,
|
||||
?string $ipAddress = null,
|
||||
@@ -56,7 +56,6 @@ public function trackContentSelection(
|
||||
$contentId,
|
||||
$contentName,
|
||||
$selectionMethod,
|
||||
$searchQuery,
|
||||
$actionAt ?? now(),
|
||||
$userAgent,
|
||||
$ipAddress,
|
||||
@@ -65,29 +64,54 @@ public function trackContentSelection(
|
||||
}
|
||||
|
||||
/**
|
||||
* Track an export action
|
||||
* Track an export action with full context
|
||||
*/
|
||||
public function trackExport(
|
||||
public function trackExportWithContext(
|
||||
string $deviceId,
|
||||
?int $memeId,
|
||||
?int $memeMediaId,
|
||||
?int $backgroundMediaId,
|
||||
array $captionTexts,
|
||||
string $exportFormat,
|
||||
string $exportQuality = 'standard',
|
||||
?Carbon $actionAt = null,
|
||||
?string $userAgent = null,
|
||||
?string $ipAddress = null,
|
||||
string $platform = 'web'
|
||||
): int {
|
||||
return TrackExportJob::dispatchSync(
|
||||
): void {
|
||||
TrackExportJob::dispatch(
|
||||
$deviceId,
|
||||
$memeId,
|
||||
$memeMediaId,
|
||||
$backgroundMediaId,
|
||||
$captionTexts,
|
||||
$exportFormat,
|
||||
$exportQuality,
|
||||
$actionAt ?? now(),
|
||||
$userAgent,
|
||||
$ipAddress,
|
||||
$platform
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Track a save action with full context
|
||||
*/
|
||||
public function trackSaveWithContext(
|
||||
string $deviceId,
|
||||
?int $memeId,
|
||||
?int $memeMediaId,
|
||||
?int $backgroundMediaId,
|
||||
array $captionTexts,
|
||||
bool $isPremiumExport,
|
||||
?Carbon $actionAt = null,
|
||||
?string $userAgent = null,
|
||||
?string $ipAddress = null,
|
||||
string $platform = 'web'
|
||||
): void {
|
||||
TrackSaveJob::dispatch(
|
||||
$deviceId,
|
||||
$memeId,
|
||||
$memeMediaId,
|
||||
$backgroundMediaId,
|
||||
$captionTexts,
|
||||
$isPremiumExport,
|
||||
$actionAt ?? now(),
|
||||
$userAgent,
|
||||
$ipAddress,
|
||||
@@ -121,7 +145,7 @@ public function getDeviceContext(): array
|
||||
|
||||
return [
|
||||
'user_agent' => $request->userAgent(),
|
||||
'ip_address' => $request->ip(),
|
||||
'ip_address' => get_current_ip(),
|
||||
'platform' => 'web', // Default for now, can be enhanced for mobile detection
|
||||
];
|
||||
}
|
||||
@@ -145,14 +169,14 @@ public function generateDeviceId(): string
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick track methods with auto device context
|
||||
* Track methods with auto device context
|
||||
*/
|
||||
public function quickTrackSearch(string $searchType, string $searchQuery, ?array $searchFilters = null): void
|
||||
public function trackSearch(string $searchType, string $searchQuery, ?array $searchFilters = null): void
|
||||
{
|
||||
$context = $this->getDeviceContext();
|
||||
$deviceId = $this->generateDeviceId();
|
||||
|
||||
$this->trackSearch(
|
||||
$this->trackSearchWithContext(
|
||||
$deviceId,
|
||||
$searchType,
|
||||
$searchQuery,
|
||||
@@ -164,18 +188,17 @@ public function quickTrackSearch(string $searchType, string $searchQuery, ?array
|
||||
);
|
||||
}
|
||||
|
||||
public function quickTrackContentSelection(string $contentType, int $contentId, string $contentName, string $selectionMethod, ?string $searchQuery = null): void
|
||||
public function trackContentSelection(string $contentType, int $contentId, string $contentName, string $selectionMethod): void
|
||||
{
|
||||
$context = $this->getDeviceContext();
|
||||
$deviceId = $this->generateDeviceId();
|
||||
|
||||
$this->trackContentSelection(
|
||||
$this->trackContentSelectionWithContext(
|
||||
$deviceId,
|
||||
$contentType,
|
||||
$contentId,
|
||||
$contentName,
|
||||
$selectionMethod,
|
||||
$searchQuery,
|
||||
null,
|
||||
$context['user_agent'],
|
||||
$context['ip_address'],
|
||||
@@ -183,19 +206,36 @@ public function quickTrackContentSelection(string $contentType, int $contentId,
|
||||
);
|
||||
}
|
||||
|
||||
public function quickTrackExport(?int $memeId, ?int $memeMediaId, ?int $backgroundMediaId, array $captionTexts, string $exportFormat, string $exportQuality = 'standard'): int
|
||||
public function trackExport(?int $memeId, ?int $memeMediaId, ?int $backgroundMediaId, array $captionTexts): void
|
||||
{
|
||||
$context = $this->getDeviceContext();
|
||||
$deviceId = $this->generateDeviceId();
|
||||
|
||||
return $this->trackExport(
|
||||
$this->trackExportWithContext(
|
||||
$deviceId,
|
||||
$memeId,
|
||||
$memeMediaId,
|
||||
$backgroundMediaId,
|
||||
$captionTexts,
|
||||
$exportFormat,
|
||||
$exportQuality,
|
||||
null,
|
||||
$context['user_agent'],
|
||||
$context['ip_address'],
|
||||
$context['platform']
|
||||
);
|
||||
}
|
||||
|
||||
public function trackSave(?int $memeId, ?int $memeMediaId, ?int $backgroundMediaId, array $captionTexts, bool $isPremiumExport = false): void
|
||||
{
|
||||
$context = $this->getDeviceContext();
|
||||
$deviceId = $this->generateDeviceId();
|
||||
|
||||
$this->trackSaveWithContext(
|
||||
$deviceId,
|
||||
$memeId,
|
||||
$memeMediaId,
|
||||
$backgroundMediaId,
|
||||
$captionTexts,
|
||||
$isPremiumExport,
|
||||
null,
|
||||
$context['user_agent'],
|
||||
$context['ip_address'],
|
||||
|
||||
Reference in New Issue
Block a user