-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Google Analytics: display deprecation notices (#38078)
Display Google Analytics deprecation notice on non-Jetpack admin pages.
- Loading branch information
1 parent
affec6d
commit 925c58d
Showing
33 changed files
with
392 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...s/packages/my-jetpack/_inc/hooks/use-notification-watcher/use-deprecate-feature-notice.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
4 changes: 4 additions & 0 deletions
4
projects/packages/my-jetpack/changelog/add-ga-deprecation-notice
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: added | ||
|
||
Add the Google Analytics deprecation notice. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Updated composer.lock. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: changed | ||
Comment: Updated composer.lock. | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;'; | ||
} | ||
} ); | ||
} | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.