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

Standardized COPPA support #3936

Merged
merged 15 commits into from
Jun 25, 2019
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
2 changes: 1 addition & 1 deletion modules/arteebeeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function makeRtbRequest(req, bidderRequest) {
'tmax': config.getConfig('bidderTimeout')
};

if (req.params.coppa) {
if (config.getConfig('coppa') === true || req.params.coppa) {
rtbReq.regs = {coppa: 1};
}

Expand Down
2 changes: 1 addition & 1 deletion modules/openxBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function buildOXBannerRequest(bids, bidderRequest) {
queryParams.ns = 1;
}

if (bids.some(bid => bid.params.coppa)) {
if (config.getConfig('coppa') === true || bids.some(bid => bid.params.coppa)) {
queryParams.tfcd = 1;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/openxoutstreamBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function buildOXBannerRequest(bid, bidderRequest) {
queryParams.ns = 1;
}

if (bid.params.coppa) {
if (config.getConfig('coppa') === true || bid.params.coppa) {
queryParams.tfcd = 1;
}

Expand Down
4 changes: 4 additions & 0 deletions modules/prebidServerBidAdapter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ const OPEN_RTB_PROTOCOL = {
}
}

if (getConfig('coppa') === true) {
utils.deepSetValue(request, 'regs.coppa', 1);
}

return request;
},

Expand Down
8 changes: 8 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ export const spec = {
}
}

if (config.getConfig('coppa') === true) {
utils.deepSetValue(request, 'regs.coppa', 1);
}

return {
method: 'POST',
url: VIDEO_ENDPOINT,
Expand Down Expand Up @@ -411,6 +415,10 @@ export const spec = {
data[paramKey] = digitrustParams[paramKey];
});

if (config.getConfig('coppa') === true) {
data['coppa'] = 1;
}

return data;
},

Expand Down
17 changes: 17 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,23 @@ export function deepAccess(obj, path) {
return obj;
}

/**
* @param {Object} obj The object to set a deep property value in
* @param {(string|Array.<string>)} path Object path to the value you would like ot set.
* @param {*} value The value you would like to set
*/
export function deepSetValue(obj, path, value) {
let i;
path = path.split('.');
for (i = 0; i < path.length - 1; i++) {
if (i !== path.length - 1 && typeof obj[path[i]] === 'undefined') {
obj[path[i]] = {};
}
obj = obj[path[i]];
}
obj[path[i]] = value;
}

/**
* Returns content for a friendly iframe to execute a URL in script tag
* @param {string} url URL to be executed in a script tag in a friendly iframe
Expand Down
23 changes: 23 additions & 0 deletions test/spec/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,29 @@ describe('Utils', function () {
});
});

describe('deepSetValue', function() {
it('should set existing properties at various depths', function() {
const testObj = {
prop: 'value',
nestedObj: {
nestedProp: 'nestedValue'
}
};
utils.deepSetValue(testObj, 'prop', 'newValue');
assert.equal(testObj.prop, 'newValue');
utils.deepSetValue(testObj, 'nestedObj.nestedProp', 'newNestedValue');
assert.equal(testObj.nestedObj.nestedProp, 'newNestedValue');
});

it('should create object levels between top and bottom of given path if they do not exist', function() {
const testObj = {};
utils.deepSetValue(testObj, 'level1.level2', 'value');
assert.notEqual(testObj.level1, undefined);
assert.notEqual(testObj.level1.level2, undefined);
assert.equal(testObj.level1.level2, 'value');
});
});

describe('createContentToExecuteExtScriptInFriendlyFrame', function () {
it('should return empty string if url is not passed', function () {
var output = utils.createContentToExecuteExtScriptInFriendlyFrame();
Expand Down