import { GoogleAnalyticsEvent } from '../../domain/google-analytics' type DataLayerPushEvent = | GoogleAnalyticsEvent | { url?: string trigger?: string phone_number?: string businessUnit?: string method?: string } export function dataLayerPush(event: DataLayerPushEvent) { window.dataLayer = window.dataLayer || [] if (!window.Didomi) window.dataLayer.push(event) else { window.didomiOnReady = window.didomiOnReady || [] window.didomiOnReady.push((Didomi: Didomi) => { const canSendEvents = Didomi.getUserConsentStatusForVendor('google') if (canSendEvents) window.dataLayer.push(event) }) } }