www/category-category-module-es5.js
/**
     * Wraps a standard gtag function with extra code to wait for completion of
     * relevant initialization promises before sending requests.
     *
     * @param gtagCore Basic gtag function that just appends to dataLayer
     * @param initializedIdPromisesMap Map of gaIds to their initialization promises
     */
Wraps a standard gtag function with extra code to wait for completion of
relevant initialization promises before sending requests.

@param gtagCore Basic gtag function that just appends to dataLayer
@param initializedIdPromisesMap Map of gaIds to their initialization promises
Wraps a standard gtag function with extra code to wait for completion of relevant initialization promises before sending requests . @param gtagCore Basic gtag function that just appends to dataLayer @param initializedIdPromisesMap Map of gaIds to their initialization promises
function wrapGtag(gtagCore, initializedIdPromisesMap) {
      return function (command, idOrNameOrParams, gtagParams) {
        if (command === GtagCommand.EVENT) {
          var initializationPromisesToWaitFor = []; 
          if (gtagParams && gtagParams['send_to']) {
            var gaSendToList = gtagParams['send_to']; 
            if (!Array.isArray(gaSendToList)) {
              gaSendToList = [gaSendToList];
            }
            for (var _i = 0, gaSendToList_1 = gaSendToList; _i < gaSendToList_1.length; _i++) {
              var sendToId = gaSendToList_1[_i];
              var initializationPromise = initializedIdPromisesMap[sendToId]; 
              if (initializationPromise) {
                initializationPromisesToWaitFor.push(initializationPromise);
              } else {
                initializationPromisesToWaitFor = [];
                break;
              }
            }
          } 
          if (initializationPromisesToWaitFor.length === 0) {
            for (var _a = 0, _b = Object.values(initializedIdPromisesMap); _a < _b.length; _a++) {
              var idPromise = _b[_a];
              initializationPromisesToWaitFor.push(idPromise);
            }
          } 
          Promise.all(initializationPromisesToWaitFor) 
          .then(function () {
            return gtagCore(GtagCommand.EVENT, idOrNameOrParams, gtagParams || {});
          }).catch(function (e) {
            return logger.error(e);
          });
        } else if (command === GtagCommand.CONFIG) {
          var initializationPromiseToWait = initializedIdPromisesMap[idOrNameOrParams] || Promise.resolve();
          initializationPromiseToWait.then(function () {
            gtagCore(GtagCommand.CONFIG, idOrNameOrParams, gtagParams);
          }).catch(function (e) {
            return logger.error(e);
          });
        } else {
          gtagCore(GtagCommand.SET, idOrNameOrParams);
        }
      };
    }
function wrapGtag ( gtagCore , initializedIdPromisesMap ) { return function ( command , idOrNameOrParams , gtagParams ) { if ( command === GtagCommand . EVENT ) { var initializationPromisesToWaitFor = [ ] ; if ( gtagParams && gtagParams [ 'send_to' ] ) { var gaSendToList = gtagParams [ 'send_to' ] ; if ( ! Array . isArray ( gaSendToList ) ) { gaSendToList = [ gaSendToList ] ; } for ( var _i = 0 , gaSendToList_1 = gaSendToList ; _i < gaSendToList_1 . length ; _i ++ ) { var sendToId = gaSendToList_1 [ _i ] ; var initializationPromise = initializedIdPromisesMap [ sendToId ] ; if ( initializationPromise ) { initializationPromisesToWaitFor . push ( initializationPromise ) ; } else { initializationPromisesToWaitFor = [ ] ; break ; } } } if ( initializationPromisesToWaitFor . length === 0 ) { for ( var _a = 0 , _b = Object . values ( initializedIdPromisesMap ) ; _a < _b . length ; _a ++ ) { var idPromise = _b [ _a ] ; initializationPromisesToWaitFor . push ( idPromise ) ; } } Promise . all ( initializationPromisesToWaitFor ) . then ( function ( ) { return gtagCore ( GtagCommand . EVENT , idOrNameOrParams , gtagParams || { } ) ; } ) . catch ( function ( e ) { return logger . error ( e ) ; } ) ; } else if ( command === GtagCommand . CONFIG ) { var initializationPromiseToWait = initializedIdPromisesMap [ idOrNameOrParams ] || Promise . resolve ( ) ; initializationPromiseToWait . then ( function ( ) { gtagCore ( GtagCommand . CONFIG , idOrNameOrParams , gtagParams ) ; } ) . catch ( function ( e ) { return logger . error ( e ) ; } ) ; } else { gtagCore ( GtagCommand . SET , idOrNameOrParams ) ; } } ; }
Wraps a standard gtag function with extra code to wait for completion of
 relevant initialization promises before sending requests.
Wraps a standard gtag function with extra code to wait for completion of relevant initialization promises before sending requests .
// If event, check that relevant initialization promises have completed. // If there's a 'send_to' param, check if any ID specified matches // a FID we have begun a fetch on. // Make it an array if is isn't, so it can be dealt with the same way. // Groups will not be in the map. // There is an item in 'send_to' that is not associated // directly with an FID, possibly a group.  Empty this array // and let it get populated below. // This will be unpopulated if there was no 'send_to' field , or // if not all entries in the 'send_to' field could be mapped to // a FID. In these cases, wait on all pending initialization promises. // Run core gtag function with args after all relevant initialization // promises have been resolved. // Workaround for http://b/141370449 - third argument cannot be undefined. // SET command. // Splitting calls for CONFIG and SET to make it clear which signature // Typescript is checking.