<commit_before>require 'net/http'

module ApiTranscriptAgent
  class Sender

    API_REFEREE_RECEIVE_URL = 'http://api-transcript.dev/api/v1/transactions'

    attr_accessor :last_sent_transaction_data if Rails.env.test?

    def self.instance
      @instance ||= new
    end

    def delta_since(start_time)
      return Time.now - start_time
    end

    def send_data(env, response, headers, status)
      start_time = Time.now

      uri = URI(API_REFEREE_RECEIVE_URL)

      Rails.logger.debug "Sending transaction data to #{uri}…"

      request_headers = env.select {|k,v| k.start_with? 'HTTP_'}
        .transform_keys {|key| key.sub(/^HTTP_/, '').capitalize }

      request_headers['Content-Type'] = env['CONTENT_TYPE']
      request_headers['Content-Length'] = env['CONTENT_LENGTH']

      request_info = {
        body: env['RAW_POST_DATA'],
        headers: request_headers,
        method: env['REQUEST_METHOD'],
        host: env['HTTP_HOST'],<commit_msg>Fucked up the receiving URL<commit_after>require 'net/http'

module ApiTranscriptAgent
  class Sender

    API_REFEREE_RECEIVE_URL =
      if Rails.env.development?
        'http://api-transcript.dev/api/v1/transactions'
      else
        'http://api-transcript.herokuapp.com/api/v1/transactions'
      end

    attr_accessor :last_sent_transaction_data if Rails.env.test?

    def self.instance
      @instance ||= new
    end

    def delta_since(start_time)
      return Time.now - start_time
    end

    def send_data(env, response, headers, status)
      start_time = Time.now

      uri = URI(API_REFEREE_RECEIVE_URL)

      Rails.logger.debug "Sending transaction data to #{uri}…"

      request_headers = env.select {|k,v| k.start_with? 'HTTP_'}
        .transform_keys {|key| key.sub(/^HTTP_/, '').capitalize }

      request_headers['Content-Type'] = env['CONTENT_TYPE']
      request_headers['Content-Length'] = env['CONTENT_LENGTH']

      request_info = {
        body: env['RAW_POST_DATA'],
        headers: request_headers,
        method: env['REQUEST_METHOD'],
        host: env['HTTP_HOST'],
{'fraction_non_alphanumeric': 0.11821239788563191, 'fraction_numerical': 0.0014416146083613647, 'mean_word_length': 3.0505836575875485, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2117745', 'n_tokens_mistral': 697, 'n_tokens_neox': 667, 'n_words': 128}