| @@ -243,8 +243,12 @@ | ||
| 243 | 243 | } else { |
| 244 | 244 | $event_data['tags'] = ['category' => 'user-feedback']; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | + // Attach white-label metadata to the issue-report event (not only the | |
| 248 | + // user-feedback item) so support can identify the reporting site. | |
| 249 | + $event_data = self::apply_white_label_context($event_data, $feedback); | |
| 250 | + | |
| 247 | 251 | // Send the event first with attachment |
| 248 | 252 | $event_result = $this->sendToSentry($event_data, 'event', $attachment); |
| 249 | 253 | |
| 250 | 254 | // Extract event_id from response |
| @@ -269,9 +273,46 @@ | ||
| 269 | 273 | $feedback_result = $this->sendToSentry($data, 'user_report'); |
| 270 | 274 | |
| 271 | 275 | return is_array($feedback_result) ? $feedback_result['success'] : $feedback_result; |
| 272 | 276 | } |
| 273 | - | |
| 277 | + | |
| 278 | + /** | |
| 279 | + * Attach white-label metadata to an issue-report event payload. | |
| 280 | + * | |
| 281 | + * Support needs to tell from the Sentry event alone whether the reporting | |
| 282 | + * site is white-labeled, so the values go on the event itself (tags plus a | |
| 283 | + * white_label context), not only on the associated user-feedback item. | |
| 284 | + * | |
| 285 | + * Static and public so the unit suite can exercise the mapping directly; | |
| 286 | + * captureFeedback() runs the result through a private curl sender that has | |
| 287 | + * no test seam. | |
| 288 | + * | |
| 289 | + * @param array $event_data Event payload built by formatMessage(). | |
| 290 | + * @param array $feedback Feedback data supplied by the report handler. | |
| 291 | + * @return array The event payload with white-label tags and context added. | |
| 292 | + */ | |
| 293 | + public static function apply_white_label_context(array $event_data, array $feedback) | |
| 294 | + { | |
| 295 | + $is_whitelabel = !empty($feedback['is_whitelabel']); | |
| 296 | + $brand_name = isset($feedback['whitelabel_brand_name']) | |
| 297 | + ? sanitize_text_field($feedback['whitelabel_brand_name']) : ''; | |
| 298 | + $support_email = isset($feedback['whitelabel_support_email']) | |
| 299 | + ? sanitize_email($feedback['whitelabel_support_email']) : ''; | |
| 300 | + $site_url = isset($feedback['site_url']) ? esc_url_raw($feedback['site_url']) : ''; | |
| 301 | + $event_data['tags']['is_whitelabel'] = $is_whitelabel ? 'true' : 'false'; | |
| 302 | + $event_data['tags']['whitelabel_brand_name'] = $brand_name; | |
| 303 | + $event_data['tags']['whitelabel_support_email'] = $support_email; | |
| 304 | + $event_data['tags']['site_url'] = $site_url; | |
| 305 | + $event_data['contexts']['white_label'] = array( | |
| 306 | + 'is_whitelabel' => $is_whitelabel, | |
| 307 | + 'whitelabel_brand_name' => $brand_name, | |
| 308 | + 'whitelabel_support_email' => $support_email, | |
| 309 | + 'site_url' => $site_url, | |
| 310 | + ); | |
| 311 | + | |
| 312 | + return $event_data; | |
| 313 | + } | |
| 314 | + | |
| 274 | 315 | /** |
| 275 | 316 | * Format exception data for Sentry API |
| 276 | 317 | */ |
| 277 | 318 | private function formatException($exception, $extra = []) { |