<commit_before>module BugHerdHelper

  def bugherd_tag(options = {})
    key = ENV['BUGHERD_PROJECT_KEY'] || BugHerd.configuration.project_key
    javascript_tag "
      var BugHerdConfig = #{options.to_json};
      (function (d, t) {
        var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
        bh.type = 'text/javascript';
        bh.src = '//www.bugherd.com/sidebarv2.js?apikey=#{key}';
        s.parentNode.insertBefore(bh, s);
      })(document, 'script');
    "
  end

end
<commit_msg>Add turbolinks compat<commit_after>module BugHerdHelper

  def bugherd_tag(options = {})
    key = ENV['BUGHERD_PROJECT_KEY'] || BugHerd.configuration.project_key
    if options[:turbolinks]
      javascript_tag "
        var BugHerdConfig = #{options.to_json};
        (function (d, t) {
          var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
          bh.type = 'text/javascript';
          bh.src = '//www.bugherd.com/sidebarv2.js?apikey=#{key}';
          s.parentNode.insertBefore(bh, s);
        })(document, 'script');
      "
    else
      javascript_tag "
        var BugHerdConfig = #{options.to_json};
        $(function() {
          if (window._bugHerd) {
            window._bugHerd.loadingComplete = false;
          }
          (function (d, t) {
            var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
            bh.type = 'text/javascript';
            bh.src = '//www.bugherd.com/sidebarv2.js?apikey=#{key}';
            s.parentNode.insertBefore(bh, s);
          })(document, 'script');
        });
      "
    end
  end

end

{'fraction_non_alphanumeric': 0.14858934169278998, 'fraction_numerical': 0.003761755485893417, 'mean_word_length': 2.3389121338912133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4250612', 'n_tokens_mistral': 553, 'n_tokens_neox': 542, 'n_words': 89}