From 796bf17c93e97209a22d2e5450f3cd3161ed5b9d Mon Sep 17 00:00:00 2001 From: Hannu Lyytikainen Date: Wed, 27 Sep 2017 12:56:30 +0300 Subject: [PATCH] Add user id to logger --- src/components/Topbar/Topbar.js | 4 ++++ src/containers/SearchPage/SearchPage.js | 1 - src/ducks/user.duck.js | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Topbar/Topbar.js b/src/components/Topbar/Topbar.js index 7b0fbaf8..d4ac0c34 100644 --- a/src/components/Topbar/Topbar.js +++ b/src/components/Topbar/Topbar.js @@ -9,6 +9,7 @@ import { withFlattenedRoutes, withViewport } from '../../util/contextHelpers'; import { parse, stringify } from '../../util/urlHelpers'; import { createResourceLocatorString, pathByRouteName } from '../../util/routes'; import * as propTypes from '../../util/propTypes'; +import { clearUserId } from '../../util/log'; import { Button, IconEmailAttention, @@ -145,6 +146,9 @@ class TopbarComponent extends Component { window.location = path; } + // clear user id from logger + clearUserId(); + // TODO: show flash message console.log('logged out'); // eslint-disable-line }); diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index 3367f2c8..0b4a7eeb 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -160,7 +160,6 @@ export class SearchPageComponent extends Component { sendVerificationEmailError, onResendVerificationEmail, } = this.props; - // eslint-disable-next-line no-unused-vars const { boundsChanged, page, ...searchInURL } = parse(location.search, { latlng: ['origin'], diff --git a/src/ducks/user.duck.js b/src/ducks/user.duck.js index 4644bd6e..09db41e9 100644 --- a/src/ducks/user.duck.js +++ b/src/ducks/user.duck.js @@ -1,6 +1,7 @@ import { authInfo } from './Auth.duck'; import { updatedEntities, denormalisedEntities } from '../util/data'; import { TX_TRANSITION_PREAUTHORIZE } from '../util/propTypes'; +import { setUserId } from '../util/log'; // ================ Action types ================ // @@ -337,6 +338,8 @@ export const fetchCurrentUser = () => const entities = updatedEntities({}, response.data); const denormalised = denormalisedEntities(entities, 'current-user', [currentUserId]); const currentUser = denormalised[0]; + // set current user id to the logger + setUserId(currentUser.id); dispatch(currentUserShowSuccess(currentUser)); return currentUser; })