refactor ad code and dont show ads on embeds (#290)

This commit is contained in:
mayeaux 2021-11-15 16:01:42 +01:00 committed by GitHub
parent f084288ac9
commit 6546eaeb63
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View file

@ -51,7 +51,7 @@ const hitsAtFiftyPercentChance = hitsFiftyPercent();
* @param allowPreRoll
* @param player
*/
function runAds(internalFeatureEnabled, allowPreRoll, player) {
function runAds(internalFeatureEnabled, allowPreRoll, player, embedded) {
// current timestamp for vpaid
const timestamp = new Date().toISOString();
@ -83,7 +83,7 @@ function runAds(internalFeatureEnabled, allowPreRoll, player) {
// always have ads on if internal feature is on,
// otherwise if not authed, roll for 20% to see an ad
// allowPreRoll currently means unauthenticated (don't show to logged in users)
const shouldShowAnAd = internalFeatureEnabled || (allowPreRoll && hitsAtFiftyPercentChance);
const shouldShowAnAd = internalFeatureEnabled || (!embedded && allowPreRoll && hitsAtFiftyPercentChance);
if (shouldShowAnAd && browserIsChrome && !IS_MOBILE) {
// fire up ima integration via module

View file

@ -183,7 +183,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
// this seems like a weird thing to have to check for here
if (!player) return;
runAds(internalFeatureEnabled, allowPreRoll, player);
runAds(internalFeatureEnabled, allowPreRoll, player, embedded);
initializeEvents();

View file

@ -470,7 +470,7 @@ function VideoViewer(props: Props) {
autoplaySetting={autoplayNext}
claimId={claimId}
userId={userId}
allowPreRoll={!authenticated} // used to not include embeds, removed for now
allowPreRoll={!authenticated} // TODO: pull this into ads functionality so it's self contained
internalFeatureEnabled={internalFeature}
shareTelemetry={shareTelemetry}
replay={replay}