Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add debug capabilities #19

Merged
merged 17 commits into from
Dec 26, 2024
Merged

feat: add debug capabilities #19

merged 17 commits into from
Dec 26, 2024

Conversation

Convly
Copy link
Member

@Convly Convly commented Dec 20, 2024

What does it do?

  • adds a dependency to the npm debug package (54kB) and supports-color (10kB)
  • introduce debug logs for critical parts of the SDK lifecycle (initialization, validation, http client, auth, content-type managers)

Also

  • fix repo configuration around lint, tests and pre-commit scripts

Why is it needed?

Better traceability and maintainability of the codebase.

Easier issue management/reproduction with finegrained logs

How to test it?

DEBUG=* node main.js # debug everything
DEBUG=sdk:auth:* node main.js # debug every auth module
DEBUG=sdj:ct:* node main.js # debug content type managers
DEBUG=*,-sdk:validators:* node main.js # debug everything except validators

TODO

  • add documentation

@Convly Convly added pr: feature New or updates to features source: sdk Source is the main SDK object labels Dec 20, 2024
Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

Nice! I didn't test it out, but code lgtm.

Comment on lines 224 to +231

private setContentTypeHeader(request: Request) {
const [key, value] = ['Content-Type', 'application/json'];

request.headers.set(key, value);

debug('%o header set to %o for %o', key, value, RequestHelper.format(request));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this? Could we instead have a setHeader(key, value)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Where would the log originate from? RequestHelper.setHeader(req, name, value) or from the http client when it calls it?

Let's continue the discussion and possibly add this in a later PR

@Convly Convly merged commit 3151d0d into main Dec 26, 2024
7 checks passed
@Convly Convly deleted the feat/debug branch December 26, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: feature New or updates to features source: sdk Source is the main SDK object
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants