set userid regardless of signin

This commit is contained in:
jessop 2020-10-20 18:20:11 -04:00 committed by Sean Yesmunt
parent fab03d337e
commit 51c94d334a
2 changed files with 6 additions and 3 deletions

View file

@ -130,6 +130,7 @@ function App(props: Props) {
const rawReferrerParam = urlParams.get('r'); const rawReferrerParam = urlParams.get('r');
const sanitizedReferrerParam = rawReferrerParam && rawReferrerParam.replace(':', '#'); const sanitizedReferrerParam = rawReferrerParam && rawReferrerParam.replace(':', '#');
const shouldHideNag = pathname.startsWith(`/$/${PAGES.EMBED}`) || pathname.startsWith(`/$/${PAGES.AUTH_VERIFY}`); const shouldHideNag = pathname.startsWith(`/$/${PAGES.EMBED}`) || pathname.startsWith(`/$/${PAGES.AUTH_VERIFY}`);
const userId = user && user.id;
let uri; let uri;
try { try {
@ -142,6 +143,11 @@ function App(props: Props) {
setShowAnalyticsNag(false); setShowAnalyticsNag(false);
} }
// @endif // @endif
useEffect(() => {
if (userId) {
analytics.setUser(userId);
}
}, [userId]);
useEffect(() => { useEffect(() => {
if (!uploadCount) return; if (!uploadCount) return;

View file

@ -529,11 +529,8 @@ export function doSignIn() {
return (dispatch, getState) => { return (dispatch, getState) => {
const state = getState(); const state = getState();
const user = selectUser(state); const user = selectUser(state);
const userId = user.id;
const notificationsEnabled = user.experimental_ui; const notificationsEnabled = user.experimental_ui;
analytics.setUser(userId);
if (notificationsEnabled) { if (notificationsEnabled) {
dispatch(doSocketConnect()); dispatch(doSocketConnect());
dispatch(doNotificationList()); dispatch(doNotificationList());