<commit_before>require 'exceptional'
require 'sinatra/base'
require 'sinatra/exceptional/version'
require 'digest/md5'

module Exceptional
  class Catcher
    class << self
      def handle_with_sinatra(exception, environment, request, opts)
        if Config.should_send_to_api?
          data = SinatraExceptionData.new exception, environment, request, opts
          Remote.error data
        end
      end
    end
  end

  class SinatraExceptionData < ExceptionData
    FILTERED_TEXT = '[FILTERED]'

    def initialize(exception, environment, request, opts={})
      super exception
      @opts = opts
      @environment = environment
      @request = request
    end

    def framework
      "sinatra"
    end

    def extra_stuff
      params = {}

      if @opts && @opts[:params_filter]
        @request.params.each do |k,v|
          params[k] =  k.to_s.match(@opts[:params_filter]) ? FILTERED_TEXT : v
        end
      else
        params = @request.params
      end
<commit_msg>move params filtering to another method<commit_after>require 'exceptional'
require 'sinatra/base'
require 'sinatra/exceptional/version'
require 'digest/md5'

module Exceptional
  class Catcher
    class << self
      def handle_with_sinatra(exception, environment, request, opts)
        if Config.should_send_to_api?
          data = SinatraExceptionData.new exception, environment, request, opts
          Remote.error data
        end
      end
    end
  end

  class SinatraExceptionData < ExceptionData
    FILTERED_TEXT = '[FILTERED]'

    def initialize(exception, environment, request, opts={})
      super exception
      @opts = opts
      @environment = environment
      @request = request
    end

    def framework
      "sinatra"
    end

    def params
      params = {}

      if @opts && @opts[:params_filter]
        @request.params.each do |key,original_value|
          params[key] =  key.to_s.match(@opts[:params_filter]) ? FILTERED_TEXT : original_value
        end
      else
        params = @request.params
      end
      params
    end

    def extra_stuff

{'fraction_non_alphanumeric': 0.08096385542168674, 'fraction_numerical': 0.0009638554216867469, 'mean_word_length': 2.536626916524702, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '6688240', 'n_tokens_mistral': 606, 'n_tokens_neox': 579, 'n_words': 157}