fix: theme analytics not getting reported as user is being fetched delayed (#5162)

This commit is contained in:
Vikrant Gupta 2024-06-06 17:04:00 +05:30 committed by GitHub
parent 35c054835a
commit c53e6de689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 16 deletions

View File

@ -178,9 +178,10 @@ function App(): JSX.Element {
}, [pathname]); }, [pathname]);
useEffect(() => { useEffect(() => {
if (user && user?.email && user?.userId && user?.name) {
try { try {
const isThemeAnalyticsSent = getLocalStorageApi( const isThemeAnalyticsSent = getLocalStorageApi(
LOCALSTORAGE.THEME_ANALYTICS, LOCALSTORAGE.THEME_ANALYTICS_V1,
); );
if (!isThemeAnalyticsSent) { if (!isThemeAnalyticsSent) {
trackEvent('Theme Analytics', { trackEvent('Theme Analytics', {
@ -188,13 +189,14 @@ function App(): JSX.Element {
user: pick(user, ['email', 'userId', 'name']), user: pick(user, ['email', 'userId', 'name']),
org, org,
}); });
setLocalStorageApi(LOCALSTORAGE.THEME_ANALYTICS, 'true'); setLocalStorageApi(LOCALSTORAGE.THEME_ANALYTICS_V1, 'true');
} }
} catch { } catch {
console.error('Failed to parse local storage theme analytics event'); console.error('Failed to parse local storage theme analytics event');
} }
}
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, [user]);
return ( return (
<ConfigProvider theme={themeConfig}> <ConfigProvider theme={themeConfig}>

View File

@ -18,5 +18,5 @@ export enum LOCALSTORAGE {
DASHBOARD_VARIABLES = 'DASHBOARD_VARIABLES', DASHBOARD_VARIABLES = 'DASHBOARD_VARIABLES',
SHOW_EXPLORER_TOOLBAR = 'SHOW_EXPLORER_TOOLBAR', SHOW_EXPLORER_TOOLBAR = 'SHOW_EXPLORER_TOOLBAR',
PINNED_ATTRIBUTES = 'PINNED_ATTRIBUTES', PINNED_ATTRIBUTES = 'PINNED_ATTRIBUTES',
THEME_ANALYTICS = 'THEME_ANALYTICS', THEME_ANALYTICS_V1 = 'THEME_ANALYTICS_V1',
} }

View File

@ -30,7 +30,7 @@ export function ThemeProvider({ children }: ThemeProviderProps): JSX.Element {
setTheme(THEME_MODE.LIGHT); setTheme(THEME_MODE.LIGHT);
set(LOCALSTORAGE.THEME, THEME_MODE.LIGHT); set(LOCALSTORAGE.THEME, THEME_MODE.LIGHT);
} }
set(LOCALSTORAGE.THEME_ANALYTICS, ''); set(LOCALSTORAGE.THEME_ANALYTICS_V1, '');
}, [theme]); }, [theme]);
const value = useMemo( const value = useMemo(