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

chore: cleanup shortcuts experiment #3742

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

Conversation

nensidosari
Copy link
Contributor

@nensidosari nensidosari commented Oct 31, 2024

Original PR from @nensidosari , now mantained by @ilasw

Changes

Summary

  • Cleanup experiment;
  • Refactor Shortcuts (split in multiple files);
  • Add isOldUser case and hide GetStarted component for them;
  • Updated tests
  • Small fixes

Description

Initially this task was about removing the experiment but due to the bad performance of the Get started banner for already existing users (registered before experiment) we added a rule that remove this step for them.

Basically this should be every possible option:

  • Old user (registered before experiment)
    • have never used/disabled shortcuts -> see the "add shortcuts" button
    • have disabled shortcuts -> see the "add shortcuts" button
    • have enabled shortcuts
      • if there are custom links -> show them
      • if empty -> show placeholder
  • New user
    • have never used/disabled shortcuts -> see the get started banner
    • have disabled shortcuts -> see the "add shortcuts" button
    • have enabled shortcuts
      • if there are custom links -> show them
      • if empty -> show placeholder

Screens

No action made Disabled shortcuts Shortcut empty Shortcut with links
New user image image image image
Old user image image image image

Old user check is IF registrationDate < 2024-07-16 date since experiment was launched.

Events

Did you introduce any new tracking events?

Experiment

Did you introduce any new experiments?

Manual Testing

Caution

Please make sure existing components are not breaking/affected by this PR

Preview domain

https://chore-shortcuts-ui.preview.app.daily.dev

Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
daily-webapp ✅ Ready (Inspect) Visit Preview Nov 21, 2024 4:29pm
1 Skipped Deployment
Name Status Preview Updated (UTC)
storybook ⬜️ Ignored (Inspect) Nov 21, 2024 4:29pm

@ilasw ilasw changed the title Chore shortcuts UI chore: cleanup shortcuts experiment Nov 20, 2024
Comment on lines -40 to -69
type ShortcutLinksControlProps = {
className?: string;
onLinkClick: () => void;
onOptionsOpen: () => void;
shortcutLinks: string[];
};

function ShortcutLinksUIControl(props: ShortcutLinksControlProps) {
const { shortcutLinks, onLinkClick, onOptionsOpen, className } = props;
return (
<>
{shortcutLinks?.length ? (
<CustomLinks
links={shortcutLinks}
className={className}
onOptions={onOptionsOpen}
onLinkClick={onLinkClick}
/>
) : (
<Button
className={className}
variant={ButtonVariant.Tertiary}
icon={<PlusIcon />}
iconPosition={ButtonIconPosition.Right}
onClick={onOptionsOpen}
>
Add shortcuts
</Button>
)}
</>
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing experiment

Comment on lines +134 to +153
{!hideShortcuts &&
(showGetStarted ? (
<ShortcutGetStarted
onTopSitesClick={toggleShowTopSites}
onCustomLinksClick={onOptionsOpen}
/>
) : (
<ShortcutLinksList
{...{
onLinkClick,
onMenuClick,
onOptionsOpen,
shortcutLinks,
shouldUseListFeedLayout,
showTopSites,
toggleShowTopSites,
hasCheckedPermission,
}}
/>
))}
Copy link
Contributor

Choose a reason for hiding this comment

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

hideShortcuts checks if shortcuts are visible

showGetStarted check if !isOldUser && hasNoShortcuts, basically old users will never see the get started banner even if they don't have any shortcuts atm

Comment on lines -1 to -5
import React, {
MouseEventHandler,
PropsWithChildren,
ReactElement,
} from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Removed this component and created new ones for clarity:

  • list
  • item
  • get started

Comment on lines 60 to 63
const { isOldUser, showToggleShortcuts } = useShortcutsUser();

const hasNoShortcuts = !shortcutLinks?.length && showTopSites;
const showGetStarted = !isOldUser && hasNoShortcuts;
Copy link
Contributor

Choose a reason for hiding this comment

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

New logic, check if is old user then hide get started if it is.

Comment on lines 104 to 111
useEffect(() => {
if (gb && experimentation?.features) {
const currentFeats = gb.getFeatures();
const currentFeats = gb.getFeatures?.();
// Do not update when the features are already set
if (!currentFeats || !Object.keys(currentFeats).length) {
gb.setFeatures(experimentation.features);
gb.setFeatures?.(experimentation.features);
setReady(true);
}
Copy link
Contributor

@ilasw ilasw Nov 21, 2024

Choose a reason for hiding this comment

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

Added optional chaining because this made Storybook crash, should not impact prod but saved me a lot of refactoring in sb.

Comment on lines 16 to 38
export const useShortcutsUser = () => {
const { user, isAuthReady } = useAuthContext();
const { checkHasCompleted, isActionsFetched } = useActions();
const isExtension = checkIsExtension();
const { showTopSites } = useSettingsContext();

const isOldUser =
isAuthReady &&
user?.createdAt &&
new Date(user.createdAt) < DATE_TO_SHOW_SHORTCUTS;
const hasCompletedFirstSession =
isActionsFetched && checkHasCompleted(ActionType.FirstShortcutsSession);
const isOldUserWithNoShortcuts = isOldUser && !hasCompletedFirstSession;

return {
isOldUser,
isOldUserWithNoShortcuts,
hasCompletedFirstSession,
showToggleShortcuts:
isExtension && (!showTopSites || isOldUserWithNoShortcuts),
hideInitialBanner: isOldUserWithNoShortcuts,
};
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a common hook between shared and extension, used for not duplicate checks.

@idoshamun
Copy link
Member

idoshamun commented Nov 21, 2024

@ilasw does new user have the "shortcuts" button as well? or do you introduce it now?

i mean the button they see when they disable the extension

@ilasw
Copy link
Contributor

ilasw commented Nov 21, 2024

@ilasw does new user have the "shortcuts" button as well? or do you introduce it now?

i mean the button they see when they disable the extension

@idoshamun yes if I correctly understand this button is visible inside the description's table (I know the preview is very small...). Are you referring to this button, right?

image image

@idoshamun
Copy link
Member

I'm referring to this button indeed, just asking if they currently see it or if we introduce it as part of this pr?

@ilasw
Copy link
Contributor

ilasw commented Nov 21, 2024

I'm referring to this button indeed, just asking if they currently see it or if we introduce it as part of this pr?

@idoshamun I've checked with a non-updated extension and seems nothing have changed for new users ✔️

Copy link
Member

@idoshamun idoshamun left a comment

Choose a reason for hiding this comment

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

I didn't review the code, but explanation and business logic makes sense to me. Please wait for an actual review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants