Skip to content

[WV-1010] Added dataLayer code to Header items [FEEDBACK PROVIDED] #4337

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Zubin-glitch
Copy link
Contributor

What github.com/wevote/WebApp/issues does this fix?

Code fix for WV-1010

Changes included this pull request?

Added dataLayer code to handle Header item clicks.
I've removed switch case and utilized lookupPageNameAndPageDict.js functions to fetch pageName and pageType.
Created variables to store tabValues for ballot, candidates and challenges.

Copy link
Member

@DaleMcGrew DaleMcGrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Zubin-glitch thank you for this pull request. I've added my code review.

handleTabChange (newValue) {
handleTabChange (tabValue) {
// Get the tab info from the mapping
console.log('handleTabChange ', tabValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you make changes based on my comments in the pull request, and update this pull request with the [MERGE READY] title, please comment out all console.log lines you have added.

@@ -239,10 +243,60 @@ class HeaderBar extends Component {
if (this.setStyleTimeout) clearTimeout(this.setStyleTimeout);
}

handleTabChange (newValue) {
handleTabChange (tabValue) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer that you change the variable name of the incoming value to newTabValue over tabValue, since it clarifies that this is a new value we are switching to.

dataLayer: {
event: 'headerItemsClick',
userDetails: {
voterWeVoteId,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change these two lines to alphabetical order & directly assign values from VoterStore:

stateCode: VoterStore.getVoterStateCode(),
userCohort: VoterStore.getAnalyticsUserCohort(),
voterWeVoteId: VoterStore.getVoterWeVoteId(),

and remove const voterWeVoteId = and const stateCode = above since we don't need them in local variables.

pathname: destinationPathname,
},
},
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to include this at the end of this function:
this.setState({ tabsValue: newTabValue });

console.log('Source page object', currentPage);

// Map tabValue to destination pathname
const tabPathMappings = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabPathMappings will need to be built up in the render method, just above the:

    return (
      <HeaderBarWrapper

around line 583. You will then pass it into the function handleTabChange. These tab values are dynamic based on the hide/show tab options, like if (isCordova() || inPrivateLabelMode) and else if (voterIsSignedIn).

@@ -495,7 +558,18 @@ class HeaderBar extends Component {
howItWorksValue = 99;
// howItWorksVisible = false;
squadsValue = 4;
} else if (friendsVisible) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't update all the values based only on if friendsVisible is true.

@DaleMcGrew DaleMcGrew changed the title [TEAM REVIEW] Added dataLayer code to Header items [WV-1010] [FEEDBACK PROVIDED] Added dataLayer code to Header items [WV-1010] May 25, 2025
@DaleMcGrew DaleMcGrew changed the title [FEEDBACK PROVIDED] Added dataLayer code to Header items [WV-1010] [WV-1010] Added dataLayer code to Header items [FEEDBACK PROVIDED] May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants