lighthouse-plugin-publisher-ads/computed/ad-lantern-metric.js
/**
 * Inserts edges between bid requests and ad requests.
 * @param {BaseNode} graph
 */
Inserts edges between bid requests and ad requests.
Inserts edges between bid requests and ad requests .
function addEdges(graph) {
   const adRequestNodes = [];
   const gptJsNodes = [];
  graph.traverse((node) => {
    if (node.type !== BaseNode.TYPES.NETWORK) {
      return;
    }
    if (isGptTag(node.record.url) && node.record.resourceType === 'Script') {
      gptJsNodes.push(node);
    } else if (isGptAdRequest(node.record)) {
      adRequestNodes.push(node);
    }
  });
  graph.traverse((node) => {
    if (node.type !== BaseNode.TYPES.NETWORK) {
      return;
    }
    if (isGptImplTag(node.record.url)) {
      const gptImplNode = node;
      for (const gptJsNode of gptJsNodes) {
        addEdge(gptJsNode, gptImplNode);
      }
    }
    if (isBidRelatedRequest(node.record)) {
      const bidNode = node;
      for (const adNode of adRequestNodes) {
        addEdge(bidNode, adNode);
      }
    }
    if (isImpressionPing(node.record.url)) {
      const impressionNode = node;
      for (const adNode of adRequestNodes) {
        addEdge(adNode, impressionNode);
        for (const dependent of adNode.getDependents()) {
          addEdge(dependent, impressionNode);
        }
      }
    }
  });
}
function addEdges ( graph ) { const adRequestNodes = [ ] ; const gptJsNodes = [ ] ; graph . traverse ( ( node ) => { if ( node . type !== BaseNode . TYPES . NETWORK ) { return ; } if ( isGptTag ( node . record . url ) && node . record . resourceType === 'Script' ) { gptJsNodes . push ( node ) ; } else if ( isGptAdRequest ( node . record ) ) { adRequestNodes . push ( node ) ; } } ) ; graph . traverse ( ( node ) => { if ( node . type !== BaseNode . TYPES . NETWORK ) { return ; } if ( isGptImplTag ( node . record . url ) ) { const gptImplNode = node ; for ( const gptJsNode of gptJsNodes ) { addEdge ( gptJsNode , gptImplNode ) ; } } if ( isBidRelatedRequest ( node . record ) ) { const bidNode = node ; for ( const adNode of adRequestNodes ) { addEdge ( bidNode , adNode ) ; } } if ( isImpressionPing ( node . record . url ) ) { const impressionNode = node ; for ( const adNode of adRequestNodes ) { addEdge ( adNode , impressionNode ) ; for ( const dependent of adNode . getDependents ( ) ) { addEdge ( dependent , impressionNode ) ; } } } } ) ; }
Inserts edges between bid requests and ad requests.
Inserts edges between bid requests and ad requests .
/** @type {NetworkNode[]} */ /** @type {NetworkNode[]} */