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

Gpp phase 1 sync #546

Merged
merged 10 commits into from
Aug 13, 2024
4 changes: 4 additions & 0 deletions init-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ then
exit 1
fi


OpenWrapNodeModules="${GLOBAL_OPENWRAP_PKG_JSON_DIR_V8_52_0}/node_modules/"


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



PrebidJSNodeModules="${GLOBAL_PREBID_PKG_JSON_DIR_V8_52_0}/node_modules/"


symLinkForPrebidNodeModules=node_modules
if [ -L $symLinkForPrebidNodeModules ]; then
unlink $symLinkForPrebidNodeModules
Expand Down
11 changes: 11 additions & 0 deletions src_new/adapters/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ var BID = require("../bid.js");
var util = require("../util.js");
var bidManager = require("../bidManager.js");
var CONF = require("../conf.js");

var COMMON_CONFIG = require("../common.config.js");


var parentAdapterID = CONSTANTS.COMMON.PARENT_ADAPTER_PREBID;

var pbNameSpace = /*CONFIG.isIdentityOnly() ? CONSTANTS.COMMON.IH_NAMESPACE : */ CONSTANTS.COMMON.PREBID_NAMESPACE;
Expand Down Expand Up @@ -857,6 +859,14 @@ function assignCcpaConfigIfRequired(prebidConfig){

exports.assignCcpaConfigIfRequired = assignCcpaConfigIfRequired;

function assignGppConfigIfRequired(prebidConfig) {
if (CONFIG.getGppConsent()) {
prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout());
}
}

exports.assignGppConfigIfRequired = assignGppConfigIfRequired;

function assignCurrencyConfigIfRequired(prebidConfig){
if(CONFIG.getAdServerCurrency()){
// get AdServer currency from Config
Expand Down Expand Up @@ -1042,6 +1052,7 @@ function setPrebidConfig(){
refThis.assignUserSyncConfig(prebidConfig);
refThis.assignGdprConfigIfRequired(prebidConfig);
refThis.assignCcpaConfigIfRequired(prebidConfig);
refThis.assignGppConfigIfRequired(prebidConfig);
refThis.assignCurrencyConfigIfRequired(prebidConfig);
refThis.assignSchainConfigIfRequired(prebidConfig);
refThis.assignSingleRequestConfigForBidders(prebidConfig);
Expand Down
3 changes: 3 additions & 0 deletions src_new/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ exports.pwt = {
abTestEnabled:"0",
pubAnalyticsAdapter: "0",
reduceCodeSize:1,
gpp: "0",
gppCmpApi: "iab",
gppTimeout: "10000",
pbGlobalVarNamespace: "owpbjs",
owGlobalVarNamespace: "PWT",
localStorageAccess: "1" // Added new field for allow local storage feature
Expand Down
17 changes: 17 additions & 0 deletions src_new/config.idhub.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ exports.getCCPATimeout = function() {
return ccpaTimeout ? window.parseInt(ccpaTimeout) : CONSTANTS.CONFIG.DEFAULT_CCPA_TIMEOUT;
};

// needed
exports.getGppConsent = function () {
var gpp = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] || CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT;
return gpp === "1";
};

// needed
exports.getGppCmpApi = function () {
return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] || CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI;
};

// needed
exports.getGppTimeout = function() {
var gppTimeout = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT];
return gppTimeout ? window.parseInt(gppTimeout) : CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT;
};

exports.getProfileID = function () {
return config.pwt[CONSTANTS.CONFIG.PROFILE_ID] || "0";
};
Expand Down
16 changes: 16 additions & 0 deletions src_new/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,22 @@ exports.getMarketplaceBidders = function(){
return config.pwt.marketplaceBidders ? config.pwt.marketplaceBidders.split(',') : false;
}


exports.getGppConsent = function () {
var gpp = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] || CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT;
return gpp === "1";
};

exports.getGppCmpApi = function () {
return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] || CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI;
};

exports.getGppTimeout = function () {
var gppTimeout = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT];
return gppTimeout ? window.parseInt(gppTimeout) : CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT;
}

exports.shouldClearTargeting = function () {
return window.PWT.shouldClearTargeting !== undefined ? Boolean(window.PWT.shouldClearTargeting) : true;

};
6 changes: 6 additions & 0 deletions src_new/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ exports.CONFIG = {
"TIMEOUT_ADJUSTMENT": 50,
"SSO_ENABLED": "ssoEnabled",
"FLOOR_SOURCE": "floorSource",
"GPP_CONSENT": "gpp",
"GPP_CMPAPI": "gppCmpApi",
"GPP_TIMEOUT": "gppTimeout",
"DEFAULT_GPP_CONSENT": "0",
"DEFAULT_GPP_CMPAPI": "iab",
"DEFAULT_GPP_TIMEOUT": 10000,
"GDPR_ACTION_TIMEOUT": "gdprActionTimeout",
"PB_GLOBAL_VAR_NAMESPACE": "pbGlobalVarNamespace",
"OW_GLOBAL_VAR_NAMESPACE": "owGlobalVarNamespace"
Expand Down
8 changes: 8 additions & 0 deletions src_new/controllers/idhub.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
var CONFIG = require("../config.idhub.js");
var CONSTANTS = require("../constants.js");
var util = require("../util.idhub.js");

var COMMON_CONFIG = require("../common.config.js");

var refThis = this;
var pbNameSpace = CONFIG.isIdentityOnly() ? CONSTANTS.COMMON.IH_NAMESPACE : CONSTANTS.COMMON.PREBID_NAMESPACE;

Expand Down Expand Up @@ -64,6 +66,12 @@ refThis.setConfig = function(){
timeout: CONFIG.getCCPATimeout(),
};
}

// Set Gpp consent config
if (CONFIG.getGppConsent()) {
prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout());
}

window.IHPWT.ssoEnabled = CONFIG.isSSOEnabled() || false;
if(CONFIG.isUserIdModuleEnabled()){
prebidConfig["userSync"]["userIds"] = util.getUserIdConfiguration();
Expand Down
15 changes: 15 additions & 0 deletions src_new/owIdhubCommon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// NOTE: This file will contains only common code/function used in OW and IDHUB.
// Do not import any other file into it.


exports.setConsentConfig = function (prebidConfig, key, cmpApi, timeout) {
prebidConfig = prebidConfig || {};
if (!prebidConfig["consentManagement"]) {
prebidConfig["consentManagement"] = {};
}
prebidConfig["consentManagement"][key] = {
cmpApi: cmpApi,
timeout: timeout
};
return prebidConfig;
};
11 changes: 11 additions & 0 deletions test/adapters/prebid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,10 @@ describe('ADAPTER: Prebid', function() {
sinon.spy(CONFIG, 'getCCPATimeout');
sinon.stub(CONFIG, 'getCCPA').returns(true);

sinon.spy(CONFIG, 'getGppTimeout');
sinon.spy(CONFIG, 'getGppCmpApi');
sinon.stub(CONFIG, 'getGppConsent').returns(true);

sinon.stub(BM, 'resetBid', function(){});
sinon.stub(BM, 'setSizes', function(){});

Expand Down Expand Up @@ -1362,6 +1366,10 @@ describe('ADAPTER: Prebid', function() {
CONFIG.getCCPA.restore();
CONFIG.getCCPATimeout.restore();

CONFIG.getGppConsent.restore();
CONFIG.getGppCmpApi.restore();
CONFIG.getGppTimeout.restore();

BM.resetBid.restore();
BM.setSizes.restore();

Expand Down Expand Up @@ -1433,6 +1441,9 @@ describe('ADAPTER: Prebid', function() {
CONFIG.getCCPA().should.be.true;
CONFIG.getCCPACmpApi().should.be.called;
CONFIG.getCCPATimeout().should.be.called;
CONFIG.getGppConsent().should.be.true;
CONFIG.getGppCmpApi().should.be.called;
CONFIG.getGppTimeout().should.be.called;
done();
});

Expand Down
67 changes: 67 additions & 0 deletions test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2412,6 +2412,73 @@ describe('Config', function() {
});
});


describe('#Gpp', function() {
beforeEach(function(done){
if(!CONF[CONSTANTS.CONFIG.COMMON]) {
CONF[CONSTANTS.CONFIG.COMMON] = {};
}
done();
});

describe('#getGpp', function() {
it('is a function', function(done) {
CONFIG.getGppConsent.should.be.a('function');
done();
});

it('should return true, as it is set to "1"', function(done) {
CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] = "1";
CONFIG.getGppConsent().should.be.true;
done();
});

it('should return default value for gpp which is '+(CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT === "1")+', as it is NOT set', function(done) {
delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT];
CONFIG.getGppConsent().should.be.equal((CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT === "1"));
done();
});
});

describe('#getGppCmpApi', function() {
it('is a function', function(done) {
CONFIG.getGppCmpApi.should.be.a('function');
done();
});

it('should return iab, as it is set to iab', function(done) {
CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] = 'iab';
CONFIG.getGppCmpApi().should.be.equal('iab');
done();
});

it('should return default cmp which is '+CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI+', as it is NOT set', function(done) {
delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI];
CONFIG.getGppCmpApi().should.be.equal(CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI);
done();
});
});

describe('#getGppTimeout', function() {
it('is a function', function(done) {
CONFIG.getGppTimeout.should.be.a('function');
done();
});

it('should return 5000, as it is set to 5000', function(done) {
CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT] = 5000;
CONFIG.getGppTimeout().should.be.equal(5000);
done();
});

it('should return default value for gpp timeout which is '+CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT+', as it is NOT set', function(done) {
delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT];
CONFIG.getGppTimeout().should.be.equal(CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT);
done();
});
});
});

describe('getOverrideNamespace', function() {
var configKey = 'pbGlobalVarNamespace';
var defaultName = 'custPbNamespace';
Expand Down
58 changes: 58 additions & 0 deletions test/owIdhubCommon.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* global describe, it, xit, sinon, expect */
// var sinon = require("sinon");
var should = require("chai").should();
var expect = require("chai").expect;
var OWIDHUBCOMMON = require("../src_new/owIdhubCommon");

describe('owIdhubCommon', function() {
describe('setConsentConfig', function() {
var prebidConfig = {};
var cmpApi = 'iab';
var timeout = 2000;

it('setConsentConfig a function', function(done) {
OWIDHUBCOMMON.setConsentConfig.should.be.a('function');
done();
});

it('should set consent management config when its not present', function(done) {
var expPrebidConfig = {
consentManagement: {
gpp: {
cmpApi,
timeout
}
}
};
const actPrebifConfig = OWIDHUBCOMMON.setConsentConfig(prebidConfig, 'gpp', cmpApi, timeout);
expect(actPrebifConfig).to.be.deep.equal(expPrebidConfig);
done();
});

it('should set consent management config when its present', function(done) {
var prebidConfig = {
consentManagement: {
gdpr: {
cmpApi,
timeout
}
}
}
var expPrebidConfig = {
consentManagement: {
gdpr: {
cmpApi,
timeout
},
gpp: {
cmpApi,
timeout
}
}
};
const actPrebifConfig = OWIDHUBCOMMON.setConsentConfig(prebidConfig, 'gpp', cmpApi, timeout);
expect(actPrebifConfig).to.be.deep.equal(expPrebidConfig);
done();
});
});
});