You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If Analytics account creation is initiated from the Settings screen and an error occurs, the user should be returned to the Settings screen, with the error notice displayed and the account creation form repopulated with the relevant details.
This was raised in the bug bash, see this Asana task.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
When Analytics account creation is initiated from the settings edit screen and an error occurs, the user is returned to the settings edit screen.
The error notice is displayed and the account creation form is repopulated with the details of the account, property and data stream to create, as shown in the mock-up below.
All form controls behave as expected - clicking Create account retries account creation, the Back button returns the user to the form variant with the dropdown to select their existing account, etc.
This change is gated behind the setupFlowRefresh feature flag.
Implementation Brief
In includes/Modules/Analytics_4.php
Update Analytics_4::get_provisioning_callback_error_redirect_url() so that the setupFlowRefresh branch returns the admin URL for 'settings#/connected-services/analytics-4/edit' if $this->is_connected(), with the $error_code passed through as the accountCreationErrorCode param.
In assets/js/modules/analytics-4/components/common/AccountCreate/index.js
In assets/js/modules/analytics-4/components/common/AccountCreate/index.test.js.
Cover clicking Back on a settings URL removing accountCreationErrorCode and keeping the #connected-services/analytics-4/edit route. Seed a saved accountID, dispatch setAccountID( ACCOUNT_CREATE ), and seed one account summary so the Back button renders.
Cover the create account form and the error notice rendering when accountCreationErrorCode is in the URL, the setupFlowRefresh flag is on, and the saved accountID points at an existing account, with accountID becoming ACCOUNT_CREATE in the store.
Cover SettingsForm rendering when the flag is off, even with the error code present.
Cover SettingsForm rendering when there is no error code.
Cover clicking Back rendering SettingsForm again, with accountID back at the saved value, the error code removed from the URL, and the route/hash kept.
In assets/js/modules/analytics-4/components/common/AccountCreate/index.stories.js.
Add a settings-context account creation error story with accountCreationErrorCode set and no showProgress, following the existing initial setup flow error stories.
Render the story with VIEW_CONTEXT_SETTINGS and give it a Backstop scenario.
In tests/phpunit/integration/Modules/Analytics_4Test.php.
Add coverage for handle_provisioning_callback() that asserts the expected redirect to the settings page if setupFlowRefresh is enabled and the $this->is_connected() for both successes and failures. Assert that the redirect behaviour is unchanged if the module is not connected.
Update any failing VRT.
QA Brief
Setup
Enable the setupFlowRefresh feature flag.
Set up Site Kit with Analytics.
Go to Site Kit Settings -> Analytics -> edit and choose to set up a new Analytics account.
Triggering errors
The simplest way to trigger an error is to decline the Terms of Service on the Google Analytics ToS screen. This produces the user_cancel error and routes the user back to the Analytics setup screen.
Other error variants (max_accounts_reached, generic backend errors) can be simulated by manually appending the corresponding accountCreationErrorCode query parameter to the Analytics settings edit screen URL, e.g.:
Verify the error state on the Analytics settings edit screen
The Analytics settings edit screen is shown in Create Account mode.
The form is repopulated with the values you entered before clicking "Create Account" (account name, property name, data stream name, country, timezone, etc.).
The error notice is shown above the form, according to the attached mock in the issue description.
Clicking Retry triggers a fresh account creation attempt.
Clicking Go to Analytics (on the user_cancel variant) navigates back to the Terms of Service screen.
Changelog entry
Fix Analytics account creation errors to redirect back to the Settings screen when initiated from there.
Feature Description
If Analytics account creation is initiated from the Settings screen and an error occurs, the user should be returned to the Settings screen, with the error notice displayed and the account creation form repopulated with the relevant details.
This was raised in the bug bash, see this Asana task.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
setupFlowRefreshfeature flag.Implementation Brief
In
includes/Modules/Analytics_4.phpAnalytics_4::get_provisioning_callback_error_redirect_url()so that thesetupFlowRefreshbranch returns the admin URL for'settings#/connected-services/analytics-4/edit'if$this->is_connected(), with the$error_codepassed through as theaccountCreationErrorCodeparam.In
assets/js/modules/analytics-4/components/common/AccountCreate/index.jsviewContextto conditionally render depending on the screen.In
assets/js/modules/analytics-4/components/settings/SettingsEdit.jsgetQueryArg( location.href, 'accountCreationErrorCode' )on each render, the wayAccountCreatereads it. AuseQueryArgread stays stale after Fix Back button on the Analytics setup screen when an account creation error occurs #12875's Back handling removes the parameter from the URL.isCreateAccountfollowingSetupMain's check:setAccountID( ACCOUNT_CREATE )while the error code is present, the same effect Fix Back button on the Analytics setup screen when an account creation error occurs #12875 adds toSetupMain. The Back button'srollbackSettings()needs this client-side change to revert, or the screen never re-renders out of the error state.Test Coverage
In
assets/js/modules/analytics-4/components/common/AccountCreate/index.test.js.accountCreationErrorCodeand keeping the#connected-services/analytics-4/editroute. Seed a savedaccountID, dispatchsetAccountID( ACCOUNT_CREATE ), and seed one account summary so the Back button renders.Create
assets/js/modules/analytics-4/components/settings/SettingsEdit.test.tsx.accountCreationErrorCodeis in the URL, thesetupFlowRefreshflag is on, and the savedaccountIDpoints at an existing account, withaccountIDbecomingACCOUNT_CREATEin the store.SettingsFormrendering when the flag is off, even with the error code present.SettingsFormrendering when there is no error code.SettingsFormagain, withaccountIDback at the saved value, the error code removed from the URL, and the route/hash kept.In
assets/js/modules/analytics-4/components/common/AccountCreate/index.stories.js.accountCreationErrorCodeset and noshowProgress, following the existing initial setup flow error stories.VIEW_CONTEXT_SETTINGSand give it a Backstop scenario.In
tests/phpunit/integration/Modules/Analytics_4Test.php.handle_provisioning_callback()that asserts the expected redirect to the settings page ifsetupFlowRefreshis enabled and the$this->is_connected()for both successes and failures. Assert that the redirect behaviour is unchanged if the module is not connected.Update any failing VRT.
QA Brief
Setup
setupFlowRefreshfeature flag.Triggering errors
The simplest way to trigger an error is to decline the Terms of Service on the Google Analytics ToS screen. This produces the
user_cancelerror and routes the user back to the Analytics setup screen.Other error variants (
max_accounts_reached, generic backend errors) can be simulated by manually appending the correspondingaccountCreationErrorCodequery parameter to the Analytics settings edit screen URL, e.g.:Verify the error state on the Analytics settings edit screen
user_cancelvariant) navigates back to the Terms of Service screen.Changelog entry