chore: create a log for http requests#124
Conversation
nikitachapovskii-dev
left a comment
There was a problem hiding this comment.
Thanks, @ruocco-l !
Please check comments below. Otherwise looks good
| if (requiredParamKey !== undefined) { | ||
| const keys = Object.keys(query).filter((key) => key !== requiredParamKey); | ||
| if (keys.length === 0) return; | ||
| loggedQuery = { ...(query as Record<string, string>) }; | ||
| delete loggedQuery[requiredParamKey]; | ||
| } | ||
|
|
||
| // Never persist the token query param (used for standby-mode auth) into the logged item. | ||
| delete loggedQuery.token; |
There was a problem hiding this comment.
if we have token in query then we should remove it/ignore before we check for custom fields.
| /** | ||
| * Initialize request logging (no-op if REQUEST_LOG_DATASET_ID is not set). Call once at startup. | ||
| */ | ||
| export async function initRequestLogger(): Promise<void> { |
There was a problem hiding this comment.
nit: it can be sync
|
I don't think I can review it properly until it's on the platform. ) Ping me please, when it's in a |
nikitachapovskii-dev
left a comment
There was a problem hiding this comment.
hmm, as it is now the token still should end up in the log and slip past the empty check 🤔
Would something like this work?
| delete loggedQuery.token; | ||
|
|
||
| if (requiredParamKey !== undefined) { | ||
| const keys = Object.keys(query).filter((key) => key !== requiredParamKey); |
There was a problem hiding this comment.
| const keys = Object.keys(query).filter((key) => key !== requiredParamKey); | |
| const keys = Object.keys(query).filter((key) => key !== requiredParamKey && key !== 'token'); |
There was a problem hiding this comment.
and move delete loggedQuery.token; right under delete loggedQuery[requiredParamKey]; so it's not after declaration 😄
Related to #123
Once this is merged I will add the secrets