Skip to content

Commit

Permalink
Clean up first pass at user tracks API (#9164)
Browse files Browse the repository at this point in the history
* Revert "Add/user tracking option api (#9003)"

This reverts commit c9b754c.

* remove obsolete settings value for jetpack_event_tracking
  • Loading branch information
dereksmart authored and zinigor committed Mar 27, 2018
1 parent ef8b0d8 commit 33b2f8d
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 133 deletions.
9 changes: 0 additions & 9 deletions _inc/lib/class.core-rest-api-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -1993,15 +1993,6 @@ public static function get_updateable_data_list( $selector = '' ) {
'jp_group' => 'settings',
),

// Whether user allows usage statistics.
'jetpack_event_tracking' => array(
'description' => 'Disables event tracking.',
'type' => 'boolean',
'default' => 0,
'validate_callback' => __CLASS__ . '::validate_boolean',
'jp_group' => 'settings',
),

);

// Add modules to list so they can be toggled
Expand Down
50 changes: 0 additions & 50 deletions _inc/lib/class.jetpack-user-event-tracking.php

This file was deleted.

12 changes: 0 additions & 12 deletions _inc/lib/core-api/class.jetpack-core-api-module-endpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,6 @@ public function get_all_options() {
);
break;

case 'jetpack_event_tracking':
jetpack_require_lib( 'class.jetpack-user-event-tracking' );
$response[ $setting ] = Jetpack_User_Event_Tracking::is_enabled( get_current_user_id() );
break;

default:
$response[ $setting ] = Jetpack_Core_Json_Api_Endpoints::cast_value( get_option( $setting ), $settings[ $setting ] );
break;
Expand Down Expand Up @@ -955,13 +950,6 @@ public function update_data( $request ) {
}
break;

case 'jetpack_event_tracking':
jetpack_require_lib( 'class.jetpack-user-event-tracking' );
$updated = $value
? Jetpack_User_Event_Tracking::enable( get_current_user_id() )
: Jetpack_User_Event_Tracking::disable( get_current_user_id() );
break;

case 'show_welcome_for_new_plan':
// If option value was the same, consider it done.
$updated = get_option( $option ) !== $value ? update_option( $option, (bool) $value ) : true;
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<file>tests/php/test_class.jetpack-constants.php</file>
<file>tests/php/test_class.jetpack-connection-banner.php</file>
<file>tests/php/test_class.jetpack-options.php</file>
<file>tests/php/test_class.jetpack-user-event-tracking.php</file>
</testsuite>
<testsuite name="php-lint">
<file phpVersion="5.3.0" phpVersionOperator="lte">tests/php/test_php-lint.php</file>
Expand Down
3 changes: 1 addition & 2 deletions sync/class.jetpack-sync-defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ public static function get_constants_whitelist() {
'hosting_provider' => array( 'Jetpack_Sync_Functions', 'get_hosting_provider' ),
'locale' => 'get_locale',
'site_icon_url' => array( 'Jetpack_Sync_Functions', 'site_icon_url' ),
'roles' => array( 'Jetpack_Sync_Functions', 'roles' ),
'default_user_event_tracking' => array( 'Jetpack_Sync_functions', 'get_default_user_tracking_value' )
'roles' => array( 'Jetpack_Sync_Functions', 'roles' ),
);


Expand Down
5 changes: 0 additions & 5 deletions sync/class.jetpack-sync-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public static function get_shortcodes() {
return array_keys( $shortcode_tags );
}

public static function get_default_user_tracking_value() {
jetpack_require_lib( 'class.jetpack-user-event-tracking' );
return Jetpack_User_Event_Tracking::default_value();
}

/**
* Removes any callback data since we will not be able to process it on our side anyways.
*/
Expand Down
10 changes: 1 addition & 9 deletions sync/class.jetpack-sync-module-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ public function expand_user( $user ) {
$user->locale = get_user_locale( $user->ID );
}
}
jetpack_require_lib( 'class.jetpack-user-event-tracking' );
if ( Jetpack_User_Event_Tracking::has_value( $user->ID ) ) {
$user->jetpack_tracking_enabled = Jetpack_User_Event_Tracking::is_enabled( $user->ID );
}

return $user;
}

Expand Down Expand Up @@ -289,11 +286,6 @@ function maybe_save_user_meta( $meta_id, $user_id, $meta_key, $value ) {
$this->add_flags( $user_id, array( 'locale_changed' => true ) );
}

jetpack_require_lib( 'class.jetpack-user-event-tracking' );
if ( $meta_key === Jetpack_User_Event_Tracking::$KEY ) {
$this->add_flags( $user_id, array( 'tracking_opt_out_changed' => true ) );
}

$user = get_user_by( 'id', $user_id );
if ( $meta_key === $user->cap_key ) {
$this->add_flags( $user_id, array( 'capabilities_changed' => true ) );
Expand Down
15 changes: 7 additions & 8 deletions tests/php.multisite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
</php>
<testsuites>
<testsuite name="general">
<file>php/test_class.jetpack.php</file>
<file>php/test_class.functions.compat.php</file>
<file>php/test_class.jetpack-network.php</file>
<file>php/test_class.jetpack-client-server.php</file>
<file>php/test_class.jetpack-xmlrpc-server.php</file>
<file>php/test_class.jetpack-heartbeat.php</file>
<file>php/test_class.jetpack-user-event-tracking.php</file>
</testsuite>
<file>php/test_class.jetpack.php</file>
<file>php/test_class.functions.compat.php</file>
<file>php/test_class.jetpack-network.php</file>
<file>php/test_class.jetpack-client-server.php</file>
<file>php/test_class.jetpack-xmlrpc-server.php</file>
<file>php/test_class.jetpack-heartbeat.php</file>
</testsuite>
<testsuite name="core-api">
<directory phpVersion="5.6.0" phpVersionOperator=">=" prefix="test_" suffix=".php">tests/php/core-api</directory>
</testsuite>
Expand Down
1 change: 0 additions & 1 deletion tests/php/sync/test_class.jetpack-sync-callables.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function test_sync_callable_whitelist() {
'site_icon_url' => Jetpack_Sync_Functions::site_icon_url(),
'shortcodes' => Jetpack_Sync_Functions::get_shortcodes(),
'roles' => Jetpack_Sync_Functions::roles(),
'default_user_event_tracking' => Jetpack_Sync_Functions::get_default_user_tracking_value()
);

if ( function_exists( 'wp_cache_is_enabled' ) ) {
Expand Down
36 changes: 0 additions & 36 deletions tests/php/test_class.jetpack-user-event-tracking.php

This file was deleted.

0 comments on commit 33b2f8d

Please sign in to comment.