PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/woocommerce-analytics/src/API/class-wc-analytics-tracking-proxy.php +3 -20 16.3-beta → 16.3-a.1 View file →
@@ -40,11 +40,9 @@
40 40 array(
41 41 array(
42 42 'methods' => \WP_REST_Server::CREATABLE,
43 43 'callback' => array( $this, 'track_events' ),
44 - // Unauthenticated front-end event endpoint. track_events() validates consent
45 - // and records events without client-supplied server-owned properties.
46 - 'permission_callback' => '__return_true',
44 + 'permission_callback' => '__return_true', // no need to check permissions
47 45 'schema' => array( $this, 'get_public_item_schema' ),
48 46 ),
49 47 )
50 48 );
@@ -56,18 +54,8 @@
56 54 * @param \WP_REST_Request $request Full data about the request.
57 55 * @return \WP_REST_Response|\WP_Error Response object on success, or WP_Error object on failure.
58 56 */
59 57 public function track_events( $request ) {
60 - // Cached pages can still post here after proxy tracking is disabled; return a
61 - // visible error instead of losing the event to a 404.
62 - if ( ! Features::is_proxy_tracking_enabled() ) {
63 - return new \WP_Error(
64 - 'proxy_tracking_disabled',
65 - 'Proxy tracking is not enabled on this site.',
66 - array( 'status' => 403 )
67 - );
68 - }
69 -
70 58 // Check consent before processing any events
71 59 if ( ! Consent_Manager::has_analytics_consent() ) {
72 60 return new \WP_REST_Response(
73 61 array(
@@ -85,13 +73,8 @@
85 73 // If $events is a single event (associative array), wrap it in an array.
86 74 $events = array( $events );
87 75 }
88 76
89 - // Limit unauthenticated callers to a bounded number of pixel requests.
90 - if ( count( $events ) > WC_Analytics_Tracking::MAX_CLIENT_EVENTS_PER_REQUEST ) {
91 - $events = array_slice( $events, 0, WC_Analytics_Tracking::MAX_CLIENT_EVENTS_PER_REQUEST, true );
92 - }
93 -
94 77 $results = array();
95 78 $has_errors = false;
96 79
97 80 foreach ( $events as $index => $event ) {
@@ -107,9 +90,9 @@
107 90
108 91 // Validate event name and properties.
109 92 $event_name = $event['event_name'] ?? null;
110 93 $properties = $event['properties'] ?? array();
111 - if ( ! $event_name || ! is_string( $event_name ) || ! is_array( $properties ) ) {
94 + if ( ! $event_name || ! is_array( $properties ) ) {
112 95 $results[ $index ] = array(
113 96 'success' => false,
114 97 'error' => 'Missing event_name or invalid properties',
115 98 );
@@ -116,9 +99,9 @@
116 99 $has_errors = true;
117 100 continue;
118 101 }
119 102
120 - $result = WC_Analytics_Tracking::record_client_event( $event_name, $properties );
103 + $result = WC_Analytics_Tracking::record_event( $event_name, $properties );
121 104
122 105 if ( is_wp_error( $result ) ) {
123 106 $results[ $index ] = array(
124 107 'success' => false,