From ddff14bf9867661c30ef0ad593d88143b478163e Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 14 Mar 2024 09:58:25 +0100 Subject: [PATCH] Synchronise ratio between demo and header ads --- docs/src/modules/components/Ad.js | 3 ++- docs/src/modules/components/AdDisplay.js | 3 ++- docs/src/modules/constants.js | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/src/modules/components/Ad.js b/docs/src/modules/components/Ad.js index 0e910aa6614d4d..a1a9ad51e33211 100644 --- a/docs/src/modules/components/Ad.js +++ b/docs/src/modules/components/Ad.js @@ -5,6 +5,7 @@ import Box from '@mui/material/Box'; import Paper from '@mui/material/Paper'; import AdCarbon from 'docs/src/modules/components/AdCarbon'; import AdInHouse from 'docs/src/modules/components/AdInHouse'; +import { GA_ADS_DISPLAY_RATIO } from 'docs/src/modules/constants'; import { AdContext, adShape } from 'docs/src/modules/components/AdManager'; import { useTranslate } from '@mui/docs/i18n'; @@ -197,7 +198,7 @@ export default function Ad() { React.useEffect(() => { // Avoid an exceed on the Google Analytics quotas. - if (Math.random() < 0.9 || !eventLabel) { + if (Math.random() > GA_ADS_DISPLAY_RATIO || !eventLabel) { return undefined; } diff --git a/docs/src/modules/components/AdDisplay.js b/docs/src/modules/components/AdDisplay.js index 68ac50be3e0154..e31003bd3225de 100644 --- a/docs/src/modules/components/AdDisplay.js +++ b/docs/src/modules/components/AdDisplay.js @@ -2,6 +2,7 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import { styled } from '@mui/material/styles'; import { adShape } from 'docs/src/modules/components/AdManager'; +import { GA_ADS_DISPLAY_RATIO } from 'docs/src/modules/constants'; import { adStylesObject } from 'docs/src/modules/components/ad.styles'; const Root = styled('span', { shouldForwardProp: (prop) => prop !== 'shape' })(({ @@ -25,7 +26,7 @@ export default function AdDisplay(props) { React.useEffect(() => { // Avoid an exceed on the Google Analytics quotas. - if (Math.random() < 0.9 || !ad.label) { + if (Math.random() > GA_ADS_DISPLAY_RATIO || !ad.label) { return; } diff --git a/docs/src/modules/constants.js b/docs/src/modules/constants.js index 7e5a49edcd5a32..527946179861bd 100644 --- a/docs/src/modules/constants.js +++ b/docs/src/modules/constants.js @@ -17,8 +17,12 @@ const LANGUAGES_LABEL = [ }, ]; +// The ratio of ads display sending event to Google Analytics +const GA_ADS_DISPLAY_RATIO = 0.1; + module.exports = { CODE_VARIANTS, LANGUAGES_LABEL, CODE_STYLING, + GA_ADS_DISPLAY_RATIO, };