Skip to content

Commit

Permalink
Help Center: fire event when requesting support (#97419)
Browse files Browse the repository at this point in the history
* Use selectedSite from storage

* Fire event when clicking on get support

* Remove unrelated code
  • Loading branch information
escapemanuele authored Dec 12, 2024
1 parent 3eac02c commit cbfccb0
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/odie-client/src/components/message/user-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,32 @@ export const UserMessage = ( {
const displayMessage =
isUserEligibleForPaidSupport && hasCannedResponse ? message.content : forwardMessage;

const handleContactSupportClick = () => {
trackEvent( 'chat_get_support', {
location: 'chat',
} );
};

const renderExtraContactOptions = () => {
const currentMessageIndex = chat.messages.findIndex(
( msg ) => msg.message_id === message.message_id
);
const isLastMessage = currentMessageIndex === chat.messages.length - 1;

return (
isLastMessage && ( shouldUseHelpCenterExperience ? <GetSupport /> : extraContactOptions )
isLastMessage &&
( shouldUseHelpCenterExperience ? (
<GetSupport onClickAdditionalEvent={ handleContactSupportClick } />
) : (
extraContactOptions
) )
);
};

const isMessageShowingDisclaimer =
message.context?.question_tags?.inquiry_type !== 'request-for-human-support';

const handleClick = () => {
const handleGuidelinesClick = () => {
trackEvent?.( 'ai_guidelines_link_clicked' );
};

Expand All @@ -78,8 +89,13 @@ export const UserMessage = ( {
__i18n_text_domain__
),
{
// @ts-expect-error Children must be passed to External link. This is done by createInterpolateElement, but the types don't see that.
a: <ExternalLink href="https://automattic.com/ai-guidelines" onClick={ handleClick } />,
a: (
// @ts-expect-error Children must be passed to External link. This is done by createInterpolateElement, but the types don't see that.
<ExternalLink
href="https://automattic.com/ai-guidelines"
onClick={ handleGuidelinesClick }
/>
),
}
) }
</div>
Expand Down

0 comments on commit cbfccb0

Please sign in to comment.