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 Center: Support Experience to 50% of ALL users #97119

Merged
merged 8 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 3 additions & 1 deletion packages/help-center/src/components/help-center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { HELP_CENTER_STORE } from '../stores';
import { Container } from '../types';
import HelpCenterContainer from './help-center-container';
import HelpCenterSmooch from './help-center-smooch';
import { isUseHelpCenterExperienceEnabled } from './utils';
import type { HelpCenterSelect } from '@automattic/data-stores';
import '../styles.scss';

Expand Down Expand Up @@ -92,7 +93,8 @@ export default function ContextualizedHelpCenter(
props: Container & HelpCenterRequiredInformation
) {
const shouldUseHelpCenterExperience =
config.isEnabled( 'help-center-experience' ) || props.shouldUseHelpCenterExperience;
config.isEnabled( 'help-center-experience' ) ||
isUseHelpCenterExperienceEnabled( props.currentUser?.ID );

return (
<HelpCenterRequiredContextProvider value={ { ...props, shouldUseHelpCenterExperience } }>
Expand Down
7 changes: 7 additions & 0 deletions packages/help-center/src/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,10 @@ export const matchSupportInteractionId = (
return foundMatch;
}
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this way, but are we sure, we don't do anything in the backend?

I mean, this will enable the frontend, but are we using any different treatment in the backend?

Example, like users being assigned in the backend to use a different version (if so, we can do also in Calypso by adding a new version parameter in the sendMessage hook stating a different version when user is assigned to the experiment)

Secondly, this is not using a real A/B experiment, is just balancing users to be using either one experience or the other. Is that intended?

Copy link
Contributor Author

@escapemanuele escapemanuele Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Daniel!
This is not using an experiment! It simply shows it to 75% of users 👍

to use a different version

Yes, we already do this here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And thanks, I updated the description!

export const isUseHelpCenterExperienceEnabled = ( userId: number ): boolean => {
if ( ! userId || userId % 100 > 50 ) {
return false;
}
return true;
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import wpcomRequest, { canAccessWpcomApis } from 'wpcom-proxy-request';
*/
import type { APIFetchOptions, MessagingAuth, ZendeskAuthType } from './types';

/**
* Bump me when the API response structure goes through a breaking change.
*/
const VERSION = 'v1';

let isLoggedIn = false;

export function useAuthenticateZendeskMessaging(
Expand All @@ -21,7 +26,7 @@ export function useAuthenticateZendeskMessaging(
const isTestMode = currentEnvironment !== 'production';

return useQuery( {
queryKey: [ 'getMessagingAuth', type, isTestMode ],
queryKey: [ 'getMessagingAuth', VERSION, type, isTestMode ],
queryFn: () => {
const params = { type, test_mode: String( isTestMode ) };
const wpcomParams = new URLSearchParams( params );
Expand Down
Loading