Code Duplication    Length = 15-15 lines in 2 locations

_inc/lib/tracks/client.php 1 location

@@ 126-140 (lines=15) @@
123
 *
124
 * @deprecated 7.5.0 use Automattic\Jetpack\Tracking->tracks_record_event instead
125
 */
126
function jetpack_tracks_record_event( $user, $event_name, $properties = array(), $event_timestamp_millis = false ) {
127
	// @TODO: Enable these once we're sure that we won't be flooding sites with notices.
128
	//_doing_it_wrong( 'jetpack_tracks_record_event', 'Use Automattic\Jetpack\Tracking::tracks_record_event instead.', '7.5.0' );
129
130
	// We don't want to track user events during unit tests/CI runs.
131
	if ( $user instanceof WP_User && 'wptests_capabilities' === $user->cap_key ) {
132
		return false;
133
	}
134
135
	$event_obj = jetpack_tracks_build_event_obj( $user, $event_name, $properties, $event_timestamp_millis );
136
137
	if ( is_wp_error( $event_obj->error ) ) {
138
		return $event_obj->error;
139
	}
140
141
	return $event_obj->record();
142
}
143

packages/tracking/src/Tracking.php 1 location

@@ 76-90 (lines=15) @@
73
	 *
74
	 * @return bool true for success | \WP_Error if the event pixel could not be fired
75
	 */
76
	function tracks_record_event( $user, $event_name, $properties = array(), $event_timestamp_millis = false ) {
77
78
		// We don't want to track user events during unit tests/CI runs.
79
		if ( $user instanceof \WP_User && 'wptests_capabilities' === $user->cap_key ) {
80
			return false;
81
		}
82
83
		$event_obj = $this->tracks_build_event_obj( $user, $event_name, $properties, $event_timestamp_millis );
84
85
		if ( is_wp_error( $event_obj->error ) ) {
86
			return $event_obj->error;
87
		}
88
89
		return $event_obj->record();
90
	}
91
92
	/**
93
	 * Procedurally build a Tracks Event Object.