-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Help: Fix linter warnings and simplify logic around tracking the offline form event #1707
Conversation
cc @dllh |
12f0c63
to
531eab2
Compare
|
||
if ( ! details.isConversing ) { | ||
analytics.tracks.recordEvent( 'calypso_help_offline_form_display', { | ||
form_type: showKayakoVariation ? 'kayako' : 'forum' | ||
form_type: 'kayako' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I felt I should show my work here just so someone else could try and spot a mistake. Here's how I reduced it
showKayakoVariation = ! showChatVariation && ( details.isConversing || isUserEligible );
showKayakoVariation = ! ( isUserEligible && details.isOperatorAvailable ) && ( details.isConversing || isUserEligible ); // substitute showChatVariation for its actual value
showKayakoVariation = ! ( isUserEligible && false ) && ( details.isConversing || isUserEligible ); // We already know operators aren't available so lets replace details.isOperatorAvailable with false because we are in the onOperatorsAway callback
showKayakoVariation = ! ( false ) && ( details.isConversing || isUserEligible ); // simplify
showKayakoVariation = true && ( details.isConversing || isUserEligible ); // simplify
showKayakoVariation = ( details.isConversing || isUserEligible ); // simplify
showKayakoVariation = details.isConversing || isUserEligible; //simplify
showKayakoVariation = false || isUserEligible; // Our if statement above indicates that details.isConversing should be false so lets fill it in
showKayakoVariation = isUserEligible; // simplify
showKayakoVariation = true; // If a user is not eligible to start a chat and they aren't currently chatting then they'd
// never experience an "offline" contact form. In this case isUserEligible will always be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After staring at this long enough I realize that the "forum" case should theoretically never happen. If a user is not eligible to start a chat and they aren't currently chatting then they'd never experience an "offline" contact form. The form would always just be the "Ask in the forums" variation. This means that we can simplify showKayakoVariation further and just set it to true and this could just be form_type: 'kayako'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure this follows. What if we change what eligibility for chat means? For example, we have greater availability to offer chat to users with subscriptions right now, but when we have capacity to expand that, I think we'd have a case of users who are not currently eligible for chat who might be in the future. Or, to try to outline it since this is sort of confusing, a future scenario might look like this:
- A user who has no subscriptions loads the form.
- We have capacity to offer chat to that user.
- The user initiates a chat.
- Operators go away.
- We need to show an offline message.
Wouldn't we still need to record the forum event in this case?
We talked this over a bit in Slack and walked through the simplification together, and the logic seems valid to me. 🚢 |
Help: Fix linter warnings and simplify logic around tracking the offline form event
I saw some linter warnings after a rebase and then decided to fix them and try to simplify the logic here a bit.
How to test
Target a group where there is only one operator and make sure the operator is available. Also enable
calyspo:analytics
debuggingcalypso_help_offline_form_display
with a form_type of "kayako".What to expect
