mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 18:36:08 +00:00
parent
54808a027e
commit
2c430d1c7e
@ -20,4 +20,6 @@ declare module '@analytics/session-utils' {
|
||||
extra = {},
|
||||
extend?: boolean
|
||||
) => Session;
|
||||
|
||||
export const removeSession: () => void;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { removeSession } from '@analytics/session-utils';
|
||||
import { Auth0Provider } from '@auth0/auth0-react';
|
||||
import { Configuration } from '@azure/msal-browser';
|
||||
import { MsalProvider } from '@azure/msal-react';
|
||||
@ -64,6 +65,7 @@ import {
|
||||
getUserDataFromOidc,
|
||||
matchUserDetails,
|
||||
} from '../../utils/UserDataUtils';
|
||||
import { resetWebAnalyticSession } from '../../utils/WebAnalyticsUtils';
|
||||
import Auth0Authenticator from '../authenticators/Auth0Authenticator';
|
||||
import BasicAuthAuthenticator from '../authenticators/basic-auth.authenticator';
|
||||
import MsalAuthenticator from '../authenticators/MsalAuthenticator';
|
||||
@ -113,11 +115,16 @@ export const AuthProvider = ({
|
||||
const onLoginHandler = () => {
|
||||
setLoading(true);
|
||||
authenticatorRef.current?.invokeLogin();
|
||||
|
||||
resetWebAnalyticSession();
|
||||
};
|
||||
|
||||
const onLogoutHandler = useCallback(() => {
|
||||
clearTimeout(timeoutId);
|
||||
authenticatorRef.current?.invokeLogout();
|
||||
|
||||
// remove analytics session on logout
|
||||
removeSession();
|
||||
setLoading(false);
|
||||
}, [timeoutId]);
|
||||
|
||||
|
@ -37,6 +37,7 @@ import {
|
||||
showInfoToast,
|
||||
showSuccessToast,
|
||||
} from '../../utils/ToastUtils';
|
||||
import { resetWebAnalyticSession } from '../../utils/WebAnalyticsUtils';
|
||||
import { useAuthContext } from './AuthProvider';
|
||||
import { OidcUser } from './AuthProvider.interface';
|
||||
|
||||
@ -106,6 +107,9 @@ const BasicAuthProvider = ({
|
||||
scope: '',
|
||||
});
|
||||
}
|
||||
|
||||
// reset web analytic session
|
||||
resetWebAnalyticSession();
|
||||
} catch (error) {
|
||||
const err = error as AxiosError<{ code: number; message: string }>;
|
||||
|
||||
|
@ -11,7 +11,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { getSession, setSession } from '@analytics/session-utils';
|
||||
import {
|
||||
getSession,
|
||||
removeSession,
|
||||
setSession,
|
||||
} from '@analytics/session-utils';
|
||||
import Analytics, { AnalyticsInstance } from 'analytics';
|
||||
import { postPageView } from '../axiosAPIs/WebAnalyticsAPI';
|
||||
import { WebPageData } from '../components/WebAnalytics/WebAnalytics.interface';
|
||||
@ -130,3 +134,11 @@ export const getAnalyticInstance = (userId: string): AnalyticsInstance => {
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
export const resetWebAnalyticSession = () => {
|
||||
// remove existing session first
|
||||
removeSession();
|
||||
|
||||
// then set new analytics session for 30 minutes
|
||||
setSession(30);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user