| @@ -83,11 +83,15 @@ | ||
| 83 | 83 | * |
| 84 | 84 | * @param string $ability_id Ability slug, e.g. `imagify/get-stats`. |
| 85 | 85 | * @param string $ability_name Human-readable ability label. |
| 86 | 86 | * @param float $start_time microtime(true) captured before execute() ran. |
| 87 | + * @param bool $is_preview True when the call was a credit-consumption preview | |
| 88 | + * (`confirmation_required`/`insufficient_quota`/`invalid_api_key`) | |
| 89 | + * rather than a real execution. Defaults to false so | |
| 90 | + * non-quota-sensitive abilities keep their current behavior. | |
| 87 | 91 | * @return void |
| 88 | 92 | */ |
| 89 | - public function track_ability_executed( string $ability_id, string $ability_name, float $start_time ): void { | |
| 93 | + public function track_ability_executed( string $ability_id, string $ability_name, float $start_time, bool $is_preview = false ): void { | |
| 90 | 94 | if ( ! $this->can_track() ) { |
| 91 | 95 | return; |
| 92 | 96 | } |
| 93 | 97 | |
| @@ -96,8 +100,9 @@ | ||
| 96 | 100 | [ |
| 97 | 101 | 'ability_id' => $ability_id, |
| 98 | 102 | 'ability_name' => $ability_name, |
| 99 | 103 | 'execution_time_ms' => round( ( microtime( true ) - $start_time ) * 1000, 2 ), |
| 104 | + 'is_preview' => $is_preview, | |
| 100 | 105 | ] |
| 101 | 106 | ); |
| 102 | 107 | |
| 103 | 108 | $this->mixpanel->track_direct( 'MCP Ability Executed', $event_data ); |