-
Notifications
You must be signed in to change notification settings - Fork 310
ACR Dashboard Subtle Notification #9612
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
Merged
eugene-manuilov
merged 45 commits into
develop
from
enhancement/9371-acr-dashboard-banner
Nov 25, 2024
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
e457584
Create base of ACR new key metrics banner.
benbowler 8f90e33
Sync with develop.
zutigrm b772a87
Update widget and notification components.
zutigrm 71e9e7a
Extract callbacks to a parent component.
zutigrm 0c012a8
Add useConversionReportingEventsForTailoredMetrics hook.
zutigrm f0faf4d
Add useConversionReportingEventsForTailoredMetrics tests.
zutigrm abbbd8a
Add ConversionReportingNotificationCTAWidget tests.
zutigrm 2056d01
Update link for ConversionReportingDashboardSubtleNotification.
zutigrm 951d8dd
Update user input saving to include includeConversionTailoredMetrics …
zutigrm 4d4ce8d
Update ACR KMW tailored metrics inclusion logic.
zutigrm eacb2e2
Add getKeyMetricsConversionEventWidgets to group ACR KMW under their …
zutigrm 61ffdd8
Include useConversionReportingEventsForTailoredMetrics in confirm modal.
zutigrm 52cdb6c
Update component name in import.
zutigrm 231e049
Add reducer callback.
zutigrm 22f34ce
Update styles.
zutigrm d4c6104
Update stories.
zutigrm 57ae99b
Add inline comment.
zutigrm cc5480e
Expand on tests.
zutigrm ba26855
Fix conflicts.
zutigrm 7211f98
Revert returned code.
zutigrm 49229b2
Fix tests.
zutigrm 32cf10d
Add VRT.
zutigrm f621be4
Add additional test.
zutigrm 0ec1298
Sync with develop and resolve merge conflicts.
zutigrm 0443cf6
Fix merge conflicts.
zutigrm dd8219d
Adapt logic to the latest change in develop for splitting the tailore…
zutigrm 92ab8f5
Adapt new logic to the confirm modal current vs new metrics preview.
zutigrm 5622dcd
Update banner display ocnditional to account for manual switch.
zutigrm 70f5808
Update logic for rendering and callback in CTAWidget.
zutigrm e230cff
Fix failing tests.
zutigrm e026f03
Fix line causing issues in stories and VRT.
zutigrm 7d7a9e4
Merge branch 'enhancement/9371-acr-dashboard-banner' of github.com:go…
10upsimon e4902a9
Fix console error.
zutigrm d28b510
Merge branch 'enhancement/9371-acr-dashboard-banner' of github.com:go…
10upsimon 49f5c26
Update VRT reference images following BackstopJS and Chromium updates.
10upsimon 4ea5b68
Revert "Update VRT reference images following BackstopJS and Chromium…
10upsimon 0f4c2a4
Update per CR feedback.
zutigrm dd3a7a1
Merge branch 'enhancement/9371-acr-dashboard-banner' of github.com:go…
zutigrm 7bf6a58
Resolve merge conflict.
zutigrm 8e5730f
Fix confirm disable modal story.
zutigrm ea1a5af
Update VRT.
zutigrm f3596a9
Update per CR feedback.
zutigrm 0ec1c45
Merge remote-tracking branch 'origin/develop' into enhancement/9371-a…
zutigrm dc2ee5b
Update per CR feedback.
zutigrm ce19904
Fix tests.
zutigrm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
94 changes: 94 additions & 0 deletions
94
assets/js/components/KeyMetrics/ConversionReportingDashboardSubtleNotification.js
This file contains hidden or 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,94 @@ | ||
/** | ||
* ConversionReportingDashboardSubtleNotification component. | ||
* | ||
* Site Kit by Google, Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { createInterpolateElement } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useSelect } from 'googlesitekit-data'; | ||
import { Button, SpinnerButton } from 'googlesitekit-components'; | ||
import StarFill from '../../../svg/icons/star-fill.svg'; | ||
import SubtleNotification from '../../googlesitekit/notifications/components/layout/SubtleNotification'; | ||
import { CORE_SITE } from '../../googlesitekit/datastore/site/constants'; | ||
import Link from '../Link'; | ||
|
||
export default function ConversionReportingDashboardSubtleNotification( { | ||
ctaLabel, | ||
handleCTAClick, | ||
isSaving = false, | ||
onDismiss, | ||
dismissCTALabel = __( 'Maybe later', 'google-site-kit' ), | ||
} ) { | ||
const documentationURL = useSelect( ( select ) => | ||
select( CORE_SITE ).getDocumentationLinkURL( 'key-metrics' ) | ||
); | ||
|
||
return ( | ||
<SubtleNotification | ||
className="googlesitekit-acr-subtle-notification" | ||
title={ __( 'New key metrics were added!', 'google-site-kit' ) } | ||
description={ createInterpolateElement( | ||
__( | ||
'We’ve extended your metrics selection with metrics that aren’t available by default in Analytics. Add them to your dashboard to get a better understanding of how users interact with your site. <a>Learn more</a>', | ||
'google-site-kit' | ||
), | ||
{ | ||
a: ( | ||
<Link | ||
href={ documentationURL } | ||
external | ||
aria-label={ __( | ||
'Learn more about advanced conversion reporting', | ||
'google-site-kit' | ||
) } | ||
/> | ||
), | ||
} | ||
) } | ||
dismissCTA={ | ||
<Button tertiary onClick={ onDismiss }> | ||
{ dismissCTALabel } | ||
</Button> | ||
} | ||
additionalCTA={ | ||
<SpinnerButton onClick={ handleCTAClick } isSaving={ isSaving }> | ||
{ ctaLabel } | ||
</SpinnerButton> | ||
} | ||
icon={ <StarFill width={ 24 } height={ 24 } /> } | ||
/> | ||
); | ||
} | ||
|
||
ConversionReportingDashboardSubtleNotification.propTypes = { | ||
ctaLabel: PropTypes.string.isRequired, | ||
handleCTAClick: PropTypes.func.isRequired, | ||
isSaving: PropTypes.bool, | ||
onDismiss: PropTypes.func.isRequired, | ||
dismissCTALabel: PropTypes.string, | ||
}; |
115 changes: 115 additions & 0 deletions
115
assets/js/components/KeyMetrics/ConversionReportingNotificationCTAWidget.js
This file contains hidden or 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,115 @@ | ||
/** | ||
* ConversionReportingNotificationCTAWidget component. | ||
* | ||
* Site Kit by Google, Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useCallback, useState } from '@wordpress/element'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { useSelect, useDispatch } from 'googlesitekit-data'; | ||
import { CORE_USER } from '../../googlesitekit/datastore/user/constants'; | ||
import whenActive from '../../util/when-active'; | ||
import ConversionReportingDashboardSubtleNotification from './ConversionReportingDashboardSubtleNotification'; | ||
import { MODULES_ANALYTICS_4 } from '../../modules/analytics-4/datastore/constants'; | ||
|
||
function ConversionReportingNotificationCTAWidget( { Widget, WidgetNull } ) { | ||
const [ isSaving, setIsSaving ] = useState( false ); | ||
const isUserInputCompleted = useSelect( ( select ) => | ||
select( CORE_USER ).isUserInputCompleted() | ||
); | ||
|
||
const keyMetricSettings = useSelect( ( select ) => | ||
select( CORE_USER ).getKeyMetricsSettings() | ||
); | ||
const hasUserPickedMetrics = useSelect( ( select ) => | ||
select( CORE_USER ).getUserPickedMetrics() | ||
); | ||
|
||
const haveConversionReportingEventsForTailoredMetrics = useSelect( | ||
( select ) => | ||
select( | ||
MODULES_ANALYTICS_4 | ||
).haveConversionEventsForTailoredMetrics() | ||
); | ||
|
||
// Initial callout is surfaced to the users with tailored metrics, if detectedEvents setting | ||
// has a conversion event associated with the ACR key metrics matching the current site purpose answer. | ||
// If new ACR key metrics that can be added are found using haveConversionReportingEventsForTailoredMetrics, | ||
// and have not been already included, which is determined by includeConversionTailoredMetrics setting, callout banner should be displayed. | ||
const shouldShowInitialCalloutForTailoredMetrics = | ||
! hasUserPickedMetrics?.length && | ||
isUserInputCompleted && | ||
haveConversionReportingEventsForTailoredMetrics && | ||
! keyMetricSettings?.includeConversionTailoredMetrics; | ||
|
||
const { setKeyMetricsSetting, saveKeyMetricsSettings } = | ||
useDispatch( CORE_USER ); | ||
const { dismissNewConversionReportingEvents } = | ||
useDispatch( MODULES_ANALYTICS_4 ); | ||
|
||
const handleAddMetricsClick = useCallback( () => { | ||
if ( shouldShowInitialCalloutForTailoredMetrics ) { | ||
setIsSaving( true ); | ||
setKeyMetricsSetting( 'includeConversionTailoredMetrics', true ); | ||
saveKeyMetricsSettings( { | ||
widgetSlugs: undefined, | ||
} ); | ||
setIsSaving( false ); | ||
} | ||
|
||
dismissNewConversionReportingEvents(); | ||
}, [ | ||
setKeyMetricsSetting, | ||
saveKeyMetricsSettings, | ||
dismissNewConversionReportingEvents, | ||
shouldShowInitialCalloutForTailoredMetrics, | ||
] ); | ||
|
||
if ( ! shouldShowInitialCalloutForTailoredMetrics ) { | ||
return <WidgetNull />; | ||
} | ||
|
||
return ( | ||
<Widget noPadding fullWidth> | ||
<ConversionReportingDashboardSubtleNotification | ||
ctaLabel={ __( 'Add metrics', 'google-site-kit' ) } | ||
handleCTAClick={ handleAddMetricsClick } | ||
isSaving={ isSaving } | ||
onDismiss={ dismissNewConversionReportingEvents } | ||
/> | ||
</Widget> | ||
); | ||
} | ||
|
||
ConversionReportingNotificationCTAWidget.propTypes = { | ||
Widget: PropTypes.elementType.isRequired, | ||
WidgetNull: PropTypes.elementType, | ||
}; | ||
|
||
export default whenActive( { moduleName: 'analytics-4' } )( | ||
ConversionReportingNotificationCTAWidget | ||
); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.