Skip to content

Commit

Permalink
Tracks: use filter instead of relying on Jetpack class (#13746)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeherve authored and kraftbj committed Oct 15, 2019
1 parent 253cef3 commit 2d21118
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 7 additions & 1 deletion class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -6938,7 +6938,13 @@ public static function get_calypso_env() {
* Will return true if a user has clicked to register, or is already connected.
*/
public static function jetpack_tos_agreed() {
return Jetpack_Options::get_option( 'tos_agreed' ) || self::is_active_and_not_development_mode();
$tos_agreed = Jetpack_Options::get_option( 'tos_agreed' ) || self::is_active_and_not_development_mode();

if ( $tos_agreed ) {
add_filter( 'jetpack_tos_agreed', '__return_true' );
}

return $tos_agreed;
}

/**
Expand Down
11 changes: 10 additions & 1 deletion packages/tracking/src/Tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,16 @@ public function tracks_record_event( $user, $event_name, $properties = array(),
}

// Don't track users who have opted out or not agreed to our TOS, or are not running an active Jetpack.
if ( ! \Jetpack::jetpack_tos_agreed() ) {
if (
/**
* Filter whether ToS were accepted on this site.
*
* @since 7.9.0
*
* @param bool $tos_agreed Was ToS accepted for this site. Defaults to false.
*/
apply_filters( 'jetpack_tos_agreed', false )
) {
return false;
}

Expand Down

0 comments on commit 2d21118

Please sign in to comment.