bugsnag-ruby icon indicating copy to clipboard operation
bugsnag-ruby copied to clipboard

Change behavour of add_tab

Open stoivo opened this issue 5 years ago • 2 comments

Description

I find the api to add_tab very strange. Why is there such a huge diffence between hashes and arrays?

The current codes looks like

    def add_tab(name, value)
      return if name.nil?

      if value.is_a? Hash
        meta_data[name] ||= {}
        meta_data[name].merge! value
      else
        meta_data["custom"] = {} unless meta_data["custom"]

        meta_data["custom"][name.to_s] = value
      end
    end

I suggest

    def add_tab(name, value)
      return if name.nil?

      meta_data[name.to_sym] ||= {}
      meta_data[name].merge!(value.is_a? Hash ? value : {name.to_sym => value})
    end

I was very confused when I added one tab called details and it appeared in the web view as CUSTOM.

It's not realy a issue since I will just wrap slimiar to what I did in my changes. I can open a PR if you are interested in the chang. I think it makes the api more unifor, therefor betterm. On the other hand it chages the behavour so someone might be supprces if it changes.

stoivo avatar Mar 24 '20 15:03 stoivo

Hi @stoivo

Thanks for the feedback. We likely wouldn't accept a PR with your proposed suggestion at present due like you say to issues with other customers who may rely on the current behavior.

We plan to revisit this interface in the future and try to come up with a more consistent way of handling arrays being added to tabs though.

Thanks!

mattdyoung avatar Mar 30 '20 09:03 mattdyoung

Ok, not supprized. Stability is defenetly imprtant in a bug tracking software. Thansks for a good product.

stoivo avatar Mar 30 '20 11:03 stoivo