UNPKG

video-ad-sdk

Version:

VAST/VPAID SDK that allows video ads to be played on top of any player

24 lines (20 loc) 646 B
import {getLinearTrackingEvents} from '../../../vastSelectors' import type { VastChain, VastResponse, VastTrackingEvent, ParsedAd } from '../../../types' import {linearEvents} from '../../../tracker' const {progress} = linearEvents export const getProgressEvents = (vastChain: VastChain): VastTrackingEvent[] => vastChain .map(({ad}: VastResponse) => ad) .reduce((accumulated: VastTrackingEvent[], ad?: ParsedAd) => { const events = (ad && getLinearTrackingEvents(ad, progress)) || [] return [...accumulated, ...events] }, []) .map(({offset, uri}: VastTrackingEvent) => ({ offset, uri }))