Skip to content

Commit

Permalink
Merge pull request #4216 from DaleMcGrew/Dale_WebApp_Dec28-2024
Browse files Browse the repository at this point in the history
Moved convertToInteger into own utils file. Added updated TagManager.dataLayer code to JoinChallengeButton based on discussions in Analytics team meeting.
  • Loading branch information
DaleMcGrew authored Dec 29, 2024
2 parents 44f9907 + 106f179 commit e18e098
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
"react": "~17.0.2",
"react-bootstrap": "^1.6.4",
"react-confetti": "^6.1.0",
"react-copy-to-clipboard": "^5.0.3",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "~17.0.2",
"react-fullstory": "^1.4.0",
"react-ga4": "^2.1.0",
Expand Down
27 changes: 25 additions & 2 deletions src/js/common/components/Challenge/JoinChallengeButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,20 @@ class JoinChallengeButton extends React.Component {
const inviteFriendsPath = `${challengeBasePath}invite-friends`;
const { location: { pathname: currentPathname } } = window;
const { challengeWeVoteId } = this.state;
// console.log('goToInviteFriends currentPathname: ', currentPathname);

// Adding event data to dataLayer for Google Tag Manager to fire the inviteFriendsToChallenge tag
TagManager.dataLayer({
dataLayer: {
event: 'inviteFriendsToChallenge', //'inviteFriendsClick',
voterWeVoteId: VoterStore.getVoterWeVoteId(),
event: 'inviteFriendsToChallenge',
user: {
voterWeVoteId: VoterStore.getVoterWeVoteId(),
},
challengeWeVoteId,
pageDestination: 'joinChallenge',
pageType: 'challenge',
pageName: '', // Populate from URL pathname
pathName: currentPathname,
},
});

Expand All @@ -157,6 +164,22 @@ class JoinChallengeButton extends React.Component {
const { location: { pathname: currentPathname } } = window;
AppObservableStore.setSetUpAccountBackLinkPath(currentPathname);
AppObservableStore.setSetUpAccountEntryPath(joinChallengeNextStepPath);
// console.log('goToJoinChallenge currentPathname: ', currentPathname);
// Adding event data to dataLayer for Google Tag Manager to fire the inviteFriendsToChallenge tag
TagManager.dataLayer({
dataLayer: {
event: 'inviteFriendsToChallenge',
user: {
voterWeVoteId: VoterStore.getVoterWeVoteId(),
},
challengeWeVoteId,
pageDestination: 'goToInviteFriends',
pageType: 'challenge',
pageName: '', // Populate from URL pathname
pathName: currentPathname,
},
});

if (itemsAreMissing) {
historyPush(joinChallengeNextStepPath);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ const ChallengeParticipantSimpleListRoot = ({ challengeWeVoteId, classes, unique
};
}, [challengeWeVoteId]);

useEffect(() => {
console.log(participantList);
}, [participantList]);
// useEffect(() => {
// console.log('participantList from useEffect: ', participantList);
// }, [participantList]);
return (
<ChallengeParticipantListRootContainer>
<ChallengeParticipantList
Expand Down
2 changes: 1 addition & 1 deletion src/js/common/pages/Challenge/ChallengesHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getTodayAsInteger } from '../../utils/dateFormat';
import extractAttributeValueListFromObjectList from '../../utils/extractAttributeValueListFromObjectList';
import { isAndroid } from '../../utils/isCordovaOrWebApp';
import { renderLog } from '../../utils/logging';
import { convertToInteger } from '../../utils/textFormat';
import convertToInteger from '../../utils/convertToInteger';
import ChallengesHomeFilter from '../../components/Challenge/ChallengesHomeFilter';
import ChallengeListRootPlaceholder from '../../components/ChallengeListRoot/ChallengeListRootPlaceholder';
import NoSearchResult from '../../../components/Search/NoSearchResult';
Expand Down
3 changes: 3 additions & 0 deletions src/js/common/utils/convertToInteger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function convertToInteger (incomingNumber) {
return parseInt(incomingNumber, 10) || 0;
}
2 changes: 1 addition & 1 deletion src/js/common/utils/dateFormat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// dateFormat.js
import initializeMoment from './initializeMoment';
import { convertToInteger } from './textFormat';
import convertToInteger from './convertToInteger';

// eslint-disable-next-line consistent-return
export function formatDateToMonthDayYear (dateString) {
Expand Down
4 changes: 0 additions & 4 deletions src/js/common/utils/textFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export function cleanArray (actual) {
return newArray;
}

export function convertToInteger (incomingNumber) {
return parseInt(incomingNumber, 10) || 0;
}

export function extractTwitterHandleFromTextString (incomingString) {
if (!incomingString || incomingString === '') {
return '';
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Ballot/PositionDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import MeasureStore from '../../stores/MeasureStore';
import VoterGuideStore from '../../stores/VoterGuideStore';
import VoterStore from '../../stores/VoterStore';
import { cordovaDrawerTopMargin } from '../../utils/cordovaOffsets';
import { convertToInteger } from '../../common/utils/textFormat';
import convertToInteger from '../../common/utils/convertToInteger';

const DelayedLoad = React.lazy(() => import(/* webpackChunkName: 'DelayedLoad' */ '../../common/components/Widgets/DelayedLoad'));
const PositionItem = React.lazy(() => import(/* webpackChunkName: 'PositionItem' */ './PositionItem'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { formatDateToMonthDayYear } from '../../common/utils/dateFormat';
import { renderLog } from '../../common/utils/logging';
import normalizedImagePath from '../../common/utils/normalizedImagePath';
import BallotStore from '../../stores/BallotStore';
import { convertToInteger } from '../../common/utils/textFormat';
import convertToInteger from '../../common/utils/convertToInteger';
import HeaderLogoImage from '../Navigation/HeaderLogoImage';

const ImageHandler = React.lazy(() => import(/* webpackChunkName: 'ImageHandler' */ '../ImageHandler'));
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Share/SharedItemModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import OrganizationStore from '../../stores/OrganizationStore';
import VoterStore from '../../stores/VoterStore';
import { cordovaFooterHeight, cordovaNetworkNextButtonTop } from '../../utils/cordovaOffsets';
import { isSpeakerTypeOrganization, isSpeakerTypePublicFigure } from '../../utils/organization-functions';
import { convertToInteger } from '../../common/utils/textFormat';
import convertToInteger from '../../common/utils/convertToInteger';
import PersonalizedScoreIntroBody from '../CompleteYourProfile/PersonalizedScoreIntroBody';
import FriendToggle from '../Friends/FriendToggle';
import StepsChips from '../Widgets/StepsChips';
Expand Down
3 changes: 2 additions & 1 deletion src/js/components/Values/IssueCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { renderLog } from '../../common/utils/logging';
import IssueStore from '../../stores/IssueStore';
import VoterGuideStore from '../../stores/VoterGuideStore';
import VoterStore from '../../stores/VoterStore';
import { convertNameToSlug, convertToInteger } from '../../common/utils/textFormat';
import convertToInteger from '../../common/utils/convertToInteger';
import { convertNameToSlug } from '../../common/utils/textFormat';
import IssueFollowToggleButton from './IssueFollowToggleButton';
import IssueImageDisplay from './IssueImageDisplay';

Expand Down
2 changes: 1 addition & 1 deletion src/js/components/VoterGuide/OrganizationModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
DrawerHeaderInnerContainer, DrawerHeaderOuterContainer,
} from '../Style/drawerLayoutStyles';
import { cordovaDrawerTopMargin } from '../../utils/cordovaOffsets';
import { convertToInteger } from '../../common/utils/textFormat';
import convertToInteger from '../../common/utils/convertToInteger';
import { isCordova, isWebApp } from '../../common/utils/isCordovaOrWebApp';
import { headroomWrapperOffset } from '../../utils/cordovaCalculatedOffsets';
import { getPageKey } from '../../utils/cordovaPageUtils';
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Widgets/ItemActionBar/ItemActionBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import VoterActions from '../../../actions/VoterActions';
import DesignTokenColors from '../../../common/components/Style/DesignTokenColors';
import { openSnackbar } from '../../../common/components/Widgets/SnackNotifier';
import AppObservableStore from '../../../common/stores/AppObservableStore';
import convertToInteger from '../../../common/utils/convertToInteger';
import { isWebApp } from '../../../common/utils/isCordovaOrWebApp';
import isMobileScreenSize from '../../../common/utils/isMobileScreenSize';
import Cookies from '../../../common/utils/js-cookie/Cookies';
import { renderLog } from '../../../common/utils/logging';
import normalizedImagePath from '../../../common/utils/normalizedImagePath';
import stringContains from '../../../common/utils/stringContains';
import { convertToInteger } from '../../../common/utils/textFormat';
import webAppConfig from '../../../config';
import VoterConstants from '../../../constants/VoterConstants';
import SupportStore from '../../../stores/SupportStore';
Expand Down
2 changes: 1 addition & 1 deletion src/js/pages/Ballot/Candidate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import VoterGuideActions from '../../actions/VoterGuideActions';
import LoadingWheel from '../../common/components/Widgets/LoadingWheel';
import AppObservableStore, { messageService } from '../../common/stores/AppObservableStore';
import apiCalming from '../../common/utils/apiCalming';
import convertToInteger from '../../common/utils/convertToInteger';
import { isAndroidSizeWide } from '../../common/utils/cordovaUtils';
import historyPush from '../../common/utils/historyPush';
import { renderLog } from '../../common/utils/logging';
import { convertToInteger } from '../../common/utils/textFormat';
import toTitleCase from '../../common/utils/toTitleCase';
import CandidateStickyHeader from '../../components/Ballot/CandidateStickyHeader';
import LinkToAdminTools from '../../common/components/Widgets/LinkToAdminTools';
Expand Down
2 changes: 1 addition & 1 deletion src/js/pages/Campaigns/CampaignsHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import CampaignStore from '../../common/stores/CampaignStore';
import { convertStateCodeToStateText, convertStateTextToStateCode } from '../../common/utils/addressFunctions';
import apiCalming from '../../common/utils/apiCalming';
import arrayContains from '../../common/utils/arrayContains';
import convertToInteger from '../../common/utils/convertToInteger';
import { getTodayAsInteger } from '../../common/utils/dateFormat';
import extractAttributeValueListFromObjectList from '../../common/utils/extractAttributeValueListFromObjectList';
import historyPush from '../../common/utils/historyPush';
import { isAndroid } from '../../common/utils/isCordovaOrWebApp';
import { renderLog } from '../../common/utils/logging';
import { convertToInteger } from '../../common/utils/textFormat';
import CampaignsHomeFilter from '../../components/CampaignsHome/CampaignsHomeFilter';
import CandidateListRootPlaceholder from '../../components/CampaignsHome/CandidateListRootPlaceholder';
import NoSearchResult from '../../components/Search/NoSearchResult';
Expand Down
2 changes: 1 addition & 1 deletion src/js/stores/VoterGuideStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import SupportActions from '../actions/SupportActions';
import VoterGuideActions from '../actions/VoterGuideActions';
import Dispatcher from '../common/dispatcher/Dispatcher';
import apiCalming from '../common/utils/apiCalming';
import convertToInteger from '../common/utils/convertToInteger';
import { isSpeakerTypeOrganization, isSpeakerTypePublicFigure } from '../utils/organization-functions';
import { convertToInteger } from '../common/utils/textFormat';
import convertVoterGuideToElection from '../utils/voterGuideFunctions';
import OrganizationStore from './OrganizationStore'; // eslint-disable-line import/no-cycle
import VoterStore from './VoterStore'; // eslint-disable-line import/no-cycle
Expand Down

0 comments on commit e18e098

Please sign in to comment.