# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/agent/telemetry/input_analysis_event'

module Contrast
  module Agent
    module Telemetry
      # Event to report all gather information from the Input Analysis Cache statistics, hits and misses.
      class InputAnalysisCacheEvent < Contrast::Agent::Telemetry::InputAnalysisEvent
        NAME = 'InputAnalysis cache event'
        PATH = '/protect_input_analysis_cache'

        private

        # Creates the tags for the event
        #
        # @param rule_id [String]
        # @param match_rates [Contrast::Agent::Protect::Rule::InputClassification::MatchRates]
        def add_tags rule_id, match_rates
          super(rule_id, match_rates)
          @tags['score_level'] = match_rates&.score_level.dup&.to_s || NOT_APPLICABLE
        end
      end
    end
  end
end