-
Notifications
You must be signed in to change notification settings - Fork 799
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
Add/user tracking option api #9003
Conversation
df4c193
to
1dccdce
Compare
… the default value. Still need sync tests for this.
1dccdce
to
7cf4d35
Compare
|
||
static private function set( $user_id, $value ) { | ||
self::$_cache[ $user_id ] = (bool) $value; | ||
update_user_meta( $user_id, self::KEY, $value ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this to return the update_user_meta
and also return the self::set
in disable
and enable
.
This was done to be able to return errors in case it doesn't work as expected.
$user_tracking = self::default_value(); | ||
} | ||
self::$_cache[ $user_id ] = (bool) $user_tracking; | ||
return (bool) $user_tracking(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be $user_tracking
.
class Jetpack_User_Event_Tracking { | ||
|
||
private static $_cache = array(); | ||
const KEY = 'jetpack_event_tracking'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not PHP 5.2 safe.
or by using the const keyword outside a class definition as of PHP 5.3.0
|
||
static private function set( $user_id, $value ) { | ||
self::$_cache[ $user_id ] = (bool) $value; | ||
return update_user_meta( $user_id, self::$KEY, $value ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you casting this as boolean when you save it to the cache, but not when you update the user meta data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I want to be able to distinguish between a set value (0,1) vs the default value (false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks!
* | ||
* @since 6.0.0 | ||
* | ||
* @param bool Default to false. (user tracking enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Isn't the default
true
? -
Update this line to
* @param bool $enable_tracking Whether to enable user tracking. Defaults to true, which allows user tracking.
tests/php.multisite.xml
Outdated
@@ -14,6 +14,7 @@ | |||
<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>tests/php/test_class.jetpack-user-event-tracking.php</file> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check indentation.
55d15a2
to
445566c
Compare
👋 not sure how the sync to WP.com works: can it potentially be both ways? ( If someone sets it on WP.com via Calypso, have it be synced in Jetpack? ) For now I've been implementing the Calypso stuff using D9412-code as the backend. |
|
||
class Jetpack_User_Event_Tracking { | ||
|
||
private static $_cache = array(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by comment since I'm looking at this in concert with tracking on the Calypso side: what's the rationale behind having a local cache for this user meta? The user meta functions already leverage WP's built-in wp_cache_*
functions, which also persist in memory for a session like this is doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rational was that is would be faster. But I see your point and would be happy to remove it.
Hi @bperson
Right now this wouldn't be the case that things get synced. We do however send this data to .com when the user sets it on the Jetpack side so that we can stop tracking the user's actions on a per site basis. For example currently we also do not sync the user's display name across the different Jetpack sites. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, merging.
* Add new settings route for /privacy * add basic option for toggling, connected to setting * Add smooth scroll when user clicks Privacy link so they're taken up to where the navigation bar is so they don't miss the content and think nothing happened * Add PropTypes and declare props. Combine selectors imported from the same path. Introduce ModuleSettingsForm to use getOptionValue and isSavingAnyOption so ththe toggle now works. Simplify mapStateToProps and mapDispatchToProps. Simplify other minor code. * Combine sentence to save option with an existing one to avoid duplicating code. * Add link to privacy policy plus placeholder text * Add link to privacy blog * Update code to work with PR #9003 so we save this setting by user * Update privacy texts and links.
This reverts commit c9b754c.
* Changelog 6.0: create base for changelog. * Add #8938 to changelog * Add #8962 to changelog * Add #8974 to changelog * Add #8975 to changelog * Add #8978 to changelog * Add #8867 to changelog * Add #8937 to changelog * Add #8961 to changelog * Add #8855 to changelog * Add #8944 to changelog * Add #8973 to changelog * Add #8977 to changelog * Add #8979 to changelog * Add #8980 to changelog * Add #8982 to changelog * Add #8983 to changelog * Add #8984 to changelog * Add #8986 to changelog * Add #9005 to changelog * Add #9010 to changelog * Add #9012 to changelog * Add #9021 to changelog * Add #9022 to changelog * Add #9056 to changelog * Add #9061 to changelog * Add #9079 to changelog * Add #9080 to changelog * Add #9088 to changelog * Add #9096 to changelog * Add #9097 to changelog * Add #9100 to changelog * Add #9107 to changelog * Add #8969 to changelog * Add #8993 to changelog * Add #9003 to changelog * Add #9031 to changelog * Add #8945 to changelog * Add #9052 to changelog * Add #9058 to changelog * Add #9066 to changelog * Add #9076 to changelog * Add #9053 to changelog * Add #9108 to changelog * Add #9135 to changelog * Add #9148 to changelog * Add #9125 to changelog * Add #9137 to changelog * Added testing instructions for 6.0. * Added IS testing instructions, huge props to @tiagonoronha. * Added #8498 to changelog. * Added #8954 to changelog. * Added #8985 to changelog. * add #9027 * add #9112 to changelog * add #9136 to changelog * add #9102 to changelog * add #9093 to changelog * add #9062 to changelog * add #9172 to changelog
Changes proposed in this Pull Request:
Testing instructions:
Proposed changelog entry for your changes:
Changelog entry
Added ability to disable user events tracking.