Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/modules/components/AdCarbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export function AdCarbonInline(props) {
name: ad.company,
description: `<strong>${ad.company}</strong> - ${ad.description}`,
poweredby: 'Carbon',
label: 'carbon-demo-inline',
}}
/>
</React.Fragment>
Expand Down
12 changes: 12 additions & 0 deletions docs/src/modules/components/AdDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ const Root = styled('span', { shouldForwardProp: (prop) => prop !== 'shape' })((
export default function AdDisplay(props) {
const { ad, className, shape = 'auto' } = props;

React.useEffect(() => {
// Avoid an exceed on the Google Analytics quotas.
if (Math.random() < 0.9 || !ad.label) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain more what's this for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about which aspect is unclear.

The early return is just a way to send only 10% of the ads display event to Goggle Analitics. A similar approach is used for top page ads

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a commit to make sure this ratio is consistent between all ads


window.gtag('event', 'ad', {
eventAction: 'display',
eventLabel: ad.label,
});
}, [ad.label]);

/* eslint-disable material-ui/no-hardcoded-labels, react/no-danger */
return (
<Root shape={shape === 'inline' ? 'inline' : adShape} className={className}>
Expand Down