site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

GTM and Analytics Create Account or Create New Container Buggy

Open bjackson27 opened this issue 7 years ago • 11 comments

Bug Description

  • When selecting 'Set up a new container' it doesn't actually create a new container but selects the first item in the list. I get an error for "User does not have sufficient permissions for this account", similar to Analytics' error message

  • I also got the following error message after saving which may have been specific to me, but thought I'd log it here. "Error: Quota exceeded for quota group 'default' and limit USER-100s of service tagmanager.googleapis.com for consumer project_number:495584684379."


Do not alter or remove anything below. The following sections will be managed by moderators only.

Changelog entry

  • Create a Tag Manager container if the user does not have one yet, normalize the container name, and display an error if container creation fails.

Acceptance criteria

  • As a first step, do the check for whether the user's accounts has necessary permissions to create a container.
  • If the account doesn't have permissions, display an informational message similar to what we do for Analytics in that case.
  • If the account does have permission to create a container, actually create a container instead of selecting the first item on the list.
  • If the same container name already exist, select that container and give a notice message back to the user.

Implementation Brief

  • Normalize the non-ASCII characters when setting the container name: https://github.com/google/site-kit-wp/blob/develop/includes/Modules/TagManager.php#L403
  • Check if the account has container(s):
    • If not, try to create a container from the server side, if succeed then finish setup
    • If account has container(s), show dropdown
  • When the same container name exist, TagManager service API will return error response. On Settings page, this error response is not displayed due to the way of the component is setup. The Confirm button is located outside the setup component and triggered with wp.hooks: https://github.com/google/site-kit-wp/blob/develop/assets/js/modules/tagmanager/setup.js#L69-L80

When the TagManagerSetup component received error response, it should throws error, so it would catch later by ModulePromise in this line: https://github.com/google/site-kit-wp/blob/9a262cd18c33995ce5ec81bc300ff055dff2a153/assets/js/components/settings/settings-modules.js#L109-L117

Then when re-create the setup component, set error message from props, so the setup component can show the error response.

bjackson27 avatar Jun 26 '19 13:06 bjackson27

@ivankristianto

So to fix it, it needs to add conditional in settings-modules.js handleButtonAction, to catch error and set it from props, so the setup component can show the error response.

Can you clarify this in more detail in how you plan to set the error on the TagmanagerSetup component using this technique?

It would be even better if this didn't use filters here. It's something we need to review as part of the JS refactoring.

felixarntz avatar Jul 09 '19 14:07 felixarntz

@felixarntz Me and Lucy find out that the components is always remounting (created and destroyed) on any user action on settings page. here is the ticket: https://github.com/google/site-kit-wp/issues/132

This will make the implementation more complex since, 1) the save button is outside the component and handled through filter. 2) it destroyed the component and create again.

The not so ideal solution to fix this with current architecture is, TagmanagerSetup pass the error message back to the parent component SettingsModules with props, and when recreating the component, pass back the error message back with props. Then in TagmanagerSetup handle the error message.

But if we are planning to refactor this later soon, I don't think this worth to pursuit. And I like to hear more feedback from you.

cc: @adamsilverstein @aaemnnosttv and @lucymtc

ivankristianto avatar Jul 10 '19 04:07 ivankristianto

Assigning to @felixarntz for feedback, per Ivan's last comment. Many thanks!

lilybonney avatar Jul 10 '19 11:07 lilybonney

@ivankristianto I reviewed this together with @swissspidy and we included a plan to address the problems in the current architecture in the JS refactoring.

So to summarize: The error is currently caught in the TagManager component. Wouldn't it be easier to throw an error from there? The SettingsModules component catches errors on the promise, so I assume it would catch this?

felixarntz avatar Jul 11 '19 09:07 felixarntz

@felixarntz Yes I think that would work. When it cached by the modulePromise here: https://github.com/google/site-kit-wp/blob/9a262cd18c33995ce5ec81bc300ff055dff2a153/assets/js/components/settings/settings-modules.js#L109-L117 The next step would be recreate that component and set error message via props. And ensure that component show the error message.

ivankristianto avatar Jul 12 '19 09:07 ivankristianto

@felixarntz - Ivan has updated the implementation brief based on the latest comments in the thread, and reassigned to you for review. Many thanks!

lilybonney avatar Jul 17 '19 10:07 lilybonney

Implementation brief looks good!

felixarntz avatar Jul 18 '19 11:07 felixarntz

@lucymtc Noticed two problems during QA:

  1. If I create a new container during module setup and a container with the name already exists, no feedback error message is shown. Also, the existing container with that name is not selected.
  2. If I have change the container in module settings and choose to create a new one, and a container with the name already exists, the feedback error message is shown, but it still shows the previously selected container (to reproduce, select a different container during setup that does not have the correct name).

In other words, this acceptance criteria is not met:

If the same container name already exist, select that container and give a notice message back to the user.

Selecting the correct container generally doesn't work, and the notice is only displayed in settings, but not in setup.

felixarntz avatar Jul 30 '19 11:07 felixarntz

@felixarntz @marrrmarrr first issue from comment https://github.com/google/site-kit-wp/issues/66#issuecomment-516374137 has a fix on this PR https://github.com/google/site-kit-wp/pull/354

Second issue is a bit trickier and there are also a couple of questions around it:

  • When the user selects from the settings page "Setup New Container", creating a new container is triggered after clicking on "Confirm Changes". If the container already exists, should we save the correct container in the settings instead of only preselecting it in the dropdown as user has confirmed the changes?

  • If user confirms the changes and we preselect (or save) the account in the dropdown, it isn't obvious the container in the dropdown has changed as the containers are shown by their publicID and not the name. Does it make sense to throw an error at this point or should we preselect/save the correct container warning the user we found an existing account with same name and saved it?

lucymtc avatar Jul 30 '19 19:07 lucymtc

Code review and QA on the fix for the aforementioned 1. is good!

@marrrmarrr I suggest we create a follow-up issue for the following acceptance criteria:

  • If a user chooses "Setup new container" and confirms, but then a container of that name already exists (there is already an error message displayed to indicate that), the existing container with this name should be selected.
  • The error message should be expanded to indicate that the existing container of that name has been selected (e.g. "We've preselected the existing container for you.").
  • This should be the case in both the module setup flow and the module settings panel.

That means we should adjust the one acceptance criteria on this issue here:

If the same container name already exist, ~~select that container and~~ give a notice message back to the user.

Does that work with you?

felixarntz avatar Jul 31 '19 07:07 felixarntz

SGTM @felixarntz let's follow up on the outstanding corner cases in a new issue

marrrmarrr avatar Jul 31 '19 08:07 marrrmarrr