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

Google Analytics: remove the module and switch to is_active flag #37960

Merged
merged 14 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/_inc/client/traffic/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class Traffic extends React.Component {
foundRelated = this.props.isModuleFound( 'related-posts' ),
foundVerification = this.props.isModuleFound( 'verification-tools' ),
foundSitemaps = this.props.isModuleFound( 'sitemaps' ),
foundAnalytics = this.props.isModuleFound( 'google-analytics' ),
foundAnalytics = this.props.isWoASite && this.props.isModuleFound( 'google-analytics' ),
foundBlaze = this.props.isModuleFound( 'blaze' );

if ( ! this.props.searchTerm && ! this.props.active ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: major
Type: other

Google Analytics: remove the module and its remnants.
1 change: 0 additions & 1 deletion projects/plugins/jetpack/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"automattic/jetpack-device-detection": "@dev",
"automattic/jetpack-error": "@dev",
"automattic/jetpack-forms": "@dev",
"automattic/jetpack-google-analytics": "@dev",
"automattic/jetpack-image-cdn": "@dev",
"automattic/jetpack-import": "@dev",
"automattic/jetpack-ip": "@dev",
Expand Down
71 changes: 1 addition & 70 deletions projects/plugins/jetpack/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @package automattic/jetpack
*/

use Automattic\Jetpack\Google_Analytics\GA_Manager;
use Automattic\Jetpack\Waf\Brute_Force_Protection\Brute_Force_Protection_Shared_Functions;

new WPCOM_JSON_API_Site_Settings_Endpoint(
Expand Down Expand Up @@ -595,38 +594,6 @@ protected function get_locale( $key ) {
return false;
}

/**
* Get GA tracking code.
*
* @deprecated 13.6
*/
protected function get_google_analytics() {
if ( class_exists( GA_Manager::class ) ) {
$option_name = GA_Manager::get_instance()->get_google_analytics_option_name();
} else {
$option_name = $this->get_google_analytics_option_name();
}

return get_option( $option_name );
}

/**
* Get GA tracking code option name.
*
* @deprecated 13.6
*/
protected function get_google_analytics_option_name() {
if ( class_exists( GA_Manager::class ) ) {
return GA_Manager::get_instance()->get_google_analytics_option_name();
}

/** This filter is documented in class.json-api-endpoints.php */
$is_jetpack = true === apply_filters( 'is_jetpack_site', false, get_current_blog_id() );
$option_name = $is_jetpack ? 'jetpack_wga' : 'wga';

return $option_name;
}

/**
* Updates site settings for authorized users
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName

use Automattic\Jetpack\Google_Analytics\GA_Manager;

new WPCOM_JSON_API_Site_Settings_V1_3_Endpoint(
array(
Expand Down Expand Up @@ -137,53 +136,4 @@ protected function get_defaults() {
'ec_track_add_to_cart' => false,
);
}

/**
* Filter the parent's response to include the fields
* added to 1.3 (and their defaults)
*
* @deprecated 13.6
*
* @param array $settings - the settings array.
*
* @return array
*/
public function filter_site_settings_endpoint_get( $settings ) {
if ( class_exists( GA_Manager::class ) ) {
$option_name = GA_Manager::get_instance()->get_google_analytics_option_name();
} else {
// @phan-suppress-next-line PhanDeprecatedFunction
$option_name = $this->get_google_analytics_option_name();
}

$option = get_option( $option_name, array() );
$settings['wga'] = wp_parse_args( $option, $this->get_defaults() );
return $settings;
}

/**
* Filter the parent's response to consume our new fields
*
* @param array $wga - Array of existing Google Analytics settings.
* @param array $new_values - the new values we're adding.
*
* @deprecated 13.6
*
* @return array
*/
public function filter_update_google_analytics( $wga, $new_values ) {
$wga_keys = array_keys( $this->get_defaults() );
foreach ( $wga_keys as $wga_key ) {
// Skip code since the parent class has handled it
if ( 'code' === $wga_key ) {
continue;
}
// All our new keys are booleans, so let's coerce each key's value
// before updating the value in settings
if ( array_key_exists( $wga_key, $new_values ) ) {
$wga[ $wga_key ] = WPCOM_JSON_API::is_truthy( $new_values[ $wga_key ] );
}
}
return $wga;
}
}
22 changes: 0 additions & 22 deletions projects/plugins/jetpack/modules/google-analytics.php

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading