-
Notifications
You must be signed in to change notification settings - Fork 293
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
Bug/6763 web data stream not available #6816
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
f135962
Add `isWebDataStreamNotAvailable` state, selector and action.
kuasha420 229781d
Update `syncGoogleTagSettings` action.
kuasha420 fd4a30e
Add `WebDataStreamNotAvailableNotification` component.
kuasha420 cf111fc
Add to BannerNotifications.
kuasha420 c91b2e2
Update `GA4SettingsControls` component.
kuasha420 e50f7e4
Fix typo missing commas thanks prettier.
kuasha420 2715399
Fix ErrorText usages.
kuasha420 bb7ca5c
Move the action above.
kuasha420 301bd16
Update `syncGoogleTagSettings` test.
kuasha420 50ecf97
Add tests for new selector and action.
kuasha420 93f3528
Add story for `WebDataStreamNotAvailableNotification`.
kuasha420 812fb85
Update `GA4SettingsControls`.
kuasha420 d6050bd
Merge branch 'main' into bug/6763-web-data-stream-not-available.
kuasha420 b07d938
Only show error messages if the field is not disabled and user has mo…
kuasha420 4141e46
Add VRT images for banner.
kuasha420 579c2b0
Fix flipper logic.
kuasha420 2060cbb
Merge branch 'develop' into bug/6763-web-data-stream-not-available.
kuasha420 4400235
Adding stories WIP.
kuasha420 73c3b6e
Fix PropertyNotAvailable and WebDataStreamNotAvailable and add scenar…
techanvil 962c1b9
Add scenario for the WithGA4Tag story that the previous commit also f…
techanvil 9445d00
Add VRT reference images.
techanvil c7e0e71
Merge branch 'develop' into bug/6763-web-data-stream-not-available.
kuasha420 c6dbad1
Fix import of `Grid`.
kuasha420 02d47d1
Add a comment explaining the dismissExpire value.
kuasha420 29a1737
Update copy with full stop.
kuasha420 4052338
Fix typo and capitalization in test.
kuasha420 f310cc1
Rename selector and related code.
kuasha420 294b259
Merge branch 'develop' into bug/6763-web-data-stream-not-available
kuasha420 0ce8421
Extract property and web data stream related error message to separat…
kuasha420 a0e5e9d
Fix tests.
kuasha420 d19d51a
Update VRT reference images.
kuasha420 46b7d4d
Remove unnecessary elseif.
kuasha420 47d7c6f
Revert unnecessary noise introduced while fixing merge conflict.
kuasha420 6217eab
Add tests for `PropertyOrWebDataStreamNotAvailableError`.
kuasha420 126f8b9
Check for `false` not `false`-y for the get properties selector error.
tofumatt c57a47e
Merge branch 'develop' into bug/6763-web-data-stream-not-available.
tofumatt 3ecfabd
Merge branch 'develop' into bug/6763-web-data-stream-not-available.
tofumatt 5203129
Reset the property ID when selecting a different account.
tofumatt 91a390f
Restore false-y checks for error.
tofumatt 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 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/notifications/WebDataStreamNotAvailableNotification.js
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,94 @@ | ||
/** | ||
* WebDataStreamNotAvailableNotification component. | ||
* | ||
* Site Kit by Google, Copyright 2023 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 { __, sprintf } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ProgressBar } from 'googlesitekit-components'; | ||
import Data from 'googlesitekit-data'; | ||
import BannerNotification from './BannerNotification'; | ||
import { MODULES_ANALYTICS_4 } from '../../modules/analytics-4/datastore/constants'; | ||
import { CORE_SITE } from '../../googlesitekit/datastore/site/constants'; | ||
import { getTimeInSeconds } from '../../util'; | ||
import { Cell, Grid, Row } from '../../material-components'; | ||
|
||
const { useSelect } = Data; | ||
|
||
export default function WebDataStreamNotAvailableNotification() { | ||
const isWebDataStreamAvailable = useSelect( ( select ) => | ||
select( MODULES_ANALYTICS_4 ).isWebDataStreamAvailable() | ||
); | ||
|
||
const measurementID = useSelect( ( select ) => | ||
select( MODULES_ANALYTICS_4 ).getMeasurementID() | ||
); | ||
|
||
const settingsURL = useSelect( ( select ) => | ||
select( CORE_SITE ).getAdminURL( 'googlesitekit-settings' ) | ||
); | ||
|
||
// If the data stream is available, we don't have to show a warning to the user. | ||
if ( isWebDataStreamAvailable ) { | ||
return null; | ||
} | ||
|
||
if ( measurementID === undefined ) { | ||
// Wrap in the googlesitekit-publisher-win class to ensure the output is treated in the same way as BannerNotification, | ||
// with only one instance visible on the screen at a time. | ||
return ( | ||
<div className="googlesitekit-publisher-win"> | ||
<Grid> | ||
<Row> | ||
<Cell size={ 12 }> | ||
<ProgressBar /> | ||
</Cell> | ||
</Row> | ||
</Grid> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<BannerNotification | ||
id="web-data-stream-not-available" | ||
title={ __( | ||
'Your Analytics 4 configuration has changed', | ||
'google-site-kit' | ||
) } | ||
description={ sprintf( | ||
/* translators: 1: Google Analytics 4 Measurement ID. */ | ||
__( | ||
'The previously selected web data stream with measurement ID %1$s is no longer available. Please select a new web data stream to continue collecting data with Google Analytics 4.', | ||
'google-site-kit' | ||
), | ||
measurementID | ||
) } | ||
ctaLink={ `${ settingsURL }#connected-services/analytics/edit` } | ||
ctaLabel={ __( 'Update Analytics settings', 'google-site-kit' ) } | ||
dismiss={ __( 'Maybe later', 'google-site-kit' ) } | ||
// This is arbitrarily set to 55 minutes to ensure that the notification | ||
// will become ready to be displayed again in an hour. | ||
dismissExpires={ getTimeInSeconds( 'minute' ) * 55 } | ||
/> | ||
); | ||
} |
77 changes: 77 additions & 0 deletions
77
assets/js/components/notifications/WebDataStreamNotAvailableNotification.stories.js
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,77 @@ | ||
/** | ||
* WebDataStreamNotAvailableNotification Component stories. | ||
* | ||
* Site Kit by Google, Copyright 2023 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. | ||
*/ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import WithRegistrySetup from '../../../../tests/js/WithRegistrySetup'; | ||
import { MODULES_ANALYTICS } from '../../modules/analytics/datastore/constants'; | ||
import { MODULES_ANALYTICS_4 } from '../../modules/analytics-4/datastore/constants'; | ||
import WebDataStreamNotAvailableNotification from './WebDataStreamNotAvailableNotification'; | ||
|
||
function Template( { ...args } ) { | ||
return <WebDataStreamNotAvailableNotification { ...args } />; | ||
} | ||
|
||
export const Loading = Template.bind( {} ); | ||
Loading.storyName = 'Loading'; | ||
|
||
export const Default = Template.bind( {} ); | ||
Default.storyName = 'Default'; | ||
Default.decorators = [ | ||
( Story ) => { | ||
const setupRegistry = ( registry ) => { | ||
registry | ||
.dispatch( MODULES_ANALYTICS_4 ) | ||
.setMeasurementID( 'G-2B7M8YQ1K6' ); | ||
}; | ||
|
||
return ( | ||
<WithRegistrySetup func={ setupRegistry }> | ||
<Story /> | ||
</WithRegistrySetup> | ||
); | ||
}, | ||
]; | ||
Default.scenario = { | ||
label: 'Global/WebDataStreamNotAvailableNotification/Default', | ||
}; | ||
|
||
export default { | ||
title: 'Components/WebDataStreamNotAvailableNotification', | ||
component: WebDataStreamNotAvailableNotification, | ||
decorators: [ | ||
( Story ) => { | ||
const setupRegistry = ( registry ) => { | ||
registry.dispatch( MODULES_ANALYTICS ).setSettings( {} ); | ||
|
||
registry | ||
.dispatch( MODULES_ANALYTICS_4 ) | ||
.setIsWebDataStreamAvailable( false ); | ||
|
||
registry.dispatch( MODULES_ANALYTICS_4 ).setSettings( {} ); | ||
}; | ||
|
||
return ( | ||
<WithRegistrySetup func={ setupRegistry }> | ||
<Story /> | ||
</WithRegistrySetup> | ||
); | ||
}, | ||
], | ||
}; |
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.
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.
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.
This order may need some thinking as it was not defined in AC/IB, but this made sense to me while implementing.
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.
This makes sense to me too, I think that's fine 👍🏻
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.
After further review, it seems okay since the code that triggers it only happens when syncing Google tag settings so while this seems off at first glance, it should be fine.