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: display deprecation notices #38078

Merged
merged 12 commits into from
Jun 28, 2024
Merged
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getMyJetpackWindowInitialState } from '../../data/utils/get-my-jetpack-window-state';
import useBadInstallNotice from './use-bad-install-notice';
import useConnectionErrorsNotice from './use-connection-errors-notice';
import useDeprecateFeatureNotice from './use-deprecate-feature-notice';
import useSiteConnectionNotice from './use-site-connection-notice';

const useNotificationWatcher = () => {
Expand All @@ -9,6 +10,7 @@ const useNotificationWatcher = () => {
useBadInstallNotice( redBubbleAlerts );
useSiteConnectionNotice( redBubbleAlerts );
useConnectionErrorsNotice();
useDeprecateFeatureNotice( redBubbleAlerts );
};

export default useNotificationWatcher;
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useContext, useEffect } from 'react';
import { NOTICE_PRIORITY_MEDIUM } from '../../context/constants';
import { NoticeContext } from '../../context/notices/noticeContext';
import type { NoticeOptions } from '../../context/notices/types';

type RedBubbleAlerts = Window[ 'myJetpackInitialState' ][ 'redBubbleAlerts' ];

const useDeprecateFeatureNotice = ( redBubbleAlerts: RedBubbleAlerts ) => {
const { setNotice } = useContext( NoticeContext );

useEffect( () => {
const deprecateAlerts = Object.keys( redBubbleAlerts ).filter( key =>
key.endsWith( '-deprecate-feature' )
) as Array< `${ string }-deprecate-feature` >;

if ( deprecateAlerts.length === 0 ) {
return;
}

const alert = redBubbleAlerts[ deprecateAlerts[ 0 ] ];
const { text, link } = alert.data;

const onCtaClick = () => {
window.open( link.url );
};

const noticeOptions: NoticeOptions = {
id: 'deprecate-feature-notice',
level: 'error',
actions: [
{
label: link.label,
onClick: onCtaClick,
noDefaultClasses: true,
},
],
priority: NOTICE_PRIORITY_MEDIUM,
};

setNotice( {
message: text,
options: noticeOptions,
} );
}, [ redBubbleAlerts, setNotice ] );
};

export default useDeprecateFeatureNotice;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add the Google Analytics deprecation notice.
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"link-template": "https://github.com/Automattic/jetpack-my-jetpack/compare/${old}...${new}"
},
"branch-alias": {
"dev-trunk": "4.26.x-dev"
"dev-trunk": "4.27.x-dev"
},
"version-constants": {
"::PACKAGE_VERSION": "src/class-initializer.php"
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-my-jetpack",
"version": "4.26.1-alpha",
"version": "4.27.0-alpha",
"description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Initializer {
*
* @var string
*/
const PACKAGE_VERSION = '4.26.1-alpha';
const PACKAGE_VERSION = '4.27.0-alpha';

/**
* HTML container ID for the IDC screen on My Jetpack page.
Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/backup/changelog/add-ga-deprecation-notice
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


2 changes: 1 addition & 1 deletion projects/plugins/backup/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"autoloader-suffix": "9559eef123208b7d1b9c15b978567267_backupⓥ2_7",
"autoloader-suffix": "9559eef123208b7d1b9c15b978567267_backupⓥ2_8_alpha",
"allow-plugins": {
"automattic/jetpack-autoloader": true,
"automattic/jetpack-composer-plugin": true
Expand Down
4 changes: 2 additions & 2 deletions projects/plugins/backup/composer.lock

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

2 changes: 1 addition & 1 deletion projects/plugins/backup/jetpack-backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: Jetpack VaultPress Backup
* Plugin URI: https://jetpack.com/jetpack-backup
* Description: Easily restore or download a backup of your site from a specific moment in time.
* Version: 2.7
* Version: 2.8-alpha
* Author: Automattic - Jetpack Backup team
* Author URI: https://jetpack.com/
* License: GPLv2 or later
Expand Down
5 changes: 5 additions & 0 deletions projects/plugins/boost/changelog/add-ga-deprecation-notice
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/boost/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
@@ -1,5 +1,6 @@
import { JETPACK_CONTACT_BETA_SUPPORT } from 'constants/urls';
import { getRedirectUrl } from '@automattic/jetpack-components';
import { ExternalLink } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import ConnectionBanner from 'components/connection-banner';
Expand Down Expand Up @@ -29,10 +30,12 @@ import {
userIsSubscriber,
getConnectionErrors,
getSiteAdminUrl,
isWoASite,
} from 'state/initial-state';
import { getLicensingError, clearLicensingError } from 'state/licensing';
import { getModule } from 'state/modules';
import { getModule, isModuleActivated } from 'state/modules';
import { getSiteDataErrors } from 'state/site';
import { isFetchingPluginsData, isPluginActive } from 'state/site/plugins';
import { StartFreshDeprecationWarning } from '../../writing/custom-css';
import DismissableNotices from './dismissable';
import JetpackConnectionErrors from './jetpack-connection-errors';
Expand Down Expand Up @@ -242,6 +245,22 @@ class JetpackNotices extends React.Component {
<StartFreshDeprecationWarning siteAdminUrl={ this.props.siteAdminUrl } />
</SimpleNotice>
) }
{ this.props.showGoogleAnalyticsNotice && (
<SimpleNotice status="is-warning" showDismiss={ false }>
<div>
{ __(
"Jetpack's Google Analytics feature will be removed on August 6, 2024.",
'jetpack'
) }
</div>
<ExternalLink href={ getRedirectUrl( 'jetpack-support-google-analytics' ) }>
{ __(
'Read this document for details and how to keep tracking visits with Google Analytics',
'jetpack'
) }
</ExternalLink>
</SimpleNotice>
) }
</div>
);
}
Expand All @@ -268,6 +287,14 @@ export default connect(
hasConnectedOwner: hasConnectedOwner( state ),
siteAdminUrl: getSiteAdminUrl( state ),
startFreshEnabled: !! getModule( state, 'custom-css' )?.options?.replace,
showGoogleAnalyticsNotice:
isModuleActivated( state, 'google-analytics' ) &&
! isWoASite( state ) &&
! isFetchingPluginsData( state ) &&
! isPluginActive(
state,
'jetpack-legacy-google-analytics/jetpack-legacy-google-analytics.php'
),
};
},
dispatch => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.jp-settings-card__configure-link {
display: flex;
margin-bottom: 0;

&:last-child {
border-top: 1px solid var( --jp-gray );
}
Expand All @@ -44,6 +44,20 @@
border-top: 1px solid var( --jp-gray );
}

.dops-notice {
margin-bottom: 0;

&, .dops-notice__icon-wrapper {
border-radius: 0;
}

.dops-notice__text {
&, a {
color: var(--jp-white);
}
}
}

.dops-card.is-card-link + .jp-form-settings-group {
border-top: 1px solid var( --jp-gray );
}
Expand All @@ -54,7 +68,7 @@

&:hover {
box-shadow: none;

.dops-banner__title {
text-decoration: underline;
}
Expand Down
18 changes: 18 additions & 0 deletions projects/plugins/jetpack/_inc/client/traffic/google-analytics.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { getRedirectUrl } from '@automattic/jetpack-components';
import { ExternalLink } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { __, _x } from '@wordpress/i18n';
import Card from 'components/card';
import { withModuleSettingsFormHelpers } from 'components/module-settings/with-module-settings-form-helpers';
import SimpleNotice from 'components/notice';
import SettingsCard from 'components/settings-card';
import SettingsGroup from 'components/settings-group';
import analytics from 'lib/analytics';
Expand All @@ -23,6 +25,22 @@ export const GoogleAnalytics = withModuleSettingsFormHelpers(
feature={ FEATURE_GOOGLE_ANALYTICS_JETPACK }
hideButton
>
{ this.props.showDeprecationNotice && (
<SimpleNotice status="is-warning" showDismiss={ false }>
<div>
{ __(
"Jetpack's Google Analytics feature will be removed on August 6, 2024.",
'jetpack'
) }
</div>
<ExternalLink href={ getRedirectUrl( 'jetpack-support-google-analytics' ) }>
{ __(
'Read this document for details and how to keep tracking visits with Google Analytics',
'jetpack'
) }
</ExternalLink>
</SimpleNotice>
) }
<SettingsGroup
disableInOfflineMode
module={ { module: 'google-analytics' } }
Expand Down
27 changes: 24 additions & 3 deletions projects/plugins/jetpack/_inc/client/traffic/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,17 @@ import {
isUnavailableInOfflineMode,
hasConnectedOwner,
} from 'state/connection';
import { getLastPostUrl, currentThemeIsBlockTheme, getSiteId } from 'state/initial-state';
import { getModule, getModuleOverride } from 'state/modules';
import {
getLastPostUrl,
currentThemeIsBlockTheme,
getSiteId,
isWoASite,
} from 'state/initial-state';
import { getModule, getModuleOverride, isModuleActivated } from 'state/modules';
import { isModuleFound } from 'state/search';
import { getSettings } from 'state/settings';
import { siteUsesWpAdminInterface } from 'state/site';
import { isFetchingPluginsData, isPluginActive } from 'state/site/plugins';
import Blaze from './blaze';
import { GoogleAnalytics } from './google-analytics';
import { RelatedPosts } from './related-posts';
Expand Down Expand Up @@ -92,7 +98,18 @@ export class Traffic extends React.Component {
) }
{ foundStats && <SiteStats { ...commonProps } /> }
{ foundAnalytics && (
<GoogleAnalytics { ...commonProps } site={ this.props.blogID ?? this.props.siteRawUrl } />
<GoogleAnalytics
{ ...commonProps }
site={ this.props.blogID ?? this.props.siteRawUrl }
showDeprecationNotice={
this.props.isModuleActivated( 'google-analytics' ) &&
! this.props.isWoASite &&
! this.props.isFetchingPluginsData &&
! this.props.isPluginActive(
'jetpack-legacy-google-analytics/jetpack-legacy-google-analytics.php'
)
}
/>
) }
{ foundBlaze && <Blaze { ...commonProps } /> }
{ foundShortlinks && <Shortlinks { ...commonProps } /> }
Expand All @@ -111,7 +128,11 @@ export default connect( state => {
isOfflineMode: isOfflineMode( state ),
isUnavailableInOfflineMode: module_name => isUnavailableInOfflineMode( state, module_name ),
isModuleFound: module_name => isModuleFound( state, module_name ),
isModuleActivated: module_name => isModuleActivated( state, module_name ),
isSiteConnected: isSiteConnected( state ),
isFetchingPluginsData: isFetchingPluginsData( state ),
isPluginActive: plugin_name => isPluginActive( state, plugin_name ),
isWoASite: isWoASite( state ),
lastPostUrl: getLastPostUrl( state ),
getModuleOverride: module_name => getModuleOverride( state, module_name ),
hasConnectedOwner: hasConnectedOwner( state ),
Expand Down
17 changes: 17 additions & 0 deletions projects/plugins/jetpack/_inc/deprecate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
addEventListener( 'DOMContentLoaded', () => {
const notices = document.getElementsByClassName( 'jetpack-deprecate-dismissible' );
for ( let i = 0; i < notices.length; ++i ) {
if ( ! notices[ i ].hasAttribute( 'id' ) ) {
continue;
}

notices[ i ].addEventListener( 'click', event => {
if ( event.target.classList.contains( 'notice-dismiss' ) ) {
document.cookie =
'jetpack_deprecate_dismissed[' +
notices[ i ].getAttribute( 'id' ) +
']=1; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=None;';
}
} );
}
} );
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/add-ga-deprecation-notice
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Google Analytics: add deprecation notice for non-Jetpack admin pages."
3 changes: 3 additions & 0 deletions projects/plugins/jetpack/class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Automattic\Jetpack\Modules;
use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer;
use Automattic\Jetpack\Paths;
use Automattic\Jetpack\Plugin\Deprecate;
use Automattic\Jetpack\Plugin\Tracking as Plugin_Tracking;
use Automattic\Jetpack\Redirect;
use Automattic\Jetpack\Status;
Expand Down Expand Up @@ -861,6 +862,8 @@ function () {

// Add 5-star
add_filter( 'plugin_row_meta', array( $this, 'add_5_star_review_link' ), 10, 2 );

Deprecate::instance();
}

/**
Expand Down
Loading
Loading