error-tracker icon indicating copy to clipboard operation
error-tracker copied to clipboard

Support native JSON module

Open crbelaus opened this issue 10 months ago • 5 comments

Since Elixir 1.18 there is a native JSON module, so new projects don't need Jason and many don't have it. This pull request updates the error tracker so:

  • Jason is an optional dependency as the error tracker can work without it
  • We try to use the user-defined JSON library (just like we did before) but if none is defined we default to the native JSON module for Elixir 1.18 and newer. On older versions we still default to Jason just like we did before.
  • We use the encode_to_iodata! function which is the most performant and provided by both libraries.
  • The JSON module can't pretty print like Jason does. Instead we are now pretty printing in the client using JSON.stringify which is widely available across all browsers.

There should not be any user-facing changes. Users will still see the JSON context formatted just like they did before but now the ErrorTracker works well on Elixir 1.18 and newer projects that don't include Jason. We also don't force it for such projects as a native alternative exists.

Closes #131

crbelaus avatar Mar 02 '25 10:03 crbelaus

I've just run mix assets.build, not sure why there are so many changes in the app.js file 🤔

crbelaus avatar Mar 03 '25 14:03 crbelaus

@crbelaus any update on this one? Do you need help, by any chance?

gmile avatar Jul 24 '25 09:07 gmile

I'd love to see this PR going through :)

xu-chris avatar Aug 06 '25 06:08 xu-chris

@crbelaus any update on this one? Do you need help, by any chance?

If someone can help testing this under Elixir 1.18 it would be great, just to confirm that things are working as expected without Jason.

crbelaus avatar Aug 06 '25 13:08 crbelaus

Hey, I've tested it now. Sorry for the delay. It works as expected.

xu-chris avatar Sep 12 '25 23:09 xu-chris