Log FCM errors in debug_info when push notification fails

This commit is contained in:
Hamza-Ayed
2026-06-30 21:59:00 +03:00
parent 1dc5ccc11d
commit e7785c9b2d

View File

@@ -100,6 +100,7 @@ try {
$sentSms = 0; $sentSms = 0;
$sentWhatsApp = 0; $sentWhatsApp = 0;
$dispatchedPassengers = []; $dispatchedPassengers = [];
$fcmErrors = [];
// 6. Save broadcast promo for this campaign (Option 1 - promos table adjustment) // 6. Save broadcast promo for this campaign (Option 1 - promos table adjustment)
$sqlPromo = "INSERT INTO promos $sqlPromo = "INSERT INTO promos
@@ -157,8 +158,14 @@ try {
$logStmt->execute([$passengerId, $countryCode, $regionName]); $logStmt->execute([$passengerId, $countryCode, $regionName]);
$dispatchedPassengers[] = $passengerId; $dispatchedPassengers[] = $passengerId;
$pushSent = true; $pushSent = true;
} else {
$fcmErrors[] = ['passenger_id' => $passengerId, 'error' => $fcmResult];
} }
} else {
$fcmErrors[] = ['passenger_id' => $passengerId, 'error' => 'Token decryption failed'];
} }
} else {
$fcmErrors[] = ['passenger_id' => $passengerId, 'error' => 'No token in DB'];
} }
if (!$pushSent) { if (!$pushSent) {
@@ -224,7 +231,8 @@ try {
'requested_country' => $countryCode, 'requested_country' => $countryCode,
'total_passengers_in_db' => count($allPassengers), 'total_passengers_in_db' => count($allPassengers),
'matched_targets' => count($targets), 'matched_targets' => count($targets),
'distribution' => $debugCounts 'distribution' => $debugCounts,
'fcm_errors' => $fcmErrors ?? []
] ]
]); ]);