function commercialMetrics()

in dotcom-rendering/src/components/Metrics.importable.tsx [136:170]


		function commercialMetrics() {
			// Only send metrics if the switch is enabled
			if (!commercialMetricsEnabled) return;

			if (isUndefined(abTestApi)) return;
			if (isUndefined(adBlockerInUse)) return;
			if (isUndefined(browserId)) return;
			if (isUndefined(isDev)) return;
			if (isUndefined(pageViewId)) return;

			const bypassSampling = shouldBypassSampling(abTestApi);

			// This is a new detection method we are trying, so we want to record it separately to `adBlockerInUse`
			EventTimer.get().setProperty(
				'detectedAdBlocker',
				detectedAdBlocker,
			);

			initCommercialMetrics({
				pageViewId,
				browserId,
				isDev,
				adBlockerInUse,
			})
				.then(() => {
					if (bypassSampling || isDev) {
						void bypassCommercialMetricsSampling();
					}
				})
				.catch((e) =>
					console.error(
						`Error initialising commercial metrics: ${String(e)}`,
					),
				);
		},