MCPcopy Create free account
hub / github.com/ampproject/amphtml / isReportingEnabled

Function isReportingEnabled

ads/google/a4a/utils.js:151–172  ·  view source on GitHub ↗
(ampElement)

Source from the content-addressed store, hash-verified

149 * @return {boolean} whether reporting is enabled for this element
150 */
151export 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.

Callers 2

onCreativeRenderMethod · 0.90
onCreativeRenderMethod · 0.90

Calls 4

getModeFunction · 0.90
toggleExperimentFunction · 0.85
getAttributeMethod · 0.80
isExperimentOnFunction · 0.50

Tested by

no test coverage detected