Automattic\WooCommerce\Internal\PushNotifications\Services
NotificationProcessor::log_send_outcome
Writes the send outcome WPCOM reported, naming the tokens it refused.
Every recipient carries the notification's own outcome except the ones WPCOM named as invalid, so the refused IDs are the whole difference.
Method of the class: NotificationProcessor{}
No Hooks.
Returns
void. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->log_send_outcome( $notification, $recipients, $result, $step_context ): void;
- $notification(Notification) (required)
- The notification being processed.
- $recipients(PushToken[]) (required)
- The tokens the notification was sent to.
- $result(array) (required)
- The dispatcher's return value.
- $step_context(array) (required)
- Fields shared by every line of this attempt.
NotificationProcessor::log_send_outcome() NotificationProcessor::log send outcome code WC 11.3.0
private function log_send_outcome( Notification $notification, array $recipients, array $result, array $step_context ): void {
if ( ! $this->step_logger->is_active() ) {
return;
}
$invalid_tokens = array_flip( $result['invalid_tokens'] ?? array() );
if ( empty( $invalid_tokens ) ) {
return;
}
$invalid_ids = array();
foreach ( $recipients as $token ) {
if ( isset( $invalid_tokens[ $token->get_token() ] ) ) {
$invalid_ids[] = (int) $token->get_id();
}
}
$this->step_logger->log_notification_step(
$notification,
'dispatched',
'invalid_token',
array_merge( $step_context, array( 'invalid_token_ids' => $invalid_ids ) )
);
}