Skip to content

Commit

Permalink
Revert "Help Center: Set the Support Experience experiment (#96549)"
Browse files Browse the repository at this point in the history
This reverts commit e186873.
  • Loading branch information
escapemanuele authored Nov 27, 2024
1 parent e186873 commit be98b75
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,18 @@ import { HelpCenter } from '@automattic/data-stores';
import { useDispatch } from '@wordpress/data';
import { useCallback } from 'react';
import AsyncLoad from 'calypso/components/async-load';
import { useExperiment } from 'calypso/lib/explat';

const HELP_CENTER_STORE = HelpCenter.register();

const AsyncHelpCenter = () => {
const { setShowHelpCenter } = useDispatch( HELP_CENTER_STORE );
const [ isLoading, experimentAssignment ] = useExperiment(
'calypso_helpcenter_new_support_flow'
);

const handleClose = useCallback( () => {
setShowHelpCenter( false );
}, [ setShowHelpCenter ] );

return (
<AsyncLoad
require="@automattic/help-center"
placeholder={ null }
handleClose={ handleClose }
shouldUseHelpCenterExperience={
! isLoading && experimentAssignment?.variationName === 'treatment'
}
/>
<AsyncLoad require="@automattic/help-center" placeholder={ null } handleClose={ handleClose } />
);
};

Expand Down
7 changes: 0 additions & 7 deletions client/layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import EmptyMasterbar from 'calypso/layout/masterbar/empty';
import MasterbarLoggedIn from 'calypso/layout/masterbar/logged-in';
import OfflineStatus from 'calypso/layout/offline-status';
import isA8CForAgencies from 'calypso/lib/a8c-for-agencies/is-a8c-for-agencies';
import { useExperiment } from 'calypso/lib/explat';
import { getGoogleMailServiceFamily } from 'calypso/lib/gsuite';
import isJetpackCloud from 'calypso/lib/jetpack/is-jetpack-cloud';
import { isWcMobileApp, isWpMobileApp } from 'calypso/lib/mobile-app';
Expand Down Expand Up @@ -150,9 +149,6 @@ function HelpCenterLoader( { sectionName, loadHelpCenter, currentRoute } ) {
const selectedSite = useSelector( getSelectedSite );
const primarySiteSlug = useSelector( getPrimarySiteSlug );
const primarySite = useSelector( ( state ) => getSiteBySlug( state, primarySiteSlug ) );
const [ isLoading, experimentAssignment ] = useExperiment(
'calypso_helpcenter_new_support_flow'
);

if ( ! loadHelpCenter ) {
return null;
Expand All @@ -173,9 +169,6 @@ function HelpCenterLoader( { sectionName, loadHelpCenter, currentRoute } ) {
hidden={ sectionName === 'gutenberg-editor' && isDesktop }
onboardingUrl={ onboardingUrl() }
googleMailServiceFamily={ getGoogleMailServiceFamily() }
shouldUseHelpCenterExperience={
! isLoading && experimentAssignment?.variationName === 'treatment'
}
/>
);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/help-center/src/components/help-center-chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* External Dependencies
*/
import { recordTracksEvent } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import OdieAssistantProvider, { OdieAssistant } from '@automattic/odie-client';
import { useEffect } from '@wordpress/element';
import { useNavigate, useParams } from 'react-router-dom';
Expand All @@ -23,8 +24,7 @@ export function HelpCenterChat( {
const navigate = useNavigate();
const shouldUseWapuu = useShouldUseWapuu();
const preventOdieAccess = ! shouldUseWapuu && ! isUserEligibleForPaidSupport;
const { currentUser, site, shouldUseHelpCenterExperience, canConnectToZendesk } =
useHelpCenterContext();
const { currentUser, site, canConnectToZendesk } = useHelpCenterContext();
const { id: conversationId = null } = useParams();

useEffect( () => {
Expand All @@ -37,11 +37,11 @@ export function HelpCenterChat( {
}
}, [] );

const odieVersion = shouldUseHelpCenterExperience ? '14.0.3' : null;
const odieVersion = config.isEnabled( 'help-center-experience' ) ? '14.0.3' : null;

return (
<OdieAssistantProvider
shouldUseHelpCenterExperience={ shouldUseHelpCenterExperience }
shouldUseHelpCenterExperience={ config.isEnabled( 'help-center-experience' ) }
currentUser={ currentUser }
canConnectToZendesk={ canConnectToZendesk }
selectedSiteId={ site?.ID as number }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* External Dependencies
*/
import { recordTracksEvent } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import { getPlan } from '@automattic/calypso-products';
import { Spinner, GMClosureNotice } from '@automattic/components';
import { HelpCenterSite } from '@automattic/data-stores';
Expand Down Expand Up @@ -241,7 +242,7 @@ const HelpCenterFooterButton = ( {
};

export const HelpCenterContactButton: FC = () => {
const { shouldUseHelpCenterExperience } = useHelpCenterContext();
const shouldUseHelpCenterExperience = config.isEnabled( 'help-center-experience' );
const { canConnectToZendesk } = useHelpCenterContext();
const { __ } = useI18n();
const { data: supportInteractionsResolved } = useGetSupportInteractions(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { recordTracksEvent } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import { getPlan } from '@automattic/calypso-products';
import { HelpCenterSite } from '@automattic/data-stores';
import { GetSupport } from '@automattic/odie-client/src/components/message/get-support';
Expand Down Expand Up @@ -35,7 +36,9 @@ const HelpCenterFeedbackForm = ( {

const { data } = useSupportStatus();
const isUserEligibleForPaidSupport = data?.eligibility.is_user_eligible ?? false;
const { sectionName, site, shouldUseHelpCenterExperience } = useHelpCenterContext();

const { sectionName, site } = useHelpCenterContext();
const shouldUseHelpCenterExperience = config.isEnabled( 'help-center-experience' );
const navigate = useNavigate();
const productSlug = ( site as HelpCenterSite )?.plan?.product_slug;
const plan = getPlan( productSlug );
Expand Down
10 changes: 4 additions & 6 deletions packages/help-center/src/components/help-center-header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable no-restricted-imports */
import config from '@automattic/calypso-config';
import { Gridicon } from '@automattic/components';
import { EllipsisMenu } from '@automattic/odie-client';
import { useManageSupportInteraction } from '@automattic/odie-client/src/data';
Expand All @@ -11,7 +12,6 @@ import { useI18n } from '@wordpress/react-i18n';
import clsx from 'clsx';
import { Route, Routes, useLocation, useSearchParams } from 'react-router-dom';
import { v4 as uuidv4 } from 'uuid';
import { useHelpCenterContext } from '../contexts/HelpCenterContext';
import { usePostByUrl } from '../hooks';
import { useResetSupportInteraction } from '../hooks/use-reset-support-interaction';
import { DragIcon } from '../icons';
Expand Down Expand Up @@ -106,7 +106,7 @@ const HeaderText = () => {
};
}, [] );

const { shouldUseHelpCenterExperience } = useHelpCenterContext();
const shouldUseHelpCenterExperience = config.isEnabled( 'help-center-experience' );

useEffect( () => {
if ( currentSupportInteraction ) {
Expand Down Expand Up @@ -156,8 +156,7 @@ const Content = ( { onMinimize }: { onMinimize?: () => void } ) => {
const { __ } = useI18n();
const { pathname } = useLocation();

const { shouldUseHelpCenterExperience } = useHelpCenterContext();

const shouldUseHelpCenterExperience = config.isEnabled( 'help-center-experience' );
const shouldDisplayClearChatButton =
shouldUseHelpCenterExperience && pathname.startsWith( '/odie' );
const isHelpCenterHome = pathname === '/';
Expand Down Expand Up @@ -191,7 +190,6 @@ const ContentMinimized = ( {
const { __ } = useI18n();
const formattedUnreadCount = unreadCount > 9 ? '9+' : unreadCount;

const { shouldUseHelpCenterExperience } = useHelpCenterContext();
return (
<>
<p
Expand All @@ -214,7 +212,7 @@ const ContentMinimized = ( {
<Route
path="/odie"
element={
shouldUseHelpCenterExperience
config.isEnabled( 'help-center-experience' )
? __( 'Support Assistant', __i18n_text_domain__ )
: __( 'Wapuu', __i18n_text_domain__ )
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable no-restricted-imports */
import { recordTracksEvent } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import page from '@automattic/calypso-router';
import { Gridicon } from '@automattic/components';
import {
Expand Down Expand Up @@ -189,7 +190,7 @@ function HelpSearchResults( {
currentRoute,
}: HelpSearchResultsProps ) {
const { hasPurchases, sectionName, site } = useHelpCenterContext();
const { shouldUseHelpCenterExperience } = useHelpCenterContext();
const shouldDisplayRecentConversations = config.isEnabled( 'help-center-experience' );

const adminResults = useAdminResults( searchQuery );

Expand Down Expand Up @@ -357,7 +358,7 @@ function HelpSearchResults( {
</p>
) : null }

{ shouldUseHelpCenterExperience && <HelpCenterRecentConversations /> }
{ shouldDisplayRecentConversations && <HelpCenterRecentConversations /> }
{ sections }
</div>
);
Expand Down
3 changes: 1 addition & 2 deletions packages/help-center/src/components/help-center-smooch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ const HelpCenterSmooch: React.FC = () => {
const { isMessagingScriptLoaded } = useLoadZendeskMessaging(
'zendesk_support_chat_key',
isHelpCenterShown && isEligibleForChat,
isEligibleForChat,
true
isEligibleForChat
);
const { setIsChatLoaded, setUnreadCount, setZendeskClientId } =
useDataStoreDispatch( HELP_CENTER_STORE );
Expand Down
9 changes: 3 additions & 6 deletions packages/help-center/src/components/help-center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const HelpCenter: React.FC< Container > = ( {
handleClose,
hidden,
currentRoute = window.location.pathname + window.location.search,
shouldUseHelpCenterExperience,
} ) => {
const portalParent = useRef( document.createElement( 'div' ) ).current;
const shouldUseHelpCenterExperience = config.isEnabled( 'help-center-experience' );

const { isHelpCenterShown, isMinimized } = useSelect( ( select ) => {
const helpCenterSelect: HelpCenterSelect = select( HELP_CENTER_STORE );
Expand Down Expand Up @@ -82,12 +82,9 @@ const HelpCenter: React.FC< Container > = ( {
export default function ContextualizedHelpCenter(
props: Container & HelpCenterRequiredInformation
) {
const shouldUseHelpCenterExperience =
config.isEnabled( 'help-center-experience' ) || props.shouldUseHelpCenterExperience;

return (
<HelpCenterRequiredContextProvider value={ { ...props, shouldUseHelpCenterExperience } }>
<HelpCenter { ...props } shouldUseHelpCenterExperience={ shouldUseHelpCenterExperience } />
<HelpCenterRequiredContextProvider value={ props }>
<HelpCenter { ...props } />
</HelpCenterRequiredContextProvider>
);
}
2 changes: 0 additions & 2 deletions packages/help-center/src/contexts/HelpCenterContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export type HelpCenterRequiredInformation = {
googleMailServiceFamily: string;
onboardingUrl: string;
canConnectToZendesk: boolean;
shouldUseHelpCenterExperience?: boolean;
};

const HelpCenterRequiredContext = createContext< HelpCenterRequiredInformation >( {
Expand All @@ -36,7 +35,6 @@ const HelpCenterRequiredContext = createContext< HelpCenterRequiredInformation >
googleMailServiceFamily: '',
onboardingUrl: '',
canConnectToZendesk: false,
shouldUseHelpCenterExperience: false,
} );

export const HelpCenterRequiredContextProvider: React.FC< {
Expand Down
1 change: 0 additions & 1 deletion packages/help-center/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface Container {
hidden?: boolean;
currentRoute?: string;
openingCoordinates?: ReturnType< typeof useOpeningCoordinates >;
shouldUseHelpCenterExperience?: boolean;
}

export interface PostObject {
Expand Down
6 changes: 3 additions & 3 deletions packages/odie-client/src/context/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { recordTracksEvent } from '@automattic/calypso-analytics';
import config from '@automattic/calypso-config';
import { useResetSupportInteraction } from '@automattic/help-center/src/hooks/use-reset-support-interaction';
import { HELP_CENTER_STORE } from '@automattic/help-center/src/stores';
import { useSelect } from '@wordpress/data';
Expand Down Expand Up @@ -69,7 +70,6 @@ export const OdieAssistantProvider: React.FC< OdieAssistantProviderProps > = ( {
version = null,
currentUser,
children,
shouldUseHelpCenterExperience,
} ) => {
const { botNameSlug, isMinimized, isChatLoaded } = useSelect( ( select ) => {
const store = select( HELP_CENTER_STORE ) as HelpCenterSelect;
Expand All @@ -91,7 +91,7 @@ export const OdieAssistantProvider: React.FC< OdieAssistantProviderProps > = ( {
*/
const { mainChatState, setMainChatState } = useGetCombinedChat(
canConnectToZendesk,
shouldUseHelpCenterExperience
config.isEnabled( 'help-center-experience' )
);

/**
Expand Down Expand Up @@ -188,7 +188,7 @@ export const OdieAssistantProvider: React.FC< OdieAssistantProviderProps > = ( {
setChatStatus,
setMessageLikedStatus,
setWaitAnswerToFirstMessageFromHumanSupport,
shouldUseHelpCenterExperience: shouldUseHelpCenterExperience ?? false,
shouldUseHelpCenterExperience: config.isEnabled( 'help-center-experience' ),
trackEvent,
version: overriddenVersion,
waitAnswerToFirstMessageFromHumanSupport,
Expand Down
5 changes: 2 additions & 3 deletions packages/zendesk-client/src/use-load-zendesk-messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import type { ZendeskConfigName } from './types';
export function useLoadZendeskMessaging(
keyConfigName: ZendeskConfigName,
enabled = true,
tryAuthenticating = true,
shouldUseHelpCenterExperience = false
tryAuthenticating = true
) {
const [ isMessagingScriptLoaded, setMessagingScriptLoaded ] = useState( false );
const zendeskKey: string = config( keyConfigName );
const { data: authData } = useAuthenticateZendeskMessaging(
isMessagingScriptLoaded && tryAuthenticating,
shouldUseHelpCenterExperience ? 'messenger' : 'zendesk'
config.isEnabled( 'help-center-experience' ) ? 'messenger' : 'zendesk'
);
useEffect( () => {
if ( ! enabled || isMessagingScriptLoaded ) {
Expand Down

0 comments on commit be98b75

Please sign in to comment.