@@ -9,22 +9,25 @@ import {Button} from 'sentry/components/core/button';
99import { DropdownMenu , type MenuItemProps } from 'sentry/components/dropdownMenu' ;
1010import OrganizationBadge from 'sentry/components/idBadge/organizationBadge' ;
1111import QuestionTooltip from 'sentry/components/questionTooltip' ;
12+ import { CUSTOM_REFERRER_KEY } from 'sentry/constants' ;
1213import { IconAdd } from 'sentry/icons' ;
1314import { t , tn } from 'sentry/locale' ;
1415import ConfigStore from 'sentry/stores/configStore' ;
1516import OrganizationsStore from 'sentry/stores/organizationsStore' ;
1617import { useLegacyStore } from 'sentry/stores/useLegacyStore' ;
1718import type { Organization } from 'sentry/types/organization' ;
1819import { isDemoModeActive } from 'sentry/utils/demoMode' ;
19- import localStorage from 'sentry/utils/localStorage' ;
2020import { localizeDomain , resolveRoute } from 'sentry/utils/resolveRoute' ;
2121import { useNavigate } from 'sentry/utils/useNavigate' ;
2222import useOrganization from 'sentry/utils/useOrganization' ;
2323import useProjects from 'sentry/utils/useProjects' ;
24+ import { useSessionStorage } from 'sentry/utils/useSessionStorage' ;
2425import { useNavContext } from 'sentry/views/nav/context' ;
2526import { NavLayout } from 'sentry/views/nav/types' ;
2627import { makeProjectsPathname } from 'sentry/views/projects/pathname' ;
2728
29+ const ORG_DROPDOWN_REFERRER = 'org-dropdown' ;
30+
2831function createOrganizationMenuItem ( ) : MenuItemProps {
2932 const configFeatures = ConfigStore . get ( 'features' ) ;
3033 const sentryUrl = localizeDomain ( ConfigStore . get ( 'links' ) . sentryUrl ) ;
@@ -64,6 +67,7 @@ export function OrgDropdown({
6467 const config = useLegacyStore ( ConfigStore ) ;
6568 const organization = useOrganization ( ) ;
6669 const navigate = useNavigate ( ) ;
70+ const [ , setReferrer ] = useSessionStorage < string | null > ( CUSTOM_REFERRER_KEY , null ) ;
6771
6872 // It's possible we do not have an org in context (e.g. RouteNotFound)
6973 // Otherwise, we should have the full org
@@ -148,7 +152,7 @@ export function OrgDropdown({
148152 key : 'projects' ,
149153 label : t ( 'Projects' ) ,
150154 onAction : ( ) => {
151- localStorage . setItem ( 'customReferrer' , 'org-dropdown' ) ;
155+ setReferrer ( ORG_DROPDOWN_REFERRER ) ;
152156 navigate ( makeProjectsPathname ( { path : '/' , organization} ) ) ;
153157 } ,
154158 hidden : hideOrgLinks ,
0 commit comments