diff --git a/src/config/apolloclient.ts b/src/config/apolloclient.ts index 4b0540d11..47f22d535 100644 --- a/src/config/apolloclient.ts +++ b/src/config/apolloclient.ts @@ -105,7 +105,7 @@ const gqlClient = (navigate: any) => { // @ts-ignore switch (networkError.statusCode) { case 401: - setLogs(`Error 401: logging user out`, 'error'); + setLogs(`Error 401: logging user out, ${JSON.stringify(networkError)}`, 'error'); navigate('/logout/session'); break; default: diff --git a/src/config/logs.ts b/src/config/logs.ts index e53820735..ef1bbc050 100644 --- a/src/config/logs.ts +++ b/src/config/logs.ts @@ -1,8 +1,12 @@ import pino from 'pino'; import { createPinoBrowserSend, createWriteStream } from 'pino-logflare'; import { LOGFLARE_API, LOGFLARE_SOURCE } from '.'; +import { getUserSession } from 'services/AuthService'; const setLogs = (message: any, type: string) => { + const orgId = getUserSession('organizationId'); + const userId = getUserSession('id'); + let logger: any; if (LOGFLARE_API && LOGFLARE_SOURCE) { @@ -33,11 +37,13 @@ const setLogs = (message: any, type: string) => { stream ); - let logMessage = message; + let logMessage; if (typeof message === 'object') { - logMessage = JSON.stringify(message); + message = JSON.stringify(message); } + logMessage = `org_id: ${orgId} user_id: ${userId} [${type}] ${message}`; + // log some events switch (type) { case 'info':