Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
#1206 - experimental change to check if intercom has booted
Browse files Browse the repository at this point in the history
  • Loading branch information
rupeshparab committed Jul 21, 2020
1 parent 6efd34e commit 5c9d32a
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/redux/userProfile/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,29 +195,36 @@ function* saveUserInfoSaga() {
email,
redirectTo,
} = yield select(getState);
let intercomPayload = null;
try {
const {
userType,
grades,
role,
} = payload;
IntercomAPI('trackEvent', 'user-details', {
userType: getFormattedUserType(userType),
userRole: role,
grades,
});
const userInfoResponse = yield call(saveUserInfoApi, {
...payload,
user_type: userType,
email,
});
yield put(setUserInfo(userInfoResponse.data));
intercomPayload = {
userType: getFormattedUserType(userType),
userRole: role,
grades,
}
} catch (error) {
yield put({
type: 'SAVE_USER_INFO_FAILURE',
});
} finally {
yield put(replace(redirectTo));
if (intercomPayload) {
while (!window.Intercom.booted) {
yield delay(1000);
}
IntercomAPI('trackEvent', 'user-details', intercomPayload);
}
}
});
}
Expand All @@ -234,14 +241,17 @@ function* setUserProfileSaga() {
email,
name,
} = payload;
ReactGA.set({
email,
});
while (!window.Intercom.booted) {
yield delay(1000);
}
IntercomAPI('update', {
user_id: email,
email,
name,
});
ReactGA.set({
email,
});
});
}

Expand Down

0 comments on commit 5c9d32a

Please sign in to comment.