<commit_before>require "keen"
require "sidekiq"

module Travis
  class TravisYmlStats
    class KeenPublisher
      include ::Sidekiq::Worker

      sidekiq_options queue: :keen_events

      def perform(payload)
        Keen.publish(:requests, payload)
      end
    end

    LANGUAGE_VERSION_KEYS = %w[
      ghc
      go
      jdk
      node_js
      otp_release
      perl
      php
      python
      ruby
      rvm
      scala
    ]

    def self.store_stats(request, publisher=KeenPublisher)
      new(request, publisher).store_stats
    end

    def initialize(request, publisher)
      @request = request
      @publisher = publisher
      @keen_payload = {}
    end

    def store_stats
      set_basic_info<commit_msg>Condtionally load Keen IO and don't fail if it's not loaded<commit_after>require "sidekiq"

begin
  require "keen"
rescue LoadError
end

module Travis
  class TravisYmlStats
    class KeenPublisher
      include ::Sidekiq::Worker

      sidekiq_options queue: :keen_events

      def perform(payload)
        if defined?(Keen) && ENV["KEEN_PROJECT_ID"]
          Keen.publish(:requests, payload)
        end
      end
    end

    LANGUAGE_VERSION_KEYS = %w[
      ghc
      go
      jdk
      node_js
      otp_release
      perl
      php
      python
      ruby
      rvm
      scala
    ]

    def self.store_stats(request, publisher=KeenPublisher)
      new(request, publisher).store_stats
    end

    def initialize(request, publisher)
      @request = request
      @publisher = publisher
      @keen_payload = {}
    end

    def store_stats
      set_basic_info
{'fraction_non_alphanumeric': 0.061875, 'fraction_numerical': 0.0, 'mean_word_length': 2.157790927021696, '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': '752597', 'n_tokens_mistral': 527, 'n_tokens_neox': 490, 'n_words': 121}