# frozen_string_literal: true module Datadog module Core module Telemetry module V1 # Describes payload for telemetry V1 API app-integrations-change event class AppEvent attr_reader \ :additional_payload, :configuration, :dependencies, :install_signature, :integrations # @param additional_payload [Array] List of Additional payload to track (any key # value not mentioned and doesn't fit under a metric) # @param configuration [Array] List of Tracer related configuration data # @param dependencies [Array] List of all loaded modules requested by the app # @param install_signature [Telemetry::V1::InstallSignature] Install signature data # @param integrations [Array] List of integrations that are available within the app # and applicable to be traced def initialize( additional_payload: nil, configuration: nil, dependencies: nil, install_signature: nil, integrations: nil ) @additional_payload = additional_payload @configuration = configuration @dependencies = dependencies @install_signature = install_signature @integrations = integrations end def to_h {}.tap do |hash| hash[:additional_payload] = map_hash(@additional_payload) if @additional_payload hash[:configuration] = map_hash(@configuration) if @configuration hash[:dependencies] = map_array(@dependencies) if @dependencies hash[:install_signature] = @install_signature.to_h if @install_signature hash[:integrations] = map_array(@integrations) if @integrations end end private def map_hash(hash) hash.map do |k, v| { name: k.to_s, value: v } end end def map_array(arr) arr.map(&:to_h) end end end end end end