Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update logEvent to silently handle errors #5599

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/src/api/common/logEvent.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,6 +21,7 @@ const logEvent = async (
payload: response.data.data,
};
} catch (error) {
console.error(error);
return ErrorResponseHandler(error as AxiosError);
}
};
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const interceptorRejected = async (
}
};

const interceptorRejectedBase = async (
value: AxiosResponse<any>,
): Promise<AxiosResponse<any>> => Promise.reject(value);

const instance = axios.create({
baseURL: `${ENVIRONMENT.baseURL}${apiV1}`,
});
Expand Down Expand Up @@ -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}`,
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/hooks/analytics/useAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

Expand Down
Loading