import { loadJS } from './loadJS' ; declare global { interface Window { gtag : ( ... args : Array < any > ) => void ; } } const MEASUREMENT_ID = ANALYTICS_TRACKING_ID ; const ENABLE_TRACKING = FLAG_PRODUCTION && document . location . hostname === HOSTNAME_PRODUCTION ; let firstCall = true ; export function analytics ( ... args ) { if ( ENABLE_TRACKING ) { if ( firstCall ) { loadJS ( `https://www.googletagmanager.com/gtag/js?id=${ MEASUREMENT_ID }` ) ; firstCall = false ; } window . gtag ( ... args ) ; } } export function trackView ( params ) { analytics ( 'config' , MEASUREMENT_ID , params ) ; }