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

IDNT-601: Override IH IDs(with prebid ids) in adUnit for OW+IH profile #447

Open
wants to merge 2 commits into
base: nightly
Choose a base branch
from
Open
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 src_new/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ exports.updateUserIds = function(bid){
}
else if(refThis.isArray(bid.userIdAsEids)){
var idsPresent = new Set();
var ids = refThis.getUserIdsAsEids().concat(bid.userIdAsEids);
var ids = bid.userIdAsEids.concat(refThis.getUserIdsAsEids());
if(refThis.isArray(ids) && ids.length > 0){
ids = ids.filter(function(id){
if(id.source){
Expand Down
18 changes: 8 additions & 10 deletions test/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3846,7 +3846,7 @@ describe('UTIL', function() {
'ecpm':'10.00'
}
sinon.stub(UTIL,'getUserIds').returns({id:1})
sinon.stub(UTIL,'getUserIdsAsEids').returns([{"source":"myId",id:1}])
sinon.stub(UTIL,'getUserIdsAsEids').returns([{"source":"myId",uids:[{ "id": "idhub-id"}]}])
done();
});

Expand All @@ -3863,27 +3863,25 @@ describe('UTIL', function() {
});

it('should add UserId in bid if userIds is not present', function(done){
var expectedResult = {"ecpm":"10.00","userId":{"id":1},"userIdAsEids":[{"source":"myId","id":1}]}
var expectedResult = {"ecpm":"10.00","userId":{"id":1},"userIdAsEids":[{"source":"myId",uids:[{ "id": "idhub-id"}]}]}
UTIL.updateUserIds(bid)
bid.should.be.deep.equal(expectedResult);
done();
})

// TODO: UnComment Below Test Cases once PhantomJs is replaced by ChromeHeadless in build.sh production and test mode
xit('should update UserID in bid if userIds is present',function(done){
var expectedResult = {"ecpm":"10.00","userId":{"existingId":2,"id":1},"userIdAsEids":[{"source":"myId","id":1},{"source":"existingMyId","existingId":2}]}
it('should update(or merge) UserID in bid if userIds is present',function(done){
var expectedResult = {"ecpm":"10.00","userId":{"existingId":2,"id":1},"userIdAsEids":[{"source":"existingMyId","uids": [{"id": "prebid-id"}]},{"source":"myId",uids:[{ "id": "idhub-id"}]}]}
bid['userId'] = {"existingId":2}
bid['userIdAsEids'] = [{"source":"existingMyId","existingId":2}]
bid['userIdAsEids'] = [{"source":"existingMyId","uids": [{"id": "prebid-id"}]}]
UTIL.updateUserIds(bid)
bid.should.be.deep.equal(expectedResult);
done();
})

// TODO: UnComment Below Test Cases once PhantomJs is replaced by ChromeHeadless in build.sh production and test mode
xit('should update with IH values if same id is present', function(done){
var expectedResult = {"ecpm":"10.00","userId":{"id":1},"userIdAsEids":[{"source":"myId","id":1}]}
it('should update or pass prebid ID instead of IH ID in bid if same id is present', function(done){
var expectedResult = {"ecpm":"10.00","userId":{"id":1},"userIdAsEids":[{"source":"myId","uids": [{"id": "prebid-id"}]}]}
bid['userId'] = {"id":2}
bid['userIdAsEids'] = [{"source":"myId","id":2}]
bid['userIdAsEids'] = [{"source":"myId","uids": [{"id": "prebid-id"}]}]
UTIL.updateUserIds(bid);
bid.should.be.deep.equal(expectedResult);
done();
Expand Down