Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/TrackingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand All @@ -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 ) {
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/TrackingPlugin/TrackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down