Skip to content

Commit

Permalink
Synchronise ratio between demo and header ads
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Mar 14, 2024
1 parent b8bb039 commit ddff14b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/src/modules/components/Ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion docs/src/modules/components/AdDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' })(({
Expand All @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions docs/src/modules/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

0 comments on commit ddff14b

Please sign in to comment.