From c77db390623792adb5cff78a1656109611cae3a6 Mon Sep 17 00:00:00 2001 From: picklesrus Date: Tue, 5 Nov 2019 18:17:37 -0500 Subject: [PATCH] Guard calls to componentDidMount with a check for existence. Fix tag on username step. --- src/components/join-flow/birthdate-step.jsx | 4 +++- src/components/join-flow/country-step.jsx | 4 +++- src/components/join-flow/email-step.jsx | 4 +++- src/components/join-flow/gender-step.jsx | 4 +++- src/components/join-flow/registration-error-step.jsx | 4 +++- src/components/join-flow/username-step.jsx | 4 +++- test/unit/components/username-step.test.jsx | 2 +- 7 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/join-flow/birthdate-step.jsx b/src/components/join-flow/birthdate-step.jsx index ae0920805..6b6a7209f 100644 --- a/src/components/join-flow/birthdate-step.jsx +++ b/src/components/join-flow/birthdate-step.jsx @@ -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) { diff --git a/src/components/join-flow/country-step.jsx b/src/components/join-flow/country-step.jsx index a95b97536..5ef3f1647 100644 --- a/src/components/join-flow/country-step.jsx +++ b/src/components/join-flow/country-step.jsx @@ -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 () { diff --git a/src/components/join-flow/email-step.jsx b/src/components/join-flow/email-step.jsx index 26cc90297..20845e1cb 100644 --- a/src/components/join-flow/email-step.jsx +++ b/src/components/join-flow/email-step.jsx @@ -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(); diff --git a/src/components/join-flow/gender-step.jsx b/src/components/join-flow/gender-step.jsx index 053034139..30089899d 100644 --- a/src/components/join-flow/gender-step.jsx +++ b/src/components/join-flow/gender-step.jsx @@ -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; diff --git a/src/components/join-flow/registration-error-step.jsx b/src/components/join-flow/registration-error-step.jsx index 160ec1241..d7eb5618c 100644 --- a/src/components/join-flow/registration-error-step.jsx +++ b/src/components/join-flow/registration-error-step.jsx @@ -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
that handles a submit action. diff --git a/src/components/join-flow/username-step.jsx b/src/components/join-flow/username-step.jsx index 5405678bd..ed6c23c13 100644 --- a/src/components/join-flow/username-step.jsx +++ b/src/components/join-flow/username-step.jsx @@ -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 diff --git a/test/unit/components/username-step.test.jsx b/test/unit/components/username-step.test.jsx index 08129ecc7..56e34588d 100644 --- a/test/unit/components/username-step.test.jsx +++ b/test/unit/components/username-step.test.jsx @@ -80,7 +80,7 @@ describe('UsernameStep test', () => { ); - expect(sendAnalyticsFn).toHaveBeenCalledWith('join-email'); + expect(sendAnalyticsFn).toHaveBeenCalledWith('join-username-modal'); }); test('handleValidSubmit passes formData to next step', () => {