Skip to content
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

Merged
merged 1 commit into from
Dec 17, 2015

Conversation

omarjackman
Copy link
Contributor

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 debugging

  1. Navigate to http://calypso.localhost:3000/help/contact
  2. Notice the "Chat with us" variation of the contact form.
  3. Set the olark operator to away.
  4. You should notice that the form has changed to the "Submit support ticket" variation.
  5. Also notice in the javascript console that an event has been recorded for calypso_help_offline_form_display with a form_type of "kayako".

What to expect
screen shot 2015-12-16 at 6 18 00 pm

@omarjackman omarjackman added Live Chat [Feature Group] Support All things related to WordPress.com customer support. labels Dec 16, 2015
@omarjackman omarjackman self-assigned this Dec 16, 2015
@omarjackman omarjackman added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Dec 16, 2015
@omarjackman
Copy link
Contributor Author

cc @dllh

@omarjackman omarjackman force-pushed the update/fix-help-linter-warnings branch from 12f0c63 to 531eab2 Compare December 17, 2015 00:29

if ( ! details.isConversing ) {
analytics.tracks.recordEvent( 'calypso_help_offline_form_display', {
form_type: showKayakoVariation ? 'kayako' : 'forum'
form_type: 'kayako'
Copy link
Contributor Author

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.

Copy link
Contributor Author

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'.

Copy link
Member

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:

  1. A user who has no subscriptions loads the form.
  2. We have capacity to offer chat to that user.
  3. The user initiates a chat.
  4. Operators go away.
  5. We need to show an offline message.

Wouldn't we still need to record the forum event in this case?

@dllh
Copy link
Member

dllh commented Dec 17, 2015

We talked this over a bit in Slack and walked through the simplification together, and the logic seems valid to me. 🚢

@dllh dllh added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Dec 17, 2015
omarjackman added a commit that referenced this pull request Dec 17, 2015
Help: Fix linter warnings and simplify logic around tracking the offline form event
@omarjackman omarjackman merged commit 3cefe5c into master Dec 17, 2015
@omarjackman omarjackman deleted the update/fix-help-linter-warnings branch December 17, 2015 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Support All things related to WordPress.com customer support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants