import type {EventParamType} from '../../../cta/cta.type' import {sendRavenAppEvent} from '../../../cta/ctaEvent' import {resolveProp} from '../../screens/NudgeScreen/utils/StringUtils' import type { AnalyticsEventActionProps, DynamicArray, } from './ActionType.interface' export function triggerAnalyticsEventAction( props: AnalyticsEventActionProps, context: Record, ) { const resolvedProps = resolveDynamicEventProperties( props.params.eventParams, context, ) sendRavenAppEvent(props.params.eventName, resolvedProps) } export function resolveDynamicEventProperties( eventParams: DynamicArray[], context: Record, ): Record { const resolveParam: Record = {} eventParams.forEach((eventParam) => { resolveParam[eventParam.name] = resolveProp( eventParam.value, context, eventParam.type, ) }) return resolveParam }