Automattic\WooCommerce\Internal\Abilities
AbilitiesTracking::queue_event
Add the properties every event carries and queue the event for sending.
Properties are built now, so the user, site and time are those of the call rather than of shutdown.
Метод класса: AbilitiesTracking{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->queue_event( $event_name, $event, ?float $started ): void;
- $event_name(строка) (обязательный)
- Event name, without the
wcadmin_prefix. - $event(array<string, mixed>) (обязательный)
- Event-specific properties.
- ?float $started
- .
По умолчанию:null
Код AbilitiesTracking::queue_event() AbilitiesTracking::queue event WC 11.3.0
private function queue_event( string $event_name, array $event, ?float $started = null ): void {
// Telemetry must never break the ability call: this runs third-party filters and Jetpack code inside core's hooks.
try {
if ( count( $this->events ) >= self::MAX_EVENTS_PER_REQUEST ) {
if ( ! $this->is_long_running_process() ) {
++$this->events_dropped;
return;
}
$this->flush_events();
$this->send_queued_pixels();
}
// The call itself may have turned tracking off.
if ( ! self::is_tracking_allowed() ) {
return;
}
// Web requests from logged-out visitors aren't merchant or agent usage, and anyone could trigger them.
$auth = self::get_auth_method();
if ( 'none' === $auth && ! ( defined( 'WP_CLI' ) && WP_CLI ) && ! wp_doing_cron() ) {
return;
}
$event['auth'] = $auth;
// Many local installs (localhost, .local, .test, DDEV, Lando) still report production.
$event['is_test'] = ( 'production' !== wp_get_environment_type() || ( class_exists( Status::class ) && ( new Status() )->is_local_site() ) ) ? 'true' : 'false';
$event['is_a11n'] = self::is_a11n() ? 'true' : 'false';
$properties = \WC_Tracks::get_properties( \WC_Tracks::PREFIX . $event_name, $event );
// The request URL and referrer can carry ability input, e.g. in the query string of GET run requests.
unset( $properties['_dl'], $properties['_dr'] );
if ( null !== $started ) {
$properties['_ts'] = number_format( round( $started * 1000 ), 0, '', '' );
}
$this->events[] = $properties;
} catch ( \Throwable $e ) {
unset( $e );
}
}