Guard calls to componentDidMount with a check for existence.

Fix tag on username step.
This commit is contained in:
picklesrus 2019-11-05 18:17:37 -05:00
parent 30967a3056
commit c77db39062
7 changed files with 19 additions and 7 deletions

View file

@ -55,7 +55,9 @@ class BirthDateStep extends React.Component {
]);
}
componentDidMount () {
this.props.sendAnalytics('join-birthdate');
if (this.props.sendAnalytics) {
this.props.sendAnalytics('join-birthdate');
}
}
validateSelect (selection) {

View file

@ -23,7 +23,9 @@ class CountryStep extends React.Component {
this.countryOptions = [];
}
componentDidMount () {
this.props.sendAnalytics('join-country');
if (this.props.sendAnalytics) {
this.props.sendAnalytics('join-country');
}
this.setCountryOptions();
}
setCountryOptions () {

View file

@ -35,7 +35,9 @@ class EmailStep extends React.Component {
this.emailRemoteCache = {};
}
componentDidMount () {
this.props.sendAnalytics('join-email');
if (this.props.sendAnalytics) {
this.props.sendAnalytics('join-email');
}
// automatically start with focus on username field
if (this.emailInput) this.emailInput.focus();

View file

@ -62,7 +62,9 @@ class GenderStep extends React.Component {
]);
}
componentDidMount () {
this.props.sendAnalytics('join-gender');
if (this.props.sendAnalytics) {
this.props.sendAnalytics('join-gender');
}
}
handleSetCustomRef (customInputRef) {
this.customInput = customInputRef;

View file

@ -16,7 +16,9 @@ class RegistrationErrorStep extends React.Component {
]);
}
componentDidMount () {
this.props.sendAnalytics('join-error');
if (this.props.sendAnalytics) {
this.props.sendAnalytics('join-error');
}
}
handleSubmit (e) {
// JoinFlowStep includes a <form> that handles a submit action.

View file

@ -40,7 +40,9 @@ class UsernameStep extends React.Component {
// Send info to analytics when we aren't on the standalone page.
// If we are on the standalone join page, the page load will take care of this.
if (!window.location.pathname.includes('/join')) {
this.props.sendAnalytics('join-email');
if (this.props.sendAnalytics) {
this.props.sendAnalytics('join-username-modal');
}
}
// automatically start with focus on username field

View file

@ -80,7 +80,7 @@ describe('UsernameStep test', () => {
<UsernameStep
sendAnalytics={sendAnalyticsFn}
/>);
expect(sendAnalyticsFn).toHaveBeenCalledWith('join-email');
expect(sendAnalyticsFn).toHaveBeenCalledWith('join-username-modal');
});
test('handleValidSubmit passes formData to next step', () => {