Skip to content

Commit

Permalink
Fetch all support articles from the same endpoint (#76734)
Browse files Browse the repository at this point in the history
* Hack Calypso help to pull all articles from the same endpoint

* checkpoint

* Linting

* Fix missing variables (need to keep siteIntent for later

* Revert unrelated change

* Revert more unrelated changes

* Remove disabled tests that were breaking the build

* Armwrestling the type system

* Revert unrelated changes

* Add more tracks events

* Remove more Sibyl parts

* Remove all trace of Sibyl for now

* Add more tracking, thumbs up/down, and button state tweaks

* Add external/internal icons to search results

* Add better styling, remove warnings, better type hints

* Remove unrelated changes

* Better (but not perfect) state handling

* Revert unnecessary changes

* Fix small formatting issue

* Set email subject/message from search query

* More informative error

* Make search result titles more consistent

* Fix naming of contact form tracks events

Co-authored-by: Omar Alshaker <omar@omaralshaker.com>

* Remove stray and incorrect comment

---------

Co-authored-by: Omar Alshaker <omar@omaralshaker.com>
  • Loading branch information
2 people authored and karenroldan committed May 18, 2023
1 parent 82f68a6 commit fce484f
Show file tree
Hide file tree
Showing 24 changed files with 423 additions and 2,314 deletions.
2 changes: 1 addition & 1 deletion client/blocks/inline-help/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@
flex-grow: 2;
}

.gridicon {
.gridicon, svg {
align-self: baseline;
color: var( --color-neutral-light );
flex-shrink: 0;
Expand Down
58 changes: 29 additions & 29 deletions client/me/help/help-contact-form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,33 @@ import { generateSubjectFromMessage } from './utils';

import './style.scss';

const trackSibylClick = ( event, helpLink ) =>
const trackArticleClick = ( event, helpLink ) =>
composeAnalytics(
bumpStat( 'sibyl_question_clicks', helpLink.id ),
recordTracksEventAction( 'calypso_sibyl_question_click', {
question_id: helpLink.id,
} )
);

const trackSibylFirstClick = ( event, helpLink ) =>
const trackArticleFirstClick = ( event, helpLink ) =>
composeAnalytics(
recordTracksEventAction( 'calypso_sibyl_first_question_click', {
question_id: helpLink.id,
} )
);

const trackSupportAfterSibylClick = () =>
const trackSupportAfterArticleClick = () =>
composeAnalytics( recordTracksEventAction( 'calypso_sibyl_support_after_question_click' ) );

const trackSupportWithSibylSuggestions = ( query, suggestions ) =>
const trackSupportWithArticleSuggestions = ( query, suggestions ) =>
composeAnalytics(
recordTracksEventAction( 'calypso_sibyl_support_with_suggestions_showing', {
query,
suggestions,
} )
);

const trackSupportWithoutSibylSuggestions = ( query ) =>
const trackSupportWithoutArticleSuggestions = ( query ) =>
composeAnalytics(
recordTracksEventAction( 'calypso_sibyl_support_without_suggestions_showing', { query } )
);
Expand Down Expand Up @@ -112,7 +112,7 @@ export class HelpContactForm extends PureComponent {
state = this.props.valueLink.value || {
message: '',
subject: '',
sibylClicked: false,
articleClicked: false,
userDeclaresNoSite: false,
userDeclaresUnableToSeeSite: this.props.siteCount === 0,
userDeclaredUrl: '',
Expand Down Expand Up @@ -151,7 +151,7 @@ export class HelpContactForm extends PureComponent {
} );
};

getSibylQuery = () => this.state.message.trim();
getArticleQuery = () => this.state.message.trim();

doRequestSite = () => {
if ( resemblesUrl( this.state.userDeclaredUrl ) ) {
Expand Down Expand Up @@ -183,7 +183,7 @@ export class HelpContactForm extends PureComponent {
requestSite = debounce( this.doRequestSite, 500 );

doQandASearch = () => {
const query = this.getSibylQuery();
const query = this.getArticleQuery();

if ( '' === query ) {
this.setState( { qanda: [] } );
Expand Down Expand Up @@ -214,23 +214,23 @@ export class HelpContactForm extends PureComponent {
}
this.setState( {
qanda: Array.isArray( qanda ) ? qanda : [],
// only keep sibylClicked true if the user is seeing the same set of questions
// only keep articleClicked true if the user is seeing the same set of questions
// we don't want to track "questions -> question click -> different questions -> support click",
// so we need to set sibylClicked to false here if the questions have changed
sibylClicked: this.state.sibylClicked && sameQuestionsReturned,
// so we need to set articleClicked to false here if the questions have changed
articleClicked: this.state.articleClicked && sameQuestionsReturned,
} );
} )
.catch( () => this.setState( { qanda: [], sibylClicked: false } ) );
.catch( () => this.setState( { qanda: [], articleClicked: false } ) );
};

debouncedQandA = debounce( this.doQandASearch, 500 );

trackSibylClick = ( event, helpLink ) => {
if ( ! this.state.sibylClicked ) {
this.props.trackSibylFirstClick( event, helpLink );
if ( ! this.state.articleClicked ) {
this.props.trackArticleFirstClick( event, helpLink );
}
this.props.trackSibylClick( event, helpLink );
this.setState( { sibylClicked: true } );
this.props.trackArticleClick( event, helpLink );
this.setState( { articleClicked: true } );
};

/**
Expand Down Expand Up @@ -319,17 +319,17 @@ export class HelpContactForm extends PureComponent {
} );
}

if ( this.state.sibylClicked ) {
if ( this.state.articleClicked ) {
// track that the user had clicked a Sibyl result, but still contacted support
this.props.trackSupportAfterSibylClick();
this.setState( { sibylClicked: false } );
this.props.trackSupportAfterArticleClick();
this.setState( { articleClicked: false } );
}

if ( this.state.qanda.length === 0 ) {
this.props.trackSupportWithoutSibylSuggestions( this.getSibylQuery() );
this.props.trackSupportWithoutArticleSuggestions( this.getArticleQuery() );
} else {
this.props.trackSupportWithSibylSuggestions(
this.getSibylQuery(),
this.props.trackSupportWithArticleSuggestions(
this.getArticleQuery(),
this.state.qanda.map( ( { id, title } ) => `${ id } - ${ title }` ).join( ' / ' )
);
}
Expand Down Expand Up @@ -474,7 +474,7 @@ export class HelpContactForm extends PureComponent {
</h2>
<InlineHelpCompactResults
helpLinks={ this.state.qanda }
onClick={ this.trackSibylClick }
onClick={ this.trackArticleClick }
/>
<FormButton disabled={ ! this.canSubmitForm() } type="button" onClick={ this.submitForm }>
{ buttonLabel }
Expand Down Expand Up @@ -628,7 +628,7 @@ export class HelpContactForm extends PureComponent {
header={ translate( 'Do you want the answer to any of these questions?' ) }
helpLinks={ this.state.qanda }
iconTypeDescription="book"
onClick={ this.trackSibylClick }
onClick={ this.trackArticleClick }
compact
/>
) }
Expand Down Expand Up @@ -675,11 +675,11 @@ const mapDispatchToProps = {
onChangeSite: selectSiteId,
recordTracksEventAction,
requestSite,
trackSibylClick,
trackSibylFirstClick,
trackSupportAfterSibylClick,
trackSupportWithSibylSuggestions,
trackSupportWithoutSibylSuggestions,
trackArticleClick,
trackArticleFirstClick,
trackSupportAfterArticleClick,
trackSupportWithArticleSuggestions,
trackSupportWithoutArticleSuggestions,
};

export default connect( mapStateToProps, mapDispatchToProps )( localize( HelpContactForm ) );
2 changes: 1 addition & 1 deletion packages/calypso-e2e/src/secrets/secrets-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class SecretsManager {
'This also may mean the typings for the secrets are stale and need updating.\n\n' +
'Details:\n' +
`\tInvalid or missing key: ${ fullKeyPath }\n` +
`\tExpected type: ${ typeof reference[ key ] }`
`\tExpected type: ${ typeof reference[ key ] }, got ${ typeof target[ key ] }`
);
}

Expand Down
Loading

0 comments on commit fce484f

Please sign in to comment.