Automattic\WooCommerce\Internal\Admin\Settings\PaymentsProviders\WooPayments
WooPaymentsService::record_event
Send a Tracks event.
By default, Woo adds url, blog_lang, blog_id, store_id, products_count, and wc_version properties to every event.
Method of the class: WooPaymentsService{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WooPaymentsService = new WooPaymentsService(); $WooPaymentsService->record_event( $name, $business_country, $properties );
- $name(string) (required)
- The event name. If it is not prefixed with self::EVENT_PREFIX, it will be prefixed with it.
- $business_country(string) (required)
- The business registration country code as set in the WooCommerce Payments settings. This is an ISO 3166-1 alpha-2 country code.
- $properties(array)
- The event custom properties. These properties will be merged with the default properties.
Default:properties values take precedence over the provided ones
WooPaymentsService::record_event() WooPaymentsService::record event code WC 10.7.0
public function record_event( string $name, string $business_country, array $properties = array() ) {
if ( ! function_exists( 'wc_admin_record_tracks_event' ) ) {
return;
}
// If the event name is empty, we don't record it.
if ( empty( $name ) ) {
return;
}
// If the event name is not prefixed with `settings_payments_`, we prefix it.
if ( ! str_starts_with( $name, self::EVENT_PREFIX ) ) {
$name = self::EVENT_PREFIX . $name;
}
// Add default properties to every event and overwrite custom properties with the same keys.
$properties = array_merge(
$properties,
array(
'business_country' => $business_country,
),
);
wc_admin_record_tracks_event( $name, $properties );
}