From d8489e36654ec30251679c558135d9be0123b793 Mon Sep 17 00:00:00 2001 From: Andrew Sotiriou Date: Tue, 7 May 2024 12:54:45 -0400 Subject: [PATCH 1/2] Remove function --- src/Bling.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Bling.js b/src/Bling.js index dfbdbc4..674d4b2 100644 --- a/src/Bling.js +++ b/src/Bling.js @@ -4,9 +4,8 @@ import PropTypes from "prop-types"; import {debounce} from "throttle-debounce"; import invariant from "invariant"; import deepEqual from "deep-equal"; -import hoistStatics from "hoist-non-react-statics"; import {Events, filterProps} from "./oneFile"; -import {createManager, pubadsAPI} from "./createManager"; +import {createManager} from "./createManager"; /** * An Ad Component using Google Publisher Tags. * This component should work standalone w/o context. @@ -853,13 +852,4 @@ class Bling extends React.Component { reject: null }); } -} - -// proxy pubads API through Bling -export default hoistStatics( - Bling, - pubadsAPI.reduce((api, method) => { - api[method] = (...args) => Bling._adManager.pubadsProxy({method, args}); - return api; - }, {}) -); +} \ No newline at end of file From e3ff4767973fba877d929f0b52b6a77f6c3879df Mon Sep 17 00:00:00 2001 From: Andrew Sotiriou Date: Tue, 7 May 2024 13:45:07 -0400 Subject: [PATCH 2/2] remove test mode --- src/Bling.js | 14 ++++++++++++-- src/createManager.js | 36 ------------------------------------ 2 files changed, 12 insertions(+), 38 deletions(-) diff --git a/src/Bling.js b/src/Bling.js index 674d4b2..dfbdbc4 100644 --- a/src/Bling.js +++ b/src/Bling.js @@ -4,8 +4,9 @@ import PropTypes from "prop-types"; import {debounce} from "throttle-debounce"; import invariant from "invariant"; import deepEqual from "deep-equal"; +import hoistStatics from "hoist-non-react-statics"; import {Events, filterProps} from "./oneFile"; -import {createManager} from "./createManager"; +import {createManager, pubadsAPI} from "./createManager"; /** * An Ad Component using Google Publisher Tags. * This component should work standalone w/o context. @@ -852,4 +853,13 @@ class Bling extends React.Component { reject: null }); } -} \ No newline at end of file +} + +// proxy pubads API through Bling +export default hoistStatics( + Bling, + pubadsAPI.reduce((api, method) => { + api[method] = (...args) => Bling._adManager.pubadsProxy({method, args}); + return api; + }, {}) +); diff --git a/src/createManager.js b/src/createManager.js index fe0e9a6..42d1dd5 100644 --- a/src/createManager.js +++ b/src/createManager.js @@ -43,10 +43,6 @@ export const APIToCallBeforeServiceEnabled = [ export class AdManager extends EventEmitter { constructor(config = {}) { super(config); - - if (config.test) { - this.testMode = config; - } } _config = { @@ -62,8 +58,6 @@ export class AdManager extends EventEmitter { _syncCorrelator = false; - _testMode = false; - get googletag() { return this._googletag; } @@ -84,27 +78,6 @@ export class AdManager extends EventEmitter { return this.googletag && this.googletag.pubadsReady; } - get testMode() { - return this._testMode; - } - - set testMode(config) { - if (process.env.NODE_ENV === "production") { - return; - } - const {test, GPTMock} = config; - this._isLoaded = true; - this._testMode = !!test; - - if (test) { - invariant( - test && GPTMock, - "Must provide GPTMock to enable testMode. config{GPTMock}" - ); - this._googletag = new GPTMock(config); - } - } - _processPubadsQueue() { if (this._pubadsProxyQueue) { Object.keys(this._pubadsProxyQueue).forEach(method => { @@ -159,10 +132,6 @@ export class AdManager extends EventEmitter { instance.foldCheck(event); } }); - - if (this.testMode) { - this._getTimer(); - } }); _getTimer() { @@ -488,11 +457,6 @@ export class AdManager extends EventEmitter { return ( this._loadPromise || (this._loadPromise = new Promise((resolve, reject) => { - // test mode can't be enabled in production mode - if (this.testMode) { - resolve(this.googletag); - return; - } if (!canUseDOM) { reject(new Error("DOM not available")); return;