mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-28 10:56:02 +00:00
parent
54808a027e
commit
2c430d1c7e
@ -20,4 +20,6 @@ declare module '@analytics/session-utils' {
|
|||||||
extra = {},
|
extra = {},
|
||||||
extend?: boolean
|
extend?: boolean
|
||||||
) => Session;
|
) => Session;
|
||||||
|
|
||||||
|
export const removeSession: () => void;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { removeSession } from '@analytics/session-utils';
|
||||||
import { Auth0Provider } from '@auth0/auth0-react';
|
import { Auth0Provider } from '@auth0/auth0-react';
|
||||||
import { Configuration } from '@azure/msal-browser';
|
import { Configuration } from '@azure/msal-browser';
|
||||||
import { MsalProvider } from '@azure/msal-react';
|
import { MsalProvider } from '@azure/msal-react';
|
||||||
@ -64,6 +65,7 @@ import {
|
|||||||
getUserDataFromOidc,
|
getUserDataFromOidc,
|
||||||
matchUserDetails,
|
matchUserDetails,
|
||||||
} from '../../utils/UserDataUtils';
|
} from '../../utils/UserDataUtils';
|
||||||
|
import { resetWebAnalyticSession } from '../../utils/WebAnalyticsUtils';
|
||||||
import Auth0Authenticator from '../authenticators/Auth0Authenticator';
|
import Auth0Authenticator from '../authenticators/Auth0Authenticator';
|
||||||
import BasicAuthAuthenticator from '../authenticators/basic-auth.authenticator';
|
import BasicAuthAuthenticator from '../authenticators/basic-auth.authenticator';
|
||||||
import MsalAuthenticator from '../authenticators/MsalAuthenticator';
|
import MsalAuthenticator from '../authenticators/MsalAuthenticator';
|
||||||
@ -113,11 +115,16 @@ export const AuthProvider = ({
|
|||||||
const onLoginHandler = () => {
|
const onLoginHandler = () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
authenticatorRef.current?.invokeLogin();
|
authenticatorRef.current?.invokeLogin();
|
||||||
|
|
||||||
|
resetWebAnalyticSession();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLogoutHandler = useCallback(() => {
|
const onLogoutHandler = useCallback(() => {
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
authenticatorRef.current?.invokeLogout();
|
authenticatorRef.current?.invokeLogout();
|
||||||
|
|
||||||
|
// remove analytics session on logout
|
||||||
|
removeSession();
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}, [timeoutId]);
|
}, [timeoutId]);
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import {
|
|||||||
showInfoToast,
|
showInfoToast,
|
||||||
showSuccessToast,
|
showSuccessToast,
|
||||||
} from '../../utils/ToastUtils';
|
} from '../../utils/ToastUtils';
|
||||||
|
import { resetWebAnalyticSession } from '../../utils/WebAnalyticsUtils';
|
||||||
import { useAuthContext } from './AuthProvider';
|
import { useAuthContext } from './AuthProvider';
|
||||||
import { OidcUser } from './AuthProvider.interface';
|
import { OidcUser } from './AuthProvider.interface';
|
||||||
|
|
||||||
@ -106,6 +107,9 @@ const BasicAuthProvider = ({
|
|||||||
scope: '',
|
scope: '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset web analytic session
|
||||||
|
resetWebAnalyticSession();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const err = error as AxiosError<{ code: number; message: string }>;
|
const err = error as AxiosError<{ code: number; message: string }>;
|
||||||
|
|
||||||
|
@ -11,7 +11,11 @@
|
|||||||
* limitations under the License.
|
* 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 Analytics, { AnalyticsInstance } from 'analytics';
|
||||||
import { postPageView } from '../axiosAPIs/WebAnalyticsAPI';
|
import { postPageView } from '../axiosAPIs/WebAnalyticsAPI';
|
||||||
import { WebPageData } from '../components/WebAnalytics/WebAnalytics.interface';
|
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