Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CAPI tracker by Pinterest request. #1026

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 2 additions & 4 deletions class-pinterest-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,9 @@ public static function init_tracking() {
return false;
}

$tag_tracker = new Tag();
$user = new User( WC_Geolocation::get_ip_address(), wc_get_user_agent() );
$conversions_tracker = new Conversions( $user );
$tag_tracker = new Tag();

return new Tracking( array( $tag_tracker, $conversions_tracker ) );
return new Tracking( array( $tag_tracker ) );
}

/**
Expand Down
46 changes: 46 additions & 0 deletions tests/Unit/TrackingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Automattic\WooCommerce\Pinterest;

use Automattic\WooCommerce\Pinterest\Tracking\Conversions;
use Automattic\WooCommerce\Pinterest\Tracking\Data\None;
use Automattic\WooCommerce\Pinterest\Tracking\Tag;
use Pinterest_For_Woocommerce;
Expand Down Expand Up @@ -85,4 +86,49 @@ public function test_tracking_calls_trackers() {

$tracking->track_event( 'test', $data );
}

public function test_tracking_calls_multiple_trackers() {
Pinterest_For_Woocommerce::save_settings( array( 'tracking_tag' => 'WD7AFW51GS' ) );

$tracking = new Tracking();

$pinterest_tag_tracker = $this->createMock( Tag::class );
$pinterest_capi_tracker = $this->createMock( Conversions::class );

$tracking->add_tracker( $pinterest_tag_tracker );
$tracking->add_tracker( $pinterest_capi_tracker );

$data = new None( 'event_id' );
$pinterest_tag_tracker->expects( $this->once() )
->method( 'track_event' )
->with( 'test', $data );
$pinterest_capi_tracker->expects( $this->once() )
->method( 'track_event' )
->with( 'test', $data );

$tracking->track_event( 'test', $data );
}

public function test_tracking_calls_no_detached_trackers() {
Pinterest_For_Woocommerce::save_settings( array( 'tracking_tag' => 'WD7AFW51GS' ) );

$tracking = new Tracking();

$pinterest_tag_tracker = $this->createMock( Tag::class );
$pinterest_capi_tracker = $this->createMock( Conversions::class );

$tracking->add_tracker( $pinterest_tag_tracker );
$tracking->add_tracker( $pinterest_capi_tracker );
$tracking->remove_tracker( get_class( $pinterest_capi_tracker ) );

$data = new None( 'event_id' );
$pinterest_tag_tracker->expects( $this->once() )
->method( 'track_event' )
->with( 'test', $data );
$pinterest_capi_tracker->expects( $this->never() )
->method( 'track_event' )
->with( 'test', $data );

$tracking->track_event( 'test', $data );
}
}
Loading