Skip to content

chore: create a log for http requests#124

Open
ruocco-l wants to merge 2 commits into
masterfrom
chore/http-request-database
Open

chore: create a log for http requests#124
ruocco-l wants to merge 2 commits into
masterfrom
chore/http-request-database

Conversation

@ruocco-l

Copy link
Copy Markdown
Collaborator

Related to #123
Once this is merged I will add the secrets

@nikitachapovskii-dev nikitachapovskii-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @ruocco-l !
Please check comments below. Otherwise looks good

Comment thread src/request-logger.ts Outdated
Comment on lines +47 to +55
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;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have token in query then we should remove it/ignore before we check for custom fields.

Comment thread src/request-logger.ts Outdated
/**
* Initialize request logging (no-op if REQUEST_LOG_DATASET_ID is not set). Call once at startup.
*/
export async function initRequestLogger(): Promise<void> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it can be sync

@nicklamonov

Copy link
Copy Markdown
Collaborator

I don't think I can review it properly until it's on the platform. ) Ping me please, when it's in a beta build, for example.

@nikitachapovskii-dev nikitachapovskii-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread src/request-logger.ts
delete loggedQuery.token;

if (requiredParamKey !== undefined) {
const keys = Object.keys(query).filter((key) => key !== requiredParamKey);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const keys = Object.keys(query).filter((key) => key !== requiredParamKey);
const keys = Object.keys(query).filter((key) => key !== requiredParamKey && key !== 'token');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and move delete loggedQuery.token; right under delete loggedQuery[requiredParamKey]; so it's not after declaration 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants