Skip to content
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

Implement the secondary user variants of the "no audiences" banner. #8577

Closed
18 tasks
techanvil opened this issue Apr 17, 2024 · 19 comments
Closed
18 tasks

Implement the secondary user variants of the "no audiences" banner. #8577

techanvil opened this issue Apr 17, 2024 · 19 comments
Labels
Module: Analytics Google Analytics module related issues P1 Medium priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@techanvil
Copy link
Collaborator

techanvil commented Apr 17, 2024

Feature Description

Show the secondary user variants of the "no audiences" banner.

See secondary user setup > no audiences in the design doc.
See Changes during engineering, 6 Sept 2024 in the design doc.


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

Acceptance criteria

  • Given that a view-only user is on the dashboard, the Audience Segmentation feature has been set up by an authenticated user, and the secondary user setup (see Implement the secondary user setup #8130) has run for the view-only user:
    • If the view-only user has an empty audience selection:
    • If the view-only user has a populated audience selection, but none of their selected audiences are present in the list of available audiences:
      • The "no audiences" banner should be displayed with the following copy:
      • The select other groups link button should open the Selection Panel.
  • Given that an authenticated user is on the dashboard, the Audience Segmentation feature has already been set up by another user, and the secondary user setup has run for the current user:
    • If the current user has an empty audience selection, and has never had any audiences selected, the "no audiences" banner should be displayed in the following variant:
      • The variant should follow this Figma design with the following copy:
  • The banner variants should follow this Figma design, with different versions of the copy as specified above.
  • The second banner variant specced in Implement the “no audiences” banner happy path view #8155 should be removed, as the scenario where there are no audiences available to select is not expected to be reachable. This is because it's not possible to archive the "All Users" default audience, so there should always be at least one item in the list of available audiences.

Implementation Brief

  • In includes/Core/User/Audience_Settings.php, add a setting didSetAudiences and default it to false.
    • In merge method when the configuredAudiences is set to array with at least one audience in it and didSetAudiences is false, set didSetAudiences to true. The value of didSetAudiences should never change once it is set to true.
  • In assets/js/modules/analytics-4/components/audience-segmentation/dashboard/NoAudienceBannerWidget/NoAudienceBanner.js.
    • This component already has the examples for Analytics and Select other groups links.
    • Set isViewOnly from the useViewOnly() hook.
    • Set hasAudienceSelection using getConfiguredAudiences selector. true if getConfiguredAudiences().length > 0 else false.
    • Set hasAvailableAudiences using getAvailableAudiences selector. true if getAvailableAudiences().length > 0 else false.
    • If isViewOnly && ! hasAudienceSelection && ! hasAvailableAudiences, show the following variant:
      There are no visitor groups available. Learn more about how to group site visitors in Analytics.
      You can temporarily hide this feature until groups are available.
    • If isViewOnly && hasAudienceSelection:
      • If hasAvailableAudiences, show the following variant:
        It looks like your visitor groups aren’t available anymore. Select other groups.
      • If ! hasAvailableAudiences, show the following variant:
        There are no visitor groups available. Learn more about how to group site visitors in Analytics.
        You can temporarily hide this feature until groups are available.
    • If ! isViewOnly && ! hasAvailableAudiences && ! didSetAudiences, show the following variant:
      There are no visitor groups available. Learn more about how to group site visitors in Analytics.
      You can deactivate this widget in Settings.
  • Refer to existing banner variants in NoAudienceBanner for examples of the Analytics, Select other groups and Settings links.
  • The Temporarily hide link should use the dismiss item infrastructure to hide the banner, with an item key of audience-segmentation-no-audiences-banner. (Refer to the dismissItem action here).
  • When registering the widget area provide filterActiveWidgets() callback.
    • The callback should check if the banner is dismissed.
    • If available audiences are available, clear the dismissed item because we would show the banner.
    • If banner is dismissed and there are no available audiences, return an empty array to hide the widget area.

Test coverage

  • Update tests for NoAudienceBannerWidget with empty available audiences, available audiences and based on combination of values for didSetAudiences setting.

QA Brief

View-only user with an empty audience selection

  • Set up Site Kit with the audienceSegmentation feature flag enabled, and click on Enable groups to set the feature up.
  • In the Analytics UI, archive all of the audiences for the connected property barring "All Users", which can't be archived.
  • Refresh the page and open the Audience Selection Panel, this will trigger a resync of the available audiences.
  • Share Analytics via the Dashboard Sharing modal.
  • Login as an unauthenticated user who has view-only access to Analytics.
  • The banner should appear as per the AC.

View-only user with an populated audience selection

  • Set up Site Kit with the audienceSegmentation feature flag enabled, and click on Enable groups to set the feature up.
  • Share Analytics via the Dashboard Sharing modal.
  • Login as an unauthenticated user who has view-only access to Analytics and verify that they have an audience selection. You might want to do this in a separate/incognito browser window for convenience.
  • Archive all of the audiences for the connected property barring "All Users".
  • As the initial admin user, refresh the page and open the Audience Selection Panel to trigger a resync of the available audiences.
  • As the unauthenticated user, refresh the page. The banner should appear as per the AC.

Secondary admin who's never had audiences selected

  • Set up Site Kit with the audienceSegmentation feature flag enabled, and click on Enable groups to set the feature up.
  • Archive all of the audiences for the connected property barring "All Users".
  • Login as a second admin user and connect Site Kit. The second admin should have view access or higher for the connected property.
  • The banner should appear as per the AC.

Changelog entry

  • Implement the Audience Segmentation "no audiences" banner variants for secondary authenticated and shared dashboard users.
@techanvil techanvil added Module: Analytics Google Analytics module related issues P1 Medium priority Type: Enhancement Improvement of an existing feature labels Apr 17, 2024
@techanvil techanvil added the Team M Issues for Squad 2 label Apr 17, 2024
@kuasha420 kuasha420 self-assigned this Jul 10, 2024
@techanvil techanvil assigned techanvil and unassigned kuasha420 Jul 26, 2024
@techanvil
Copy link
Collaborator Author

Hey @kuasha420, just letting you know I've picked this one up to add the AC.

@techanvil techanvil assigned techanvil and unassigned techanvil Jul 26, 2024
@ankitrox ankitrox assigned ankitrox and unassigned ankitrox Aug 1, 2024
@techanvil techanvil self-assigned this Aug 2, 2024
@ivonac4 ivonac4 added the Next Up Issues to prioritize for definition label Aug 2, 2024
@techanvil
Copy link
Collaborator Author

Hi @ankitrox, thanks for drafting this IB.

However, while reading it I realise that the AC were a bit misleading, this is my mistake and I do apologise for the confusion.

The AC used phrases like "if the view-only user has not yet set up the feature", which I was using as a bit of a shorthand for having not fully set up the feature to the point of having an audience selection. I realise though it was a bit confusing because really, we do want the secondary user setup to have completed before determining which variant of the banner to display.

It looks like this has manifested in your IB where for example you specify checking for configuredAudiences to be null, which is a condition that should only be true before the secondary user setup has run.

I've modified the AC to be more clear on these points. Please can you take a look at the changes and update the IB accordingly?

@techanvil techanvil assigned ankitrox and unassigned techanvil Aug 2, 2024
@ankitrox ankitrox removed their assignment Aug 7, 2024
@techanvil techanvil self-assigned this Aug 7, 2024
@techanvil
Copy link
Collaborator Author

Hi @ankitrox, thanks for updating the IB. However, there are a few issues with it. One of which is the secondaryUserSetupRan flag, I know we discussed setting a flag in the secondary user setup, however the flag we need should be an indicator of whether the user has had a populated audience selection rather than simply whether the secondary setup has run. In fact, we should set this independently of the secondary user setup, and setting it can instead be encapsulated within Audience_Settings.

Furthermore, we don't need to bail out of the NoAudienceBanner if secondaryUserSetupRan is false because we still need to show the no audience banner variants for the primary admin. Anyhow as mentioned we don't actually need secondaryUserSetupRan and should create a different flag which we can name hasSeenAudience (or something along those lines).

Essentially the conditions for showing the specced banner variants should boil down to the following:

  • Add a new setting to Audience_Settings called hasSeenAudience. Set this to true the first time the configuredAudiences setting is populated with at least one audience.
  • In NoAudienceBanner:
    • Set isViewOnly from the useViewOnly() hook.
    • Set hasAudienceSelection = getConfiguredAudiences().length > 0.
    • Set hasAvailableAudiences = getAvailableAudiences().length > 0.
    • If isViewOnly && ! hasAudienceSelection && ! hasAvailableAudiences, show the following variant:
      • There are no visitor groups available. Learn more about how to group site visitors in Analytics.
        You can temporarily hide this feature until groups are available.
    • If isViewOnly && hasAudienceSelection:
      • If hasAvailableAudiences, show the following variant:
      • If ! hasAvailableAudiences, show the following variant:
        • It looks like your visitor groups aren’t available anymore. Learn more about how to group site visitors in Analytics.
          You can temporarily hide this feature until groups are available.
    • If ! isViewOnly && ! hasAvailableAudiences && ! hasSeenAudience, show the following variant:
      • There are no visitor groups available. Learn more about how to group site visitors in Analytics.
        You can temporarily hide this feature until groups are available.

Obviously, with the "temporarily hide" behaviour to be fleshed out.

One more thing, we try to avoid including code blocks in IBs, the IB should be a higher level description describing the approach to implementation rather than including blocks of code. Of course there are always exceptions to be made, but I don't think this case requires the code blocks.

Please can you update the IB again taking the above into account?

@techanvil techanvil assigned ankitrox and unassigned techanvil Aug 7, 2024
@ankitrox
Copy link
Collaborator

ankitrox commented Aug 8, 2024

Thank you @techanvil .

I've updated the IB. I kept the setting name as didSetAudiences as it sounds more relevant. Rest of the points updated as per your comment and AC conditions.

@ankitrox ankitrox assigned techanvil and unassigned ankitrox Aug 8, 2024
@ankitrox ankitrox removed their assignment Aug 14, 2024
@techanvil
Copy link
Collaborator Author

Thanks @ankitrox! That's looking good. Please note, I've added one point to the IB that was previously missed from this feedback point:

It would be worth mentioning that the existing banner variants in NoAudienceBanner have examples to follow for the Analytics and Select other groups links.

IB ✅

@techanvil techanvil assigned techanvil and unassigned techanvil Aug 14, 2024
@techanvil
Copy link
Collaborator Author

Hey @ankitrox, I realised there was another AC issue whereby the authenticated user variant was incorrectly specced to have the temporarily hide button, whereas in fact it should show a Settings link as per this version in Figma.

I've updated the AC and also restored the criteria for temporarily hidden audiences to remain hidden until an authenticated user has resynced the audiences. This will align this issue with forthcoming changes to remove the ability to sync audiences from view-only users. I've also tweaked the IB accordingly.

@techanvil techanvil removed their assignment Aug 15, 2024
@ivonac4 ivonac4 removed the Next Up Issues to prioritize for definition label Aug 21, 2024
@techanvil techanvil self-assigned this Aug 27, 2024
@techanvil
Copy link
Collaborator Author

Whooops, I picked this one up for execution without realising it's not in the current sprint.

I've hardly spent any time on it, will leave it assigned in the EB to continue but someone else can pick it up if needs be.

@techanvil
Copy link
Collaborator Author

While working on the execution for this issue, I realised that part of the AC as it stood didn't match up with the GA4 Audiences behaviour. The scenarios where the list of available audiences is empty are not expected to be reachable, due to the fact that the "All Users" default audience cannot be archived, so there will always be at least one audience which the user can select.

This is something that came up previously, as discussed here: #8155 (comment). At the time we decided to keep a minor edge case to support the unexpected scenario.

However, reviewing this again and re-verifying the Analytics behaviour w/re the "All Users" audience, it doesn't seem worth including support for this scenario which we cannot replicate through any expected behaviour. It would add unnecessary complexity to the code and to testing in various forms.

I have therefore amended the AC to remove the proposed banner variants for the "no available audience" scenarios, including the ability to temporarily hide the banner until audiences are available which is obviously no longer relevant.

There are still possible variants where the user has not previously had a populated audience selection and I've updated the copy for these as follows: You don't have any visitor groups selected. Select groups. This should suffice to move this issue forward, but I'll check in with @sigal-teller to get her thoughts on this copy amendment, if we want to change it we can in a small followup issue.

@techanvil
Copy link
Collaborator Author

Update: I've asked Sigal for her thoughts in a comment on Figma.

@techanvil techanvil removed their assignment Sep 6, 2024
@kuasha420 kuasha420 assigned kuasha420 and unassigned kuasha420 Sep 6, 2024
@kelvinballoo
Copy link
Collaborator

QA Update ⚠️

@techanvil , referring to the third section of the QAB:

Secondary admin who's never had audiences selected
   - Set up Site Kit with the audienceSegmentation feature flag enabled, and click on Enable groups to set the feature up.
   - Archive all of the audiences for the connected property barring "All Users".
   - Login as a second admin user and connect Site Kit.
   - The banner should appear as per the AC.
  • I followed the steps but at the last step, I get the 'Insufficient permissions' banner instead. ⚠️
  • Or I am thinking maybe the second admin should be granted access the analytics property for this testing? Can you confirm?

Video attached below for reference:

8577.scenario.3.720p.mov

Other than that, the first 2 scenarios were tested good:

  • View-only user with an empty audience selection

    8577.banner.ok.mov
  • View-only user with an populated audience selection

    8577.scenario.2.ok.480p.mov

@techanvil
Copy link
Collaborator Author

Hi @kelvinballoo, yes, sorry for not being more explicit but the second admin should indeed be able to see the connected property. I've updated the AC to make that clear.

@techanvil techanvil removed their assignment Sep 17, 2024
@kelvinballoo
Copy link
Collaborator

QA Update ⚠️

Thanks for confirming @techanvil

After granting the analytics property access, the correct banner is showing up as per below details ✅

Screenshot 2024-09-17 at 13 57 15
8577.-.AUthenticated.user.test.720p.mov
  • ⚠️ My only flag (and this is understandably out of scope for this task but worth raising if it's being tackled under another ticket or it needs one), is that when we click on 'Settings' to deactivate this widget, it brings up the 'Enable groups' button. By right, I would expect the toggle only at this point so that it can be turned on and off. You may refer to the 1m40 mark on the video above.

@techanvil
Copy link
Collaborator Author

Hi @kelvinballoo, thanks for spotting that. As you've surmised, it's out of scope for this issue, but is not addressed by another issue so please can you raise one for it?

@kelvinballoo
Copy link
Collaborator

QA Update ✅

Thanks @techanvil . New issue raised under #9366

The following scenarios were tested good:

  • View-only user with an empty audience selection
    Banner has the copy : You don't have any visitor groups selected. [Select groups]

    8577.banner.ok.mov
  • View-only user with an populated audience selection
    Banner has the copy : "It looks like your visitor groups aren’t available anymore. [Select other groups]"

    (Around 3 min mark)
    8577.scenario.2.ok.480p.mov
  • Secondary admin who's never had audiences selected
    Banner has the copy: "You don't have any visitor groups selected. [Select groups]. You can deactivate this widget in [Settings]"

    Screenshot 2024-09-17 at 13 57 15
    8577.-.AUthenticated.user.test.720p.mov
     </Details>
    

Moving ticket to approval.

@kelvinballoo kelvinballoo removed their assignment Sep 17, 2024
@techanvil
Copy link
Collaborator Author

Thanks @kelvinballoo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: Analytics Google Analytics module related issues P1 Medium priority Team M Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

6 participants