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

Merge pull request #569 from PubMatic/UOE-11010 #575

Open
wants to merge 10 commits into
base: UOE-11674
Choose a base branch
from
4 changes: 2 additions & 2 deletions init-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ then
exit 1
fi

OpenWrapNodeModules="${GLOBAL_OPENWRAP_PKG_JSON_DIR_V9_21_0}/node_modules/"
OpenWrapNodeModules="${GLOBAL_OPENWRAP_PKG_JSON_DIR_V9_27_0}/node_modules/"

function prebidNpmInstall() {
echo "This is SymLinking Start"
cd $1


PrebidJSNodeModules="${GLOBAL_PREBID_PKG_JSON_DIR_V9_21_0}/node_modules/"
PrebidJSNodeModules="${GLOBAL_PREBID_PKG_JSON_DIR_V9_27_0}/node_modules/"

symLinkForPrebidNodeModules=node_modules
if [ -L $symLinkForPrebidNodeModules ]; then
Expand Down
7 changes: 5 additions & 2 deletions src_new/adapters/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ function assignCurrencyConfigIfRequired(prebidConfig){
exports.assignCurrencyConfigIfRequired = assignCurrencyConfigIfRequired;

function assignSchainConfigIfRequired(prebidConfig){
if(CONFIG.isSchainEnabled()){
if(CONFIG.isSchainEnabled() && CONFIG.getSchainObject()){
prebidConfig["schain"] = CONFIG.getSchainObject();
}
}
Expand Down Expand Up @@ -1440,7 +1440,7 @@ function initPbjsConfig(){
}
exports.initPbjsConfig = initPbjsConfig;

function fetchBids(activeSlots){
function fetchBids(activeSlots, callback){

var impressionID = util.generateUUID();
// todo:
Expand Down Expand Up @@ -1498,6 +1498,9 @@ function fetchBids(activeSlots){
window[pbNameSpace].setPAAPIConfigForGPT();
};
refThis.pbjsBidsBackHandler(bidResponses, activeSlots);
if(util.isFunction(callback)){
callback(bidResponses);
}
},
timeout: CONFIG.getTimeout() - CONSTANTS.CONFIG.TIMEOUT_ADJUSTMENT
});
Expand Down
2 changes: 1 addition & 1 deletion src_new/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ exports.getCCPATimeout = function () {
};

exports.getSchainObject = function () {
return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.SCHAINOBJECT] || {};
return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.SCHAINOBJECT] || null;
};

exports.isSchainEnabled = function () {
Expand Down
53 changes: 18 additions & 35 deletions src_new/controllers/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,43 +263,26 @@ function origCustomServerExposedAPI(arrayOfAdUnits, callbackFunction){
}

// new approach without adapter-managers
prebid.fetchBids(qualifyingSlots);

var posTimeoutTime = Date.now() + CONFIG.getTimeout(); // post timeout condition
var intervalId = window.setInterval(function() {
// todo: can we move this code to a function?
if (bidManager.getAllPartnersBidStatuses(window.PWT.bidMap, qualifyingSlotDivIds) || Date.now() >= posTimeoutTime) {

clearInterval(intervalId);
// removeIf(removeLegacyAnalyticsRelatedCode)
if(isPrebidPubMaticAnalyticsEnabled === false){
// after some time call fire the analytics pixel
setTimeout(function() {
bidManager.executeAnalyticsPixel();
}, 2000);
}
// endRemoveIf(removeLegacyAnalyticsRelatedCode)

var winningBids = {}; // object:: { code : response bid or just key value pairs }
// we should loop on qualifyingSlotDivIds to avoid confusion if two parallel calls are fired to our PWT.requestBids
util.forEachOnArray(qualifyingSlotDivIds, function(index, divId) {
var code = mapOfDivToCode[divId];
winningBids[code] = refThis.findWinningBidAndGenerateTargeting(divId);
// we need to delay the realignment as we need to do it post creative rendering :)
// delaying by 1000ms as creative rendering may tke time
setTimeout(util.realignVLogInfoPanel, 1000, divId);
});
prebid.fetchBids(qualifyingSlots, function(){
var winningBids = {}; // object:: { code : response bid or just key value pairs }
// we should loop on qualifyingSlotDivIds to avoid confusion if two parallel calls are fired to our PWT.requestBids
util.forEachOnArray(qualifyingSlotDivIds, function(index, divId) {
var code = mapOfDivToCode[divId];
winningBids[code] = refThis.findWinningBidAndGenerateTargeting(divId);
// we need to delay the realignment as we need to do it post creative rendering :)
// delaying by 1000ms as creative rendering may tke time
setTimeout(util.realignVLogInfoPanel, 1000, divId);
});

// for each adUnit in arrayOfAdUnits find the winningBids, we need to return this updated arrayOfAdUnits
util.forEachOnArray(arrayOfAdUnits, function(index, anAdUnitObject) {
if (winningBids.hasOwnProperty(anAdUnitObject.code)) {
anAdUnitObject.bidData = winningBids[anAdUnitObject.code];
}
});
// for each adUnit in arrayOfAdUnits find the winningBids, we need to return this updated arrayOfAdUnits
util.forEachOnArray(arrayOfAdUnits, function(index, anAdUnitObject) {
if (winningBids.hasOwnProperty(anAdUnitObject.code)) {
anAdUnitObject.bidData = winningBids[anAdUnitObject.code];
}
});

callbackFunction(arrayOfAdUnits);
}
}, 10); // check every 10 milliseconds if we have all bids or timeout has been happened.
callbackFunction(arrayOfAdUnits);
});
}

/* start-test-block */
Expand Down
4 changes: 4 additions & 0 deletions src_new/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,10 @@ exports.getAdUnitConfig = function(sizes, currentSlot){
mediaTypeObject["banner"] = {
sizes: sizes
};
var bannerConfig = (config && config.banner && config.banner.config) || {};
Object.keys(bannerConfig).map(function(configKey) {
mediaTypeObject["banner"][configKey] = bannerConfig[configKey];
});
refThis.mediaTypeConfig[divId] = mediaTypeObject;
adUnitConfig['mediaTypeObject'] = mediaTypeObject
return adUnitConfig;
Expand Down
4 changes: 2 additions & 2 deletions test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,9 @@ describe('Config', function() {
done();
});

it('should return empty object if config is not present',function(done){
it('should return undefined if schain config is not present',function(done){
delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.SCHAINOBJECT];
CONFIG.getSchainObject().should.be.deep.equal({});
expect(CONFIG.getSchainObject()).to.equal(null);
done();
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/custom.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ describe("CONTROLLER: CUSTOM", function() {
done();
});

it("it should call addpter-manager", function(done){
xit("it should call addpter-manager", function(done){
sinon.stub(PREBID, "fetchBids", function(){});
sinon.stub(CONFIG, "getTimeout");
CONFIG.getTimeout.returns(10);
Expand All @@ -506,7 +506,7 @@ describe("CONTROLLER: CUSTOM", function() {
}, 200);
});

it("should call the callback postimeout if allBid status is false ecverytime",function(done){
xit("should call the callback postimeout if allBid status is false ecverytime",function(done){
sinon.stub(BM,"getAllPartnersBidStatuses").returns(false);
sinon.stub(PREBID, "fetchBids", function(){});
sinon.stub(CONFIG, "getTimeout");
Expand Down
13 changes: 13 additions & 0 deletions test/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3073,6 +3073,19 @@ describe('UTIL', function() {
expect(result.should.deep.equal(expectedResult));
done();
});

it('should return proper pos value', function(done){
currentSlot.getDivID.restore();
// DivId settings not registered in MediaConfiguration
sinon.stub(currentSlot, "getDivID").returns("div_pos");
commonDivID="div_pos";
var expectedResult = {"banner":{"sizes":[[300,250]], pos: 5}};
// initializing invalid regex key and respective expression
slotConfiguration.config = {default: {banner : {enabled:true, config:{pos: 5}}}};
var result = UTIL.getAdUnitConfig(sizes, currentSlot).mediaTypeObject;
expect(result.should.deep.equal(expectedResult));
done();
});
});

describe('#addEventListenerForClass', function() {
Expand Down