Merge branch 'fix/login-errmsg' into 'release'
Fixed login error message. Wrong user email in segment after logout issue. See merge request theappsmith/internal-tools-client!462
This commit is contained in:
commit
dc8a921f1e
|
|
@ -8,7 +8,7 @@ import { AppToaster } from "components/editorComponents/ToastComponent";
|
|||
import { DEFAULT_ERROR_MESSAGE, DEFAULT_ACTION_ERROR } from "constants/errors";
|
||||
import { ApiResponse } from "api/ApiResponses";
|
||||
import { put, takeLatest, call } from "redux-saga/effects";
|
||||
import { ERROR_500, ERROR_0 } from "constants/messages";
|
||||
import { ERROR_401, ERROR_500, ERROR_0 } from "constants/messages";
|
||||
import { ToastType } from "react-toastify";
|
||||
|
||||
export function* callAPI(apiCall: any, requestPayload: any) {
|
||||
|
|
@ -20,6 +20,8 @@ export function* callAPI(apiCall: any, requestPayload: any) {
|
|||
}
|
||||
const getErrorMessage = (code: number) => {
|
||||
switch (code) {
|
||||
case 401:
|
||||
return ERROR_401;
|
||||
case 500:
|
||||
return ERROR_500;
|
||||
case 0:
|
||||
|
|
@ -28,6 +30,9 @@ const getErrorMessage = (code: number) => {
|
|||
};
|
||||
|
||||
export function* validateResponse(response: ApiResponse | any) {
|
||||
if (!response) {
|
||||
throw Error("");
|
||||
}
|
||||
if (!response.responseMeta && !response.status) {
|
||||
throw Error(getErrorMessage(0));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { call, takeLatest, put, all } from "redux-saga/effects";
|
||||
import { call, takeLatest, put, all, delay } from "redux-saga/effects";
|
||||
import {
|
||||
ReduxAction,
|
||||
ReduxActionWithPromise,
|
||||
|
|
@ -275,6 +275,10 @@ export function* fetchUserSaga(action: ReduxAction<FetchUserRequest>) {
|
|||
applications,
|
||||
currentOrganization,
|
||||
};
|
||||
AnalyticsUtil.identifyUser(finalData.id, finalData);
|
||||
Sentry.configureScope(function(scope) {
|
||||
scope.setUser({ email: finalData.email, id: finalData.id });
|
||||
});
|
||||
yield put({
|
||||
type: ReduxActionTypes.FETCH_USER_SUCCESS,
|
||||
payload: finalData,
|
||||
|
|
@ -284,22 +288,20 @@ export function* fetchUserSaga(action: ReduxAction<FetchUserRequest>) {
|
|||
return yield false;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
yield put({
|
||||
type: ReduxActionErrorTypes.FETCH_USER_ERROR,
|
||||
payload: {
|
||||
error,
|
||||
},
|
||||
});
|
||||
if (error) {
|
||||
yield put({
|
||||
type: ReduxActionErrorTypes.FETCH_USER_ERROR,
|
||||
payload: {
|
||||
error,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function* setCurrentUserSaga(action: ReduxAction<FetchUserRequest>) {
|
||||
const me = yield call(fetchUserSaga, action);
|
||||
if (me) {
|
||||
AnalyticsUtil.identifyUser(me.id, me);
|
||||
Sentry.configureScope(function(scope) {
|
||||
scope.setUser({ email: me.email, id: me.id });
|
||||
});
|
||||
resetAuthExpiration();
|
||||
yield put({
|
||||
type: ReduxActionTypes.SET_CURRENT_USER_SUCCESS,
|
||||
|
|
@ -362,6 +364,7 @@ export function* logoutSaga() {
|
|||
const response: ApiResponse = yield call(UserApi.logoutUser);
|
||||
const isValidResponse = yield validateResponse(response);
|
||||
if (isValidResponse) {
|
||||
AnalyticsUtil.reset();
|
||||
yield put(logoutUserSuccess());
|
||||
yield put(fetchCurrentUser());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,12 @@ class AnalyticsUtil {
|
|||
windowDoc.analytics.identify(userId, userData);
|
||||
}
|
||||
}
|
||||
|
||||
static reset() {
|
||||
const windowDoc: any = window;
|
||||
windowDoc.analytics.reset();
|
||||
windowDoc.mixpanel.reset();
|
||||
}
|
||||
}
|
||||
|
||||
export default AnalyticsUtil;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user