Skip to content

Commit 3ef34ae

Browse files
authored
appnexus bid adapter - add support for tid (prebid#13502)
1 parent c2bcd41 commit 3ef34ae

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

modules/appnexusBidAdapter.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,18 @@ export const spec = {
284284
payload.keywords = auctionKeywords;
285285
}
286286

287+
if (ortb2?.source?.tid) {
288+
if (!payload.source) {
289+
payload.source = {
290+
tid: ortb2.source.tid
291+
};
292+
} else {
293+
Object.assign({}, payload.source, {
294+
tid: ortb2.source.tid
295+
});
296+
}
297+
}
298+
287299
if (config.getConfig('adpod.brandCategoryExclusion')) {
288300
payload.brand_category_uniqueness = true;
289301
}
@@ -914,6 +926,11 @@ function bidToTag(bid) {
914926
tag.gpid = gpid;
915927
}
916928

929+
let tid = deepAccess(bid, 'ortb2Imp.ext.tid');
930+
if (tid) {
931+
tag.tid = tid;
932+
}
933+
917934
if (FEATURES.NATIVE && (bid.mediaType === NATIVE || deepAccess(bid, `mediaTypes.${NATIVE}`))) {
918935
tag.ad_types.push(NATIVE);
919936
if (tag.sizes.length === 0) {

test/spec/modules/appnexusBidAdapter_spec.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ describe('AppNexusAdapter', function () {
12181218
const request = spec.buildRequests([bidRequest]);
12191219
const payload = JSON.parse(request.data);
12201220

1221-
expect(payload.tags[0].gpid).to.exist.and.equal(testGpid)
1221+
expect(payload.tags[0].gpid).to.exist.and.equal(testGpid);
12221222
});
12231223

12241224
it('should add backup gpid to the request', function () {
@@ -1229,7 +1229,33 @@ describe('AppNexusAdapter', function () {
12291229
const request = spec.buildRequests([bidRequest]);
12301230
const payload = JSON.parse(request.data);
12311231

1232-
expect(payload.tags[0].gpid).to.exist.and.equal(testGpid)
1232+
expect(payload.tags[0].gpid).to.exist.and.equal(testGpid);
1233+
});
1234+
1235+
it('should add tid to the request', function () {
1236+
const testTid = '1234test';
1237+
let bidRequest = deepClone(bidRequests[0]);
1238+
bidRequest.ortb2Imp = { ext: { tid: testTid } };
1239+
// bidRequest.ortb2 = { source: { tid: testTid } };
1240+
1241+
const bidderRequest = {
1242+
'bidderCode': 'appnexus',
1243+
'auctionId': '1d1a030790a475',
1244+
'bidderRequestId': '22edbae2733bf6',
1245+
'timeout': 3000,
1246+
ortb2: {
1247+
source: {
1248+
tid: testTid
1249+
}
1250+
}
1251+
};
1252+
bidderRequest.bids = [bidRequest];
1253+
1254+
const request = spec.buildRequests([bidRequest], bidderRequest);
1255+
const payload = JSON.parse(request.data);
1256+
1257+
expect(payload.tags[0].tid).to.exist.and.equal(testTid);
1258+
expect(payload.source.tid).to.exist.and.equal(testTid);
12331259
});
12341260

12351261
it('should add gdpr consent information to the request', function () {

0 commit comments

Comments
 (0)