Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stripped out all old ad code. #570

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"remark-parse": "^9.0.0",
"remark-rehype": "^8.0.0",
"swr": "^1.0.1",
"tab-ads": "^1.1.24",
"tab-cmp": "^0.15.0-alpha.0",
"unified": "^9.0.0",
"uuid": "^8.3.2"
Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/pages/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@
jest.mock('src/utils/navigation')
jest.mock('src/utils/events')
jest.mock('src/utils/ssr')
jest.mock('src/utils/adHelpers', () => ({
getAdUnits: jest.fn().mockReturnValue({}),
incrementTabsOpenedToday: jest.fn(),
}))
jest.mock('src/utils/localstorage-mgr', () => ({
getItem: jest.fn(),
setItem: jest.fn(),
Expand Down Expand Up @@ -312,7 +308,7 @@
})
})

// it('includes a settings icon link to the account page', () => {

Check warning on line 311 in src/__tests__/pages/index.test.js

View workflow job for this annotation

GitHub Actions / test

Some tests seem to be commented

Check warning on line 311 in src/__tests__/pages/index.test.js

View workflow job for this annotation

GitHub Actions / test

Some tests seem to be commented
// expect.assertions(1)
// const IndexPage = require('src/pages/index').default
// const mockProps = getMockProps()
Expand All @@ -323,7 +319,7 @@
// expect(settingsLink.exists()).toBe(true)
// })

// it('/', () => {

Check warning on line 322 in src/__tests__/pages/index.test.js

View workflow job for this annotation

GitHub Actions / test

Some tests seem to be commented

Check warning on line 322 in src/__tests__/pages/index.test.js

View workflow job for this annotation

GitHub Actions / test

Some tests seem to be commented
// expect.assertions(2)
// const IndexPage = require('src/pages/index').default
// const mockProps = getMockProps()
Expand Down
41 changes: 0 additions & 41 deletions src/pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,6 @@ class CustomDocument extends Document {
<TabCMPHeadElements />
</Head>
<body style={{ margin: 0, padding: 0 }} className="v4">
{/**
* Begin: Ads code.
* See: https://github.com/gladly-team/tab-ads#html-tags
*/}
{/* Google Publisher Tag */}
<script
dangerouslySetInnerHTML={{
__html: `
var googletag = window.googletag || {}
googletag.cmd = googletag.cmd || []
googletag.cmd.push(() => {
googletag.pubads().disableInitialLoad()
googletag.pubads().setTagForChildDirectedTreatment(0)
})
var gads = document.createElement('script')
gads.async = true
gads.type = 'text/javascript'
var useSSL = document.location.protocol === 'https:'
gads.src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js'
var head = document.getElementsByTagName('head')[0]
head.appendChild(gads)
`,
}}
/>
{/* Amazon apstag */}
<script
dangerouslySetInnerHTML={{
__html: `
try {
!function(a9,a,p,s,t,A,g){if(a[a9])return;function q(c,r){a[a9]._Q.push([c,r])}a[a9]={init:function(){q("i",arguments)},fetchBids:function(){q("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]};A=p.createElement(s);A.async=!0;A.src=t;g=p.getElementsByTagName(s)[0];g.parentNode.insertBefore(A,g)}("apstag",window,document,"script","//c.amazon-adsystem.com/aax2/apstag.js");
} catch(e) {
console.error(e)
}
`,
}}
/>
{/**
* End: Ads code.
*/}

{/* Google Analytics V4 Tag */}
<script
async
Expand Down
73 changes: 0 additions & 73 deletions src/utils/__tests__/adHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import {
STORAGE_TABS_LAST_TAB_OPENED_DATE,
STORAGE_TABS_RECENT_DAY_COUNT,
} from '../constants'
import localStorageFeaturesManager from '../localStorageFeaturesManager'

// jest.mock('js/utils/feature-flags')
// jest.mock('js/utils/experiments')
jest.mock('tab-ads')
jest.mock('../localstorage-mgr', () => ({
getItem: jest.fn(),
setItem: jest.fn(),
Expand Down Expand Up @@ -167,74 +165,3 @@ describe('Tab Tracking Methods', () => {
)
})
})

describe('adHelpers: getAdUnits', () => {
it('returns three ads if test returns true and screen large enough', () => {
localStorageFeaturesManager.getFeatureValue.mockReturnValue('true')
const { getAdUnits } = require('../adHelpers')
expect(getAdUnits()).toEqual({
leaderboard: {
// The long leaderboard ad.
adId: 'div-gpt-ad-1464385677836-0',
adUnitId: '/43865596/HBTL',
sizes: [[728, 90]],
},
rectangleAdPrimary: {
// The primary rectangle ad (bottom-right).
adId: 'div-gpt-ad-1464385742501-0',
adUnitId: '/43865596/HBTR',
sizes: [[300, 250]],
},
rectangleAdSecondary: {
// The second rectangle ad (right side, above the first).
adId: 'div-gpt-ad-1539903223131-0',
adUnitId: '/43865596/HBTR2',
sizes: [[300, 250]],
},
})
})
it('returns two ads if test returns true and screen too small', () => {
localStorageFeaturesManager.getFeatureValue.mockReturnValue('true')
window.innerHeight = 400
const { getAdUnits } = require('../adHelpers')
expect(getAdUnits()).toEqual({
leaderboard: {
// The long leaderboard ad.
adId: 'div-gpt-ad-1464385677836-0',
adUnitId: '/43865596/HBTL',
sizes: [[728, 90]],
},
rectangleAdPrimary: {
// The primary rectangle ad (bottom-right).
adId: 'div-gpt-ad-1464385742501-0',
adUnitId: '/43865596/HBTR',
sizes: [[300, 250]],
},
})
})
it('returns three ads if test returns true and window height undefined', () => {
localStorageFeaturesManager.getFeatureValue.mockReturnValue('true')
window.innerHeight = undefined
const { getAdUnits } = require('../adHelpers')
expect(getAdUnits()).toEqual({
leaderboard: {
// The long leaderboard ad.
adId: 'div-gpt-ad-1464385677836-0',
adUnitId: '/43865596/HBTL',
sizes: [[728, 90]],
},
rectangleAdPrimary: {
// The primary rectangle ad (bottom-right).
adId: 'div-gpt-ad-1464385742501-0',
adUnitId: '/43865596/HBTR',
sizes: [[300, 250]],
},
rectangleAdSecondary: {
// The second rectangle ad (right side, above the first).
adId: 'div-gpt-ad-1539903223131-0',
adUnitId: '/43865596/HBTR2',
sizes: [[300, 250]],
},
})
})
})
53 changes: 0 additions & 53 deletions src/utils/adHelpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* globals window */

import { getAvailableAdUnits } from 'tab-ads'
import ensureValuesAreDefined from 'src/utils/ensureValuesAreDefined'
import moment from 'moment'
import localStorageMgr from './localstorage-mgr'
Expand All @@ -22,8 +19,6 @@ try {
)
}

const DEFAULT_NUMBER_OF_ADS = 2

/**
* Get the count of tabs opened today (UTC day) from localStorage. If no
* value exists in storage, return zero.
Expand Down Expand Up @@ -127,54 +122,6 @@ export const incrementTabsOpenedToday = () => {
}
}

// TODO: implement
/**
* Determine if we should show only one ad. We'll show one ad to
* users for the first X hours after they join.
* @return {Boolean} Whether to show one ad.
*/
const shouldShowOneAd = () => false

/**
* Determine if we should show three ads based on screen size.
* @return {Boolean} Whether to show one ad.
*/
const shouldShowThreeAds = () => !window.innerHeight || window.innerHeight > 700

/**
* Return an object of ad units we should display. This returns ad units
* even if ads are disabled.
* @return {Object} AdUnitsInfo
* @return {Object|null} AdUnitsInfo.leaderboard - a tab-ads ad unit
* definition for the 728x90 ad, or null if we shouldn't show that
* ad unit
* @return {Object|null} AdUnitsInfo.rectangleAdPrimary - a tab-ads
* ad unit definition for the first 300x250 ad, or null if we
* shouldn't show that ad unit
* @return {Object|null} AdUnitsInfo.rectangleAdSecondary - a tab-ads
* ad unit definition for the second 300x250 ad, or null if we
* shouldn't show that ad unit
*/
export const getAdUnits = () => {
let numberOfAdsToShow
if (hasUserReachedMaxTabsToday()) {
numberOfAdsToShow = 0
} else if (shouldShowOneAd()) {
numberOfAdsToShow = 1
} else if (shouldShowThreeAds()) {
numberOfAdsToShow = 3
} else {
numberOfAdsToShow = DEFAULT_NUMBER_OF_ADS
}
const { leaderboard, rectangleAdPrimary, rectangleAdSecondary } =
getAvailableAdUnits()
return {
...(numberOfAdsToShow > 0 && { leaderboard }),
...(numberOfAdsToShow > 1 && { rectangleAdPrimary }),
...(numberOfAdsToShow > 2 && { rectangleAdSecondary }),
}
}

/**
* Determine if we should fetch and display ads. Ads are disabled
* by env variable or if the user views a lot of ads in a single day.
Expand Down
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15315,13 +15315,6 @@ synchronous-promise@^2.0.15:
resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.16.tgz#669b75e86b4295fdcc1bb0498de9ac1af6fd51a9"
integrity sha512-qImOD23aDfnIDNqlG1NOehdB9IYsn1V9oByPjKY1nakv2MQYCEMyX033/q+aEtYCpmYK1cv2+NTmlH+ra6GA5A==

tab-ads@^1.1.24:
version "1.1.24"
resolved "https://registry.yarnpkg.com/tab-ads/-/tab-ads-1.1.24.tgz#11ed0dc5ea991f8239a1f2040f01eada44937998"
integrity sha512-xQqLIlGfQ6T7BxQj730L2arM+dQqUHYqtm52z9M0bykeo4C5hwkqXtu5cLYSp2ff4rdHw+tj7w6z/gDJUjM92w==
dependencies:
lodash "^4.17.21"

tab-cmp@^0.15.0-alpha.0:
version "0.15.0-alpha.0"
resolved "https://registry.yarnpkg.com/tab-cmp/-/tab-cmp-0.15.0-alpha.0.tgz#b16c609c0a6f9d80d98fbb34f7773de0ce2f2c69"
Expand Down
Loading