Skip to content

Commit 80567cd

Browse files
committed
remove key=value keyword parsing for appnexus and its clones
1 parent d6450d1 commit 80567cd

File tree

3 files changed

+12
-114
lines changed

3 files changed

+12
-114
lines changed

libraries/appnexusKeywords/anKeywords.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,10 @@ export function convertKeywordStringToANMap(keyStr) {
6060
function convertKeywordsToANMap(kwarray) {
6161
const result = {};
6262
kwarray.forEach(kw => {
63-
// if = exists, then split
64-
if (kw.indexOf('=') !== -1) {
65-
let kwPair = kw.split('=');
66-
let key = kwPair[0];
67-
let val = kwPair[1];
68-
69-
// then check for existing key in result > if so add value to the array > if not, add new key and create value array
70-
if (result.hasOwnProperty(key)) {
71-
result[key].push(val);
72-
} else {
73-
result[key] = [val];
74-
}
75-
} else {
76-
if (!result.hasOwnProperty(kw)) {
77-
result[kw] = [];
78-
}
63+
if (!result.hasOwnProperty(kw)) {
64+
result[kw] = [];
7965
}
80-
})
66+
});
8167
return result;
8268
}
8369

modules/appnexusBidAdapter.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {hasPurpose1Consent} from '../src/utils/gpdr.js';
3636
import {convertOrtbRequestToProprietaryNative} from '../src/native.js';
3737
import {APPNEXUS_CATEGORY_MAPPING} from '../libraries/categoryTranslationMapping/index.js';
3838
import {
39-
convertKeywordStringToANMap,
4039
getANKewyordParamFromMaps,
4140
getANKeywordParam,
4241
transformBidderParamKeywords
@@ -783,7 +782,7 @@ function bidToTag(bid) {
783782
tag.external_imp_id = bid.params.external_imp_id;
784783
}
785784

786-
const auKeywords = getANKewyordParamFromMaps(convertKeywordStringToANMap(deepAccess(bid, 'ortb2Imp.ext.data.keywords')), bid.params?.keywords);
785+
const auKeywords = getANKewyordParamFromMaps(bid.params?.keywords);
787786
if (auKeywords.length > 0) {
788787
tag.keywords = auKeywords;
789788
}

test/spec/modules/appnexusBidAdapter_spec.js

Lines changed: 8 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -757,26 +757,27 @@ describe('AppNexusAdapter', function () {
757757
'value': ['rock', 'pop']
758758
}, {
759759
'key': 'test'
760+
}, {
761+
key: 'tools=industrial',
762+
}, {
763+
key: 'tools=home',
760764
}, {
761765
'key': 'tools',
762-
'value': ['power', 'industrial', 'home']
766+
'value': ['power']
763767
}, {
764768
'key': 'power tools'
765769
}, {
766770
'key': 'drills'
767771
}, {
768772
'key': 'video'
769773
}, {
770-
'key': 'source',
771-
'value': ['streaming']
774+
'key': 'source=streaming',
772775
}, {
773776
'key': 'renting'
774777
}, {
775-
'key': 'app',
776-
'value': ['iphone 11']
778+
'key': 'app=iphone 11',
777779
}, {
778-
'key': 'appcontent',
779-
'value': ['home repair']
780+
'key': 'appcontent=home repair',
780781
}, {
781782
'key': 'dyi'
782783
}]);
@@ -908,94 +909,6 @@ describe('AppNexusAdapter', function () {
908909
])
909910
});
910911

911-
it('should convert adUnit ortb2 keywords (when there are no bid param keywords) to proper form and attaches to request', function () {
912-
let bidRequest = Object.assign({},
913-
bidRequests[0],
914-
{
915-
ortb2Imp: {
916-
ext: {
917-
data: {
918-
keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456'
919-
}
920-
}
921-
}
922-
}
923-
);
924-
925-
const request = spec.buildRequests([bidRequest]);
926-
const payload = JSON.parse(request.data);
927-
928-
expectKeywords(payload.tags[0].keywords, [{
929-
'key': 'ortb2',
930-
'value': ['yes']
931-
}, {
932-
'key': 'ortb2test'
933-
}, {
934-
'key': 'multiValMixed',
935-
'value': ['4']
936-
}, {
937-
'key': 'singleValNum',
938-
'value': ['456']
939-
}]);
940-
});
941-
942-
it('should convert keyword params and adUnit ortb2 keywords to proper form and attaches to request', function () {
943-
let bidRequest = Object.assign({},
944-
bidRequests[0],
945-
{
946-
params: {
947-
placementId: '10433394',
948-
keywords: {
949-
single: 'val',
950-
singleArr: ['val'],
951-
singleArrNum: [5],
952-
multiValMixed: ['value1', 2, 'value3'],
953-
singleValNum: 123,
954-
emptyStr: '',
955-
emptyArr: [''],
956-
badValue: { 'foo': 'bar' } // should be dropped
957-
}
958-
},
959-
ortb2Imp: {
960-
ext: {
961-
data: {
962-
keywords: 'ortb2=yes,ortb2test, multiValMixed=4, singleValNum=456'
963-
}
964-
}
965-
}
966-
}
967-
);
968-
969-
const request = spec.buildRequests([bidRequest]);
970-
const payload = JSON.parse(request.data);
971-
972-
expectKeywords(payload.tags[0].keywords, [{
973-
'key': 'single',
974-
'value': ['val']
975-
}, {
976-
'key': 'singleArr',
977-
'value': ['val']
978-
}, {
979-
'key': 'singleArrNum',
980-
'value': ['5']
981-
}, {
982-
'key': 'multiValMixed',
983-
'value': ['value1', '2', 'value3', '4']
984-
}, {
985-
'key': 'singleValNum',
986-
'value': ['123', '456']
987-
}, {
988-
'key': 'emptyStr'
989-
}, {
990-
'key': 'emptyArr'
991-
}, {
992-
'key': 'ortb2',
993-
'value': ['yes']
994-
}, {
995-
'key': 'ortb2test'
996-
}]);
997-
});
998-
999912
it('should add payment rules to the request', function () {
1000913
let bidRequest = Object.assign({},
1001914
bidRequests[0],

0 commit comments

Comments
 (0)