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

PubMatic bid adapter to support app object set using setConfig #5090

Merged
merged 37 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
33762d1
added support for pubcommon, digitrust, id5id
pm-harshad-mane Sep 12, 2019
0722354
added support for IdentityLink
pm-harshad-mane Sep 13, 2019
f2c32c0
changed the source for id5
pm-harshad-mane Sep 13, 2019
37163d1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 13, 2019
eaed987
added unit test cases
pm-harshad-mane Sep 13, 2019
602ee7e
changed source param for identityLink
pm-harshad-mane Sep 16, 2019
b6fcd36
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 23, 2019
58381f3
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Sep 26, 2019
c9fb11b
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 10, 2019
8ece7fd
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 16, 2019
28d12a0
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 16, 2019
05a55e1
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Oct 31, 2019
e8b10d5
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 5, 2019
870085f
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 12, 2019
844ce4e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 12, 2019
704eca3
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Nov 13, 2019
2565cb9
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 4, 2019
1d75bd4
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 4, 2019
6adde1e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 6, 2019
477c98a
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 9, 2019
cef5422
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Dec 10, 2019
c110a7d
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Jan 9, 2020
e8fb062
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 5, 2020
d77cd71
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 17, 2020
817ce3f
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 24, 2020
cda825e
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 26, 2020
f34a3ec
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Feb 27, 2020
f106dc8
Merge remote-tracking branch 'upstream/master'
pm-harshad-mane Mar 4, 2020
b749c0b
merge the device object from setConfig
pm-harshad-mane Mar 5, 2020
405ebc6
set app from config and site, remove site if app is set
pm-harshad-mane Mar 6, 2020
bacb14f
added test cases for reading device from config
pm-harshad-mane Mar 6, 2020
9d3f16e
unit test case for reading app from conf
pm-harshad-mane Mar 6, 2020
e20e9a5
Merge remote-tracking branch 'upstream/master' into pubmatic_app
pm-harshad-mane Mar 6, 2020
cb0ab45
delete the site object
pm-harshad-mane Mar 26, 2020
44824ab
Merge remote-tracking branch 'upstream/master' into pubmatic_app
pm-harshad-mane Mar 26, 2020
d0a77ac
set undefined not null
pm-harshad-mane Mar 27, 2020
ff3904f
Merge remote-tracking branch 'upstream/master' into pubmatic_app
pm-harshad-mane Apr 7, 2020
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
15 changes: 15 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,11 @@ export const spec = {
payload.site.page = conf.kadpageurl.trim() || payload.site.page.trim();
payload.site.domain = _getDomainFromURL(payload.site.page);

// merge the device from config.getConfig('device')
if (typeof config.getConfig('device') === 'object') {
payload.device = Object.assign(payload.device, config.getConfig('device'));
}

// passing transactionId in source.tid
utils.deepSetValue(payload, 'source.tid', conf.transactionId);

Expand Down Expand Up @@ -953,6 +958,16 @@ export const spec = {
_handleEids(payload, validBidRequests);
_blockedIabCategoriesValidation(payload, blockedIabCategories);

// Note: Do not move this block up
// if site object is set in Prebid config then we need to copy required fields from site into app and unset the site object
if (typeof config.getConfig('app') === 'object') {
payload.app = config.getConfig('app');
// not copying domain from site as it is a derived value from page
payload.app.publisher = payload.site.publisher;
payload.app.ext = payload.site.ext || UNDEFINED;
delete payload.site;
}

return {
method: 'POST',
url: ENDPOINT,
Expand Down
64 changes: 64 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,70 @@ describe('PubMatic adapter', function () {
expect(data.source.ext.schain).to.deep.equal(bidRequests[0].schain);
});

it('Merge the device info from config', function() {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake((key) => {
var config = {
device: {
'newkey': 'new-device-data'
}
};
return config[key];
});
let request = spec.buildRequests(bidRequests);
let data = JSON.parse(request.data);
expect(data.device.js).to.equal(1);
expect(data.device.dnt).to.equal((navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0);
expect(data.device.h).to.equal(screen.height);
expect(data.device.w).to.equal(screen.width);
expect(data.device.language).to.equal(navigator.language);
expect(data.device.newkey).to.equal('new-device-data');// additional data from config
sandbox.restore();
});

it('Merge the device info from config; data from config overrides the info we have gathered', function() {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake((key) => {
var config = {
device: {
newkey: 'new-device-data',
language: 'MARATHI'
}
};
return config[key];
});
let request = spec.buildRequests(bidRequests);
let data = JSON.parse(request.data);
expect(data.device.js).to.equal(1);
expect(data.device.dnt).to.equal((navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0);
expect(data.device.h).to.equal(screen.height);
expect(data.device.w).to.equal(screen.width);
expect(data.device.language).to.equal('MARATHI');// // data overriding from config
expect(data.device.newkey).to.equal('new-device-data');// additional data from config
sandbox.restore();
});

it('Set app from config, copy publisher and ext from site, unset site', function() {
let sandbox = sinon.sandbox.create();
sandbox.stub(config, 'getConfig').callsFake((key) => {
var config = {
app: {
bundle: 'org.prebid.mobile.demoapp',
domain: 'prebid.org'
}
};
return config[key];
});
let request = spec.buildRequests(bidRequests);
let data = JSON.parse(request.data);
expect(data.app.bundle).to.equal('org.prebid.mobile.demoapp');
expect(data.app.domain).to.equal('prebid.org');
expect(data.app.publisher.id).to.equal(bidRequests[0].params.publisherId);
expect(data.app.ext.key_val).to.exist.and.to.equal(bidRequests[0].params.dctr);
expect(data.site).to.not.exist;
sandbox.restore();
});

it('Request params check: without adSlot', function () {
delete bidRequests[0].params.adSlot;
let request = spec.buildRequests(bidRequests);
Expand Down