From 0a63afb6aa64e8d23a8f0f3f83f41dd02bc3d03b Mon Sep 17 00:00:00 2001 From: Kristaps Fabians Geikins Date: Fri, 9 Feb 2024 13:56:13 +0200 Subject: [PATCH] feat: various observability improvements (#2027) * feat(server): adding userId to req logs * feat(server): adding userId to gql logs * feat(fe2): adding userId to logger calls * feat(fe2): more userId logging additions * even more thorough logging in FE2 * more adjustments * add country to fe2 logs * added prop to help distinguish gql req time logs * get initial SSR req id in CSR logs * improved 'fetch failed' error * better rate limit error message * minor improvements --- packages/frontend-2/.env.example | 3 + packages/frontend-2/app.vue | 1 + .../components/error/page/Renderer.vue | 12 +- packages/frontend-2/error.vue | 4 +- .../lib/auth/composables/activeUser.ts | 10 ++ .../lib/core/composables/appErrorState.ts | 2 +- .../frontend-2/lib/core/composables/server.ts | 31 +++++ .../frontend-2/lib/core/configs/apollo.ts | 8 +- .../lib/core/helpers/observability.ts | 70 +++++++++-- packages/frontend-2/nuxt.config.ts | 1 + packages/frontend-2/plugins/001-logger.ts | 111 +++++++++++++----- .../server/lib/core/helpers/observability.ts | 55 +++++++++ .../server/middleware/001-logging.ts | 32 ++--- .../frontend-2/type-augmentations/server.d.ts | 7 ++ packages/server/app.ts | 11 +- packages/server/logging/apolloPlugin.js | 5 +- packages/server/logging/expressLogging.ts | 19 ++- .../server/type-augmentations/express.d.ts | 6 + 18 files changed, 310 insertions(+), 78 deletions(-) create mode 100644 packages/frontend-2/type-augmentations/server.d.ts diff --git a/packages/frontend-2/.env.example b/packages/frontend-2/.env.example index c8790391e2..d520789d63 100644 --- a/packages/frontend-2/.env.example +++ b/packages/frontend-2/.env.example @@ -4,6 +4,9 @@ PORT=8081 NUXT_PUBLIC_LOG_LEVEL=debug NUXT_PUBLIC_LOG_PRETTY=true +# Whether to emit extra properties (bindings) that would be sent to seq to the console in CSR +NUXT_PUBLIC_LOG_CSR_EMIT_PROPS=false + NUXT_PUBLIC_API_ORIGIN=http://127.0.0.1:3000 NUXT_PUBLIC_BASE_URL=http://127.0.0.1:8081 diff --git a/packages/frontend-2/app.vue b/packages/frontend-2/app.vue index 55f9f95db2..1e06bffd84 100644 --- a/packages/frontend-2/app.vue +++ b/packages/frontend-2/app.vue @@ -13,6 +13,7 @@ import { useTheme } from '~~/lib/core/composables/theme' import { useAuthManager } from '~~/lib/auth/composables/auth' import { useMixpanelInitialization } from '~~/lib/core/composables/mp' + const { isDarkTheme } = useTheme() useHead({ diff --git a/packages/frontend-2/components/error/page/Renderer.vue b/packages/frontend-2/components/error/page/Renderer.vue index 86fcdd7fe8..428b80075a 100644 --- a/packages/frontend-2/components/error/page/Renderer.vue +++ b/packages/frontend-2/components/error/page/Renderer.vue @@ -2,18 +2,19 @@ diff --git a/packages/frontend-2/error.vue b/packages/frontend-2/error.vue index f14644ce99..b93aa21f22 100644 --- a/packages/frontend-2/error.vue +++ b/packages/frontend-2/error.vue @@ -10,6 +10,7 @@