diff --git a/frontend/src/api/common/logEvent.ts b/frontend/src/api/common/logEvent.ts index 212d382d77..a1bf3dba7c 100644 --- a/frontend/src/api/common/logEvent.ts +++ b/frontend/src/api/common/logEvent.ts @@ -1,4 +1,4 @@ -import axios from 'api'; +import { ApiBaseInstance as axios } from 'api'; import { ErrorResponseHandler } from 'api/ErrorResponseHandler'; import { AxiosError } from 'axios'; import { ErrorResponse, SuccessResponse } from 'types/api'; @@ -21,6 +21,7 @@ const logEvent = async ( payload: response.data.data, }; } catch (error) { + console.error(error); return ErrorResponseHandler(error as AxiosError); } }; diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index 1ec4cda601..7f5e2d476c 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -96,6 +96,10 @@ const interceptorRejected = async ( } }; +const interceptorRejectedBase = async ( + value: AxiosResponse, +): Promise> => Promise.reject(value); + const instance = axios.create({ baseURL: `${ENVIRONMENT.baseURL}${apiV1}`, }); @@ -140,6 +144,18 @@ ApiV4Instance.interceptors.response.use( ApiV4Instance.interceptors.request.use(interceptorsRequestResponse); // +// axios Base +export const ApiBaseInstance = axios.create({ + baseURL: `${ENVIRONMENT.baseURL}${apiV1}`, +}); + +ApiBaseInstance.interceptors.response.use( + interceptorsResponse, + interceptorRejectedBase, +); +ApiBaseInstance.interceptors.request.use(interceptorsRequestResponse); +// + // gateway Api V1 export const GatewayApiV1Instance = axios.create({ baseURL: `${ENVIRONMENT.baseURL}${gatewayApiV1}`, diff --git a/frontend/src/hooks/analytics/useAnalytics.tsx b/frontend/src/hooks/analytics/useAnalytics.tsx index 28213c9579..e3d2081766 100644 --- a/frontend/src/hooks/analytics/useAnalytics.tsx +++ b/frontend/src/hooks/analytics/useAnalytics.tsx @@ -32,16 +32,6 @@ const useAnalytics = (): any => { } }; - // useEffect(() => { - // // Perform any setup or cleanup related to the analytics library - // // For example, initialize analytics library here - - // // Clean-up function (optional) - // return () => { - // // Perform cleanup if needed - // }; - // }, []); // The empty dependency array ensures that this effect runs only once when the component mounts - return { trackPageView, trackEvent }; };