PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.1
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.1
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / includes / core / MCP / Observability / FunnelMcpObservabilityHandler.php

FunnelMcpObservabilityHandler.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.1, at includes/core/MCP/Observability/FunnelMcpObservabilityHandler.php

58 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * FunnelMcpObservabilityHandler — observability sink for the WPFunnels MCP server.
4 *
5 * Wraps the adapter's error-log handler and drops the events that the adapter
6 * emits while building the server, keeping only the events that describe
7 * something a site owner would actually want in an audit trail.
8 *
9 * @package WPFunnels\MCP\Observability
10 * @since 3.13.0
11 */
12
13 namespace WPFunnels\MCP\Observability;
14
15 defined( 'ABSPATH' ) || exit;
16
17 use WP\MCP\Infrastructure\Observability\ErrorLogMcpObservabilityHandler as AdapterErrorLogHandler;
18
19 /**
20 * Class FunnelMcpObservabilityHandler
21 *
22 * Logs MCP tool traffic without the per-request lifecycle noise.
23 */
24 class FunnelMcpObservabilityHandler extends AdapterErrorLogHandler {
25
26 /**
27 * Events the adapter emits as a side effect of constructing the server,
28 * whether or not anyone is using MCP.
29 *
30 * The adapter builds every registered server on `rest_api_init`, so passing
31 * these through to error_log() writes one line per REST request on every
32 * site — hundreds of thousands of lines on a busy store, none of them
33 * actionable. Tool traffic (`mcp.request`) is still logged.
34 *
35 * @var string[]
36 */
37 private const LIFECYCLE_EVENTS = array(
38 'mcp.server.created',
39 'mcp.component.registration',
40 );
41
42 /**
43 * Record an event unless it is per-request lifecycle noise.
44 *
45 * @param string $event The event name to record.
46 * @param array $tags Optional tags to attach to the event.
47 * @param float|null $duration_ms Optional duration in milliseconds.
48 * @return void
49 */
50 public function record_event( string $event, array $tags = array(), ?float $duration_ms = null ): void {
51 if ( in_array( self::format_metric_name( $event ), self::LIFECYCLE_EVENTS, true ) ) {
52 return;
53 }
54
55 parent::record_event( $event, $tags, $duration_ms );
56 }
57 }
58