From 99bbb16d2b294fe7f92583608ee4fae9a63bc5dd Mon Sep 17 00:00:00 2001 From: "Daryl L. L. Houston" Date: Tue, 15 Dec 2015 11:58:56 -0500 Subject: [PATCH] Help: Begin recording a few stats pertaining to the help section. This commit also incidentally fixes up a couple of things that didn't pass linter tests. --- client/me/help/controller.js | 18 +++++++++++++----- client/me/help/help-contact/index.jsx | 18 ++++++++++++++++++ client/me/help/help-search/index.jsx | 8 +++++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/client/me/help/controller.js b/client/me/help/controller.js index b6b73d5b3e2d8a..9c1840f270aaef 100644 --- a/client/me/help/controller.js +++ b/client/me/help/controller.js @@ -7,23 +7,31 @@ var ReactDom = require( 'react-dom' ), /** * Internal dependencies */ -var i18n = require( 'lib/mixins/i18n' ), +var analytics = require( 'analytics' ), + i18n = require( 'lib/mixins/i18n' ), + route = require( 'lib/route' ), titleActions = require( 'lib/screen-title/actions' ); module.exports = { - help: function() { - var Help = require( './main' ); + help: function( context ) { + var Help = require( './main' ), + basePath = route.sectionify( context.path ); titleActions.setTitle( i18n.translate( 'Help', { textOnly: true } ) ); + analytics.pageView.record( basePath, 'Help' ); + ReactDom.render( React.createElement( Help ), document.getElementById( 'primary' ) ); }, - contact: function() { - var ContactComponent = require( './help-contact' ); + contact: function( context ) { + var ContactComponent = require( './help-contact' ), + basePath = route.sectionify( context.path ); + + analytics.pageView.record( basePath, 'Help > Contact' ); ReactDom.render( , diff --git a/client/me/help/help-contact/index.jsx b/client/me/help/help-contact/index.jsx index 823555fa65b226..5b2fd27cf386da 100644 --- a/client/me/help/help-contact/index.jsx +++ b/client/me/help/help-contact/index.jsx @@ -19,6 +19,7 @@ import HeaderCake from 'components/header-cake'; import wpcomLib from 'lib/wp'; import notices from 'notices'; import siteList from 'lib/sites-list'; +import analytics from 'analytics'; /** * Module variables @@ -96,6 +97,8 @@ module.exports = React.createClass( { notifications.forEach( olarkActions.sendNotificationToOperator ); + analytics.tracks.recordEvent( 'calypso_help_live_chat_begin' ); + this.sendMessageToOperator( message ); }, @@ -130,6 +133,9 @@ module.exports = React.createClass( { 'one of our Happiness Engineers shortly.' ) } } ); + + analytics.tracks.recordEvent( 'calypso_help_contact_submit', { ticket_type: 'kayako' } ); + } ); }, @@ -162,6 +168,8 @@ module.exports = React.createClass( { ) } } ); + + analytics.tracks.recordEvent( 'calypso_help_contact_submit', { ticket_type: 'forum' } ); } ); }, @@ -203,6 +211,16 @@ module.exports = React.createClass( { }, onOperatorsAway: function() { + const { isOlarkReady, isUserEligible, details } = this.state.olark; + const showChatVariation = isUserEligible && details.isOperatorAvailable; + const showKayakoVariation = ! showChatVariation && ( details.isConversing || isUserEligible ); + const showForumsVariation = ! ( showChatVariation || showKayakoVariation ); + + if ( ! details.isConversing ) { + analytics.tracks.recordEvent( 'calypso_help_offline_form_display', { + form_type: showKayakoVariation ? 'kayako' : 'forum' + } ); + } this.showOperatorAvailabilityNotice( false ); }, diff --git a/client/me/help/help-search/index.jsx b/client/me/help/help-search/index.jsx index a6c1cef1f5fecb..320211d67ad378 100644 --- a/client/me/help/help-search/index.jsx +++ b/client/me/help/help-search/index.jsx @@ -13,6 +13,7 @@ import HelpResults from 'me/help/help-results'; import NoResults from 'my-sites/no-results'; import SearchCard from 'components/search-card'; import CompactCard from 'components/card/compact'; +import analytics from 'analytics'; module.exports = React.createClass( { displayName: 'HelpSearch', @@ -40,6 +41,7 @@ module.exports = React.createClass( { onSearch: function( searchQuery ) { this.setState( { helpLinks: [], searchQuery: searchQuery } ); + analytics.tracks.recordEvent( 'calypso_help_search', { query: searchQuery } ); HelpSearchActions.fetch( searchQuery ); }, @@ -78,19 +80,19 @@ module.exports = React.createClass( {