<commit_before># encoding: utf-8

require 'toadhopper'
require 'socket'
require 'adhearsion/reporter/version'

module Adhearsion
  class Reporter
    class AirbrakeNotifier
      include Singleton

      def init
        @notifier = Toadhopper.new Reporter.config.api_key, :notify_host => Reporter.config.url
        @options = {
          framework_env: Adhearsion.config.platform.environment,
          notifier_name: 'adhearsion-reporter',
          project_root: Adhearsion.config.platform[:root]
          notifier_version: Adhearsion::Reporter::VERSION,
        }
      end

      def notify(ex)
        return unless should_post?
        response = @notifier.post!(ex, @options)
        if !response.errors.empty? || !(200..299).include?(response.status.to_i)
          logger.error "Error posting exception to #{Reporter.config.url}! Response code #{response.status}"
          response.errors.each do |error|
            logger.error "#{error}"<commit_msg>Include some environment information<commit_after># encoding: utf-8

require 'toadhopper'
require 'socket'
require 'adhearsion/reporter/version'

module Adhearsion
  class Reporter
    class AirbrakeNotifier
      include Singleton

      def init
        @notifier = Toadhopper.new Reporter.config.api_key, :notify_host => Reporter.config.url
        @options = {
          framework_env: Adhearsion.config.platform.environment,
          notifier_name: 'adhearsion-reporter',
          notifier_version: Adhearsion::Reporter::VERSION,
          project_root: Adhearsion.config.platform[:root],
          environment: {
            'HOSTNAME' => Socket.gethostname,
            'AHN_VERSION' => Adhearsion::VERSION
          }
        }
      end

      def notify(ex)
        return unless should_post?
        response = @notifier.post!(ex, @options)
        if !response.errors.empty? || !(200..299).include?(response.status.to_i)
          logger.error "Error posting exception to #{Reporter.config.url}! Response code #{response.status}"
          response.errors.each do |error|
            logger.error "#{error}"
{'fraction_non_alphanumeric': 0.10546500479386385, 'fraction_numerical': 0.006711409395973154, 'mean_word_length': 2.767148014440433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2002095', 'n_tokens_mistral': 618, 'n_tokens_neox': 605, 'n_words': 125}