honeybadger-elixir icon indicating copy to clipboard operation
honeybadger-elixir copied to clipboard

Is this documentation outdated?

Open joshuap opened this issue 4 years ago • 4 comments

The README and code docs for Honeybadger.notify say to pass the context as the second argument:

https://github.com/honeybadger-io/honeybadger-elixir/blob/d051f0754dd44e13c9cc7c989d7fdfc5cb068f82/lib/honeybadger.ex#L44

...but it looks like the second argument is actually metadata, which expects a context key:

https://github.com/honeybadger-io/honeybadger-elixir/blob/c2dc31100fb764ad4b0c4df6bf94bdef0bbc8984/lib/honeybadger/notice.ex#L58

Should it be Honeybadger.notify(exception, context), or Honeybadger.notify(exception, %{context: context})? I may be forgetting how this works.

cc @rabidpraxis @sorentwo

joshuap avatar Jul 10 '20 18:07 joshuap

@joshuap The second argument is the metadata and not the context. To pass in context you need the %{context: context} map.

sorentwo avatar Jul 13 '20 14:07 sorentwo

@joshuap Notice.new expects a map with :context, but it looks like Honeybadger.notify will jam all metadata the into the context key if its not already present:

https://github.com/honeybadger-io/honeybadger-elixir/blob/24edb30cb2a2c9462bdc453c9943fa64ef9bac00/lib/honeybadger.ex#L253-L257

https://github.com/honeybadger-io/honeybadger-elixir/blob/24edb30cb2a2c9462bdc453c9943fa64ef9bac00/lib/honeybadger.ex#L428-L435

rabidpraxis avatar Jul 13 '20 15:07 rabidpraxis

@rabidpraxis oh OK, so our docs are actually valid? Is there a method you prefer?

joshuap avatar Aug 17 '20 18:08 joshuap

I'm not sure. I probably swing towards favoring the explicit version, just for readability sake.

rabidpraxis avatar Aug 19 '20 17:08 rabidpraxis