-
Notifications
You must be signed in to change notification settings - Fork 813
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
Tracks: Don't track users in dev mode or when opted out #13698
Conversation
This is an automated check which relies on |
This will avoid having to bypass the pre-commit hook for all commits to this file
This PR looks like it might contain user tracking functions. We need to make sure that it is GDPR Compliant. Rules triggering this positive scan:
cc: @pesieminski |
Let's update the legacy file too. I'll push a commit. |
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 added a commit to fix all PHPCS issues, to avoid having to bypass the pre-commit hook for that file in the future.
I also have one remark, I think we could simplify this a bit.
The TOS check is used for confirming that a site is "Trackable". For sites in development mode or are not active, we should not track them.
7921945
to
7adc285
Compare
Just to be sure. See #13698 (comment)
Don't track users in dev mode or when opted out * Fix all phpcs issues This will avoid having to bypass the pre-commit hook for all commits to this file * [not verified] Opt out of tracking in dev mode in legacy branch. * PHPCS fixes * Include development mode check within Jetpack::jetpack_tos_agreed. The TOS check is used for confirming that a site is "Trackable". For sites in development mode or are not active, we should not track them. * Docblock for is_active_and_not_development function * Bring cookie check back Just to be sure. See Automattic/jetpack#13698 (comment)
|
||
// We don't want to track user events during unit tests/CI runs. | ||
if ( $user instanceof \WP_User && 'wptests_capabilities' === $user->cap_key ) { | ||
return false; | ||
} | ||
|
||
// 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() ) { |
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.
Since Jetpack
is not a package this means that his package is not usable outside of jetpack.
Which kind of defeats the purpose of this a package.
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.
That's a good point. Isn't it already an issue with this already?
if ( ! Jetpack::jetpack_tos_agreed() || ! empty( $_COOKIE['tk_opt-out'] ) ) { |
Does this mean we should also refrain from relying on constants like JETPACK__PLUGIN_FILE
or JETPACK__VERSION
, that are not set anywhere but in Jetpack right now?
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.
To be honest I don't quite know.
but I always assume that the src
folder is there code that is supposed to be working also outside of jetpack and the src
are classes that could be used outside of Jetpack.
I think using a filter here instead would work well.
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.
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 constants are a different thing FWIW, we have the constants
package and we can use it to access any constants inside packages without relying on the core plugin.
We shouldn't fire Tracks events when we are in dev mode, or if users haven't accepted our TOS, or if they have opted out of Tracks.
Changes proposed in this Pull Request:
Is this a new feature or does it add/remove features to an existing part of Jetpack?
Testing instructions:
jetpack_search_widget_widget_added
event in Trackswp-config.php
):define( 'JETPACK_DEV_DEBUG', true );
jetpack_search_widget_widget_added
event in TracksProposed changelog entry for your changes: