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

View File

@ -18,5 +18,5 @@ export enum LOCALSTORAGE {
DASHBOARD_VARIABLES = 'DASHBOARD_VARIABLES',
SHOW_EXPLORER_TOOLBAR = 'SHOW_EXPLORER_TOOLBAR',
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);
set(LOCALSTORAGE.THEME, THEME_MODE.LIGHT);
}
set(LOCALSTORAGE.THEME_ANALYTICS, '');
set(LOCALSTORAGE.THEME_ANALYTICS_V1, '');
}, [theme]);
const value = useMemo(