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.
Method of the class: AbilitiesTracking{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->queue_event( $event_name, $event, ?float $started ): void;
- $event_name(string) (required)
- Event name, without the
wcadmin_prefix. - $event(array<string, mixed>) (required)
- Event-specific properties.
- ?float $started
- .
Default:null
AbilitiesTracking::queue_event() AbilitiesTracking::queue event code 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 );
}
}