(ampElement)
| 149 | * @return {boolean} whether reporting is enabled for this element |
| 150 | */ |
| 151 | export function isReportingEnabled(ampElement) { |
| 152 | // Carve-outs: We only want to enable profiling pingbacks when: |
| 153 | // - The ad is from one of the Google networks (AdSense or Doubleclick). |
| 154 | // - The ad slot is in the A4A-vs-3p amp-ad control branch (either via |
| 155 | // internal, client-side selection or via external, Google Search |
| 156 | // selection). |
| 157 | // - We haven't turned off profiling via the rate controls in |
| 158 | // build-system/global-config/{canary,prod}-config.json |
| 159 | // If any of those fail, we use the `BaseLifecycleReporter`, which is a |
| 160 | // a no-op (sends no pings). |
| 161 | const type = ampElement.element.getAttribute('type'); |
| 162 | const {win} = ampElement; |
| 163 | // In local dev mode, neither the canary nor prod config files is available, |
| 164 | // so manually set the profiling rate, for testing/dev. |
| 165 | if (getMode(ampElement.win).localDev && !getMode(ampElement.win).test) { |
| 166 | toggleExperiment(win, 'a4aProfilingRate', true, true); |
| 167 | } |
| 168 | return ( |
| 169 | (type == 'doubleclick' || type == 'adsense') && |
| 170 | isExperimentOn(win, 'a4aProfilingRate') |
| 171 | ); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Has side-effect of incrementing ifi counter on window. |
no test coverage detected