commerce.js icon indicating copy to clipboard operation
commerce.js copied to clipboard

Console debugger: notes and improvements

Open robbieaverill opened this issue 3 years ago • 1 comments

The console debugger was piped over from CJS v1 to v2, but doesn't work as well as it probably used to for a few reasons:

  • Not all API responses provide the metadata necessary for the console debugger to show things
  • Browsers now have dark mode, CJS helper looks best in light mode
  • 422s cause uncaught promise exceptions in the console which pollutes the CJS debugger output

My suggestions would be that we remove debugger output from the API and move it entirely into Commerce.js. We know what all of the API calls are because we initiate them, and we know whether they were successful or not, because we can monitor the HTTP status code of each request. We should be able to achieve this with an Axios interceptor, or something similar.

I think the CJS helper should show successful requests as well as failures, at a quick test it looks like it's currently only showing some errors, but no successes (from adding to cart and completing a checkout, I didn't see any).

robbieaverill avatar Oct 08 '20 17:10 robbieaverill

Some of this post is still relevant. I think that the console debugger in Commerce.js should be the only place that handles outputting debug events, and that we should remove them from the API. #124 resolves an issue where 422 error messages weren't being clearly output.

robbieaverill avatar Jun 17 '21 00:06 robbieaverill