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

[Themes] Add status codes and event methods to user logging #4605

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

EvilGenius13
Copy link
Contributor

@EvilGenius13 EvilGenius13 commented Oct 8, 2024

WHY are these changes introduced?

Iterating on the last user logging improvements

Follow up to: #4536
Closes: https://github.com/Shopify/develop-advanced-edits/issues/359

WHAT is this pull request doing?

This PR adds more functionality to user logging when using the Dev Server.

Highlights:

  • Pulled the logRequestLine function into it's own util file for use in other areas
  • Added logging to proxy requests allowing us to see POST requests (not including /cdn routes)
  • Added some colour distinction to the output such as status codes and response time

Output example with changes:
image

How to test your changes?

Pull down the branch
Build the branch
run theme dev
click around and watch the logs

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Oct 8, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.73% (+0.24% 🔼)
8563/11773
🟡 Branches
69.71% (+0.57% 🔼)
4204/6031
🟡 Functions
71.7% (-0.06% 🔻)
2212/3085
🟡 Lines
73.06% (+0.27% 🔼)
8105/11093
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / function-upload-url-generate.ts
100% 100% 100% 100%
🟢
... / authorize.ts
100% 75% 100% 100%
🔴
... / post-auth.ts
44.12% 0% 0% 45.45%
🔴
... / redirect-listener.ts
14.75% 0% 33.33% 15%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app.test-data.ts
91.4%
91.09% (-0.09% 🔻)
81.01% 90.8%
🟢
... / app.ts
87.07%
70.89% (-0.72% 🔻)
92% 88.37%
🟢
... / function.ts
86.36% (-0.59% 🔻)
86.36% 83.33%
86.36% (-0.59% 🔻)
🟢
... / app-context.ts
100%
87.5% (-1.97% 🔻)
100% 100%
🟢
... / deploy.ts
87.18%
85% (-7.86% 🔻)
87.5% 89.19%
🟢
... / generate.ts
100%
80% (-2.14% 🔻)
100% 100%
🟢
... / versions-list.ts
100%
85.71% (-1.79% 🔻)
100% 100%
🟢
... / show.ts
100%
66.67% (-8.33% 🔻)
100% 100%
🔴
... / extension.ts
55.26% (-0.29% 🔻)
50% 57.14%
56.76% (-0.06% 🔻)
🟡
... / update-extension.ts
66.67% (-3.33% 🔻)
54.55% (-3.79% 🔻)
60%
70.97% (-3.32% 🔻)
🟡
... / build.ts
74.49%
59.09% (-2.27% 🔻)
75.76% 72.22%
🟢
... / extension.ts
91.4% (+0.09% 🔼)
73.58%
91.3% (-0.36% 🔻)
91.21% (+0.1% 🔼)
🔴
... / app-management-client.ts
20.75% (-0.09% 🔻)
10.26%
22.58% (-0.25% 🔻)
19% (-0.09% 🔻)
🔴
... / partners-client.ts
26.87% (-0.2% 🔻)
40%
18.18% (-0.34% 🔻)
26.56% (-0.21% 🔻)
🟢
... / session.ts
81.01% (-1.99% 🔻)
72.32% (-0.41% 🔻)
92.86%
80.67% (-2.09% 🔻)
🟡
... / fs.ts
62.5%
84.62% (-7.05% 🔻)
58.97% 62.5%
🟢
... / admin.ts
82.76% (+1.51% 🔼)
37.5% (-2.5% 🔻)
90%
85.71% (+1.84% 🔼)

Test suite run success

1948 tests passing in 877 suites.

Report generated by 🧪jest coverage report action from 581abd8

@EvilGenius13
Copy link
Contributor Author

For status codes I went with green for any 2xx status, yellow for 3xx (redirects), and red for anything 4xx-5xx.

I'm also torn on part of the logging. On every request we make a /checkouts/internal/preloads.js? request as well. This adds some noise to the output. I considered ignoring it but I'm not sure if that would cause a debugging issue if someone wanted to make sure that was working as intended. Happy for some opinions.

@frandiox I would love your feedback based on your original comments from the PR prior to this. Would you want padding for the Status codes to always be in line or does this seem sufficient.

Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

I think I would personally prefer aligning them to the right:

Request >>  GET 200 /...
Request >>  GET 404 /...
Request >> POST 200 /...
Request >>  GET 200 /...
Request >> POST 400 /...

If we want we could do the same with Request and Synced. Also, to make them more similar, another possibility is moving the statuses after the path:

Request >>    GET  /...  200 400ms
Request >>   POST  /...  200  500ms
 Synced >> update  /layout/theme...
Request >>    GET  /...  404  150ms

Just a random thought, not sure if this looks any better.
cc @jamesmengo I feel you probably have a better judgement on this 😂

@EvilGenius13 EvilGenius13 requested a review from a team as a code owner October 9, 2024 18:04
@EvilGenius13 EvilGenius13 requested review from jantnovi and gonzaloriestra and removed request for a team October 9, 2024 18:04
@EvilGenius13
Copy link
Contributor Author

Thanks for the changes!

I think I would personally prefer aligning them to the right:

Request >>  GET 200 /...
Request >>  GET 404 /...
Request >> POST 200 /...
Request >>  GET 200 /...
Request >> POST 400 /...

If we want we could do the same with Request and Synced. Also, to make them more similar, another possibility is moving the statuses after the path:

Request >>    GET  /...  200 400ms
Request >>   POST  /...  200  500ms
 Synced >> update  /layout/theme...
Request >>    GET  /...  404  150ms

Just a random thought, not sure if this looks any better. cc @jamesmengo I feel you probably have a better judgement on this 😂

This is the current look which the changes
image

Although I prefer seeing the status code after the event method, I can see how it aligns better with the Synced >>

So the only piece left is that the actions are lower cases in Synced and I think that helps quickly differentiate what kind of thing we're looking at (Request vs Synced) if were browsing details.

If needed I can probably push the action over but that makes me wonder if I should uppercase the action.

Copy link
Contributor

@frandiox frandiox left a comment

Choose a reason for hiding this comment

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

Thanks so much for all the updates! I'll defer to the other reviewers for the log styles 🙌

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, @EvilGenius13! Logs look so much better 🤩

I've left only one refactoring + unit testing suggestion, and with that we will be ready to merge :)

Although I prefer seeing the status code after the event method, I can see how it aligns better with the Synced >>

Loved the idea of aligning them to the right, but I strongly prefer the status codes after the event method as well 😅

Thanks again for this PR!

Copy link
Contributor

@jamesmengo jamesmengo left a comment

Choose a reason for hiding this comment

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

🚀 Nice work and thanks for the changes!

+1 to adding the guard condition in logRequestLine + Guilherme's styling suggestions before merging

@EvilGenius13 EvilGenius13 force-pushed the log-improvment-iteration branch 3 times, most recently from b2e18d1 to 2fb5be6 Compare October 11, 2024 16:36
Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you, @EvilGenius13! 🚀

This commit moves the logRequestLine function into a separate file and adds
status codes and event methods. It grabs both get and post requests
@karreiro karreiro added this pull request to the merge queue Oct 17, 2024
Merged via the queue into main with commit b0c806b Oct 17, 2024
36 checks passed
@karreiro karreiro deleted the log-improvment-iteration branch October 17, 2024 05:16
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