static public record_event ( mixed $event ) : mixed | ||
$event | mixed | Event object to send to Tracks. An array will be cast to object. Required. Properties are included directly in the pixel query string after light validation. |
리턴 | mixed | True on success, WP_Error on failure |
static function record_event($event)
{
if (!$event instanceof Jetpack_Tracks_Event) {
$event = new Jetpack_Tracks_Event($event);
}
if (is_wp_error($event)) {
return $event;
}
$pixel = $event->build_pixel_url($event);
if (!$pixel) {
return new WP_Error('invalid_pixel', 'cannot generate tracks pixel for given input', 400);
}
return self::record_pixel($pixel);
}
/** * Procedurally (vs. Object-oriented), track an event object (or flat array) * NOTE: Use this only when the simpler jetpack_tracks_record_event() function won't work for you. * @param \Jetpack_Tracks_Event $event The event object. * @return \Jetpack_Tracks_Event|\WP_Error */ function jetpack_tracks_record_event_raw($event) { return Jetpack_Tracks_Client::record_event($event); }