import { isIosAgentName , isRumAgentName , isJavaAgentName , OPEN_TELEMETRY_AGENT_NAMES , } from '../../../../common/agent_name' ; import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent' ; import defaultIcon from '../span_icon/icons/default.svg' ; import dotNetIcon from './icons/dot-net.svg' ; import erlangIcon from './icons/erlang.svg' ; import goIcon from './icons/go.svg' ; import iosIcon from './icons/ios.svg' ; import darkIosIcon from './icons/ios_dark.svg' ; import javaIcon from './icons/java.svg' ; import lambdaIcon from './icons/lambda.svg' ; import nodeJsIcon from './icons/nodejs.svg' ; import ocamlIcon from './icons/ocaml.svg' ; import openTelemetryIcon from './icons/opentelemetry.svg' ; import phpIcon from './icons/php.svg' ; import pythonIcon from './icons/python.svg' ; import rubyIcon from './icons/ruby.svg' ; import rumJsIcon from './icons/rumjs.svg' ; import darkPhpIcon from './icons/php_dark.svg' ; import darkRumJsIcon from './icons/rumjs_dark.svg' ; import rustIcon from './icons/rust.svg' ; import darkRustIcon from './icons/rust_dark.svg' ; const agentIcons = { dotnet : dotNetIcon , erlang : erlangIcon , go : goIcon , ios : iosIcon , java : javaIcon , lambda : lambdaIcon , nodejs : nodeJsIcon , ocaml : ocamlIcon , opentelemetry : openTelemetryIcon , php : phpIcon , python : pythonIcon , ruby : rubyIcon , rum : rumJsIcon , rust : rustIcon , } ; const darkAgentIcons = { ... agentIcons , ios : darkIosIcon , php : darkPhpIcon , rum : darkRumJsIcon , rust : darkRustIcon , } ; export function getAgentIconKey ( agentName ) { const lowercasedAgentName = agentName . toLowerCase ( ) ; if ( isRumAgentName ( lowercasedAgentName ) ) { return 'rum' ; } if ( isJavaAgentName ( lowercasedAgentName ) ) { return 'java' ; } if ( isIosAgentName ( lowercasedAgentName ) ) { return 'ios' ; } const agentNameWithoutPrefix = lowercasedAgentName . replace ( /^opentelemetry\// , '' ) ; if ( Object . keys ( agentIcons ) . includes ( agentNameWithoutPrefix ) ) { return agentNameWithoutPrefix ; } if ( OPEN_TELEMETRY_AGENT_NAMES . includes ( lowercasedAgentName as AgentName ) ) { return 'opentelemetry' ; } } export function getAgentIcon ( agentName , isDarkMode ) { const key = agentName && getAgentIconKey ( agentName ) ; if ( ! key ) { return defaultIcon ; } return ( isDarkMode ? darkAgentIcons [ key ] : agentIcons [ key ] ) ?? defaultIcon ; }