diff --git a/src/TrackingPlugin.php b/src/TrackingPlugin.php index 9415365..cec50f5 100644 --- a/src/TrackingPlugin.php +++ b/src/TrackingPlugin.php @@ -54,6 +54,8 @@ public function __construct( string $mixpanel_token, string $plugin, string $bra * @param string $event Event name. * @param mixed[] $properties Event properties. * @param string $event_capability The capability required to track the event. + * + * @return void */ public function track( string $event, array $properties, string $event_capability = '' ): void { /** @@ -73,6 +75,18 @@ public function track( string $event, array $properties, string $event_capabilit return; } + $this->track_direct( $event, $properties ); + } + + /** + * Track an event directly in Mixpanel, bypassing capability checks. + * + * @param string $event Event name. + * @param mixed[] $properties Event properties. + * + * @return void + */ + public function track_direct( string $event, array $properties ): void { $host = wp_parse_url( get_home_url(), PHP_URL_HOST ); if ( ! $host ) { diff --git a/tests/Unit/TrackingPlugin/TrackTest.php b/tests/Unit/TrackingPlugin/TrackTest.php index ca755fb..e6b9f91 100644 --- a/tests/Unit/TrackingPlugin/TrackTest.php +++ b/tests/Unit/TrackingPlugin/TrackTest.php @@ -44,6 +44,7 @@ protected function set_up() { * @return void */ public function testShouldDoExpected( $config, $expected ) { + if ( $config['filter_value'] ) { Filters\expectApplied( 'wp_mixpanel_event_capability' ) ->once()