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

33Across: Adding floors support #5408

Merged
merged 92 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
60b6821
check gdpr in buildRequest
curlyblueeagle Aug 3, 2018
888a1bd
User sync based on whether gdpr applies or not
curlyblueeagle Aug 3, 2018
59f8304
check if consent data exists during user sync
curlyblueeagle Aug 3, 2018
1096846
split user sync into further branches: 1) when gdpr does not apply 2)…
curlyblueeagle Aug 7, 2018
6dfb54d
Merge pull request #8 from 33Across/XCH-801_gdpr_compliance
curlyblueeagle Aug 16, 2018
c089d82
Merge remote-tracking branch 'upstream/master'
Sep 12, 2018
fc9e8c6
contribute viewability to ttxRequest
Sep 7, 2018
5a95872
update tests
Sep 10, 2018
8aa0218
remove window mock from tests
Sep 10, 2018
7f75405
use local variables
Sep 10, 2018
6aedf17
introduce ServerRequestBuilder
Sep 10, 2018
9765718
add withOptions() method to ServerRequestBuilder
Sep 10, 2018
88a6527
add semicolons
Sep 10, 2018
093062d
Merge pull request #12 from 33Across/viewability
glebglushtsov Sep 12, 2018
ac0b586
sync up package-lock.json with upstream/master
Sep 12, 2018
a9abbfb
stub window.top in tests
Sep 13, 2018
f701fb9
introduce getTopWindowSize() for test purpose
Sep 13, 2018
059437b
reformat code
Sep 13, 2018
90e5bed
add withSite() method to TtxRequestBuilder
Sep 13, 2018
9660102
Merge pull request #14 from 33Across/viewability
glebglushtsov Sep 13, 2018
832e1d1
Merge remote-tracking branch 'upstream/master'
Sep 14, 2018
f26b47a
add isIframe() and _isViewabilityMeasurable()
Sep 14, 2018
8f34683
handle NON_MEASURABLE viewability in nested iframes
Sep 14, 2018
07f4933
consider page visibility, stub utils functions getWindowTop() and get…
Sep 14, 2018
525684b
Merge pull request #15 from 33Across/viewability
glebglushtsov Sep 14, 2018
8507272
contribute viewability as 0 for inactive tab
Sep 17, 2018
d502156
Merge pull request #16 from 33Across/viewability
glebglushtsov Sep 17, 2018
a83374e
Merge remote-tracking branch 'upstream/master'
Sep 27, 2018
7219753
Merge remote-tracking branch 'upstream/master'
Nov 7, 2018
527abc6
add prebidjs version to ttx request
Nov 7, 2018
959637f
send caller as an array
Nov 8, 2018
2b347c1
Merge pull request #17 from 33Across/oculus-66-add-prebidjs-version-t…
glebglushtsov Nov 8, 2018
a636d84
Merge remote-tracking branch 'upstream/master'
Nov 8, 2018
1682fb3
Merge remote-tracking branch 'upstream/master'
Nov 8, 2018
753d9ab
Merge remote-tracking branch 'upstream/master'
Nov 12, 2018
da38438
send viewability as non measurable when unable to locate target HTMLE…
Nov 14, 2018
6ee858d
fix JSDoc in utils.js
Nov 13, 2018
66aa3eb
Merge pull request #18 from 33Across/oculus-68-map-ad-slot-path-to-el…
glebglushtsov Nov 15, 2018
87b5970
Merge tag '1.33.0'
Nov 26, 2018
f23e855
Merge remote-tracking branch 'upstream/master'
May 23, 2019
6e38645
Merge remote-tracking branch 'upstream/master'
May 31, 2019
3214634
introduce mapAdSlotPathToElementId()
May 31, 2019
1058803
introduce getAdSlotHTMLElement(), add logging
May 31, 2019
3fc8fe9
introduce mapAdSlotPathToElementId()
May 31, 2019
d850980
update logging in ad unit path to element id mapping
Jun 3, 2019
e14d1e1
rephrase logging, fix tests
Jun 3, 2019
17a2342
update adapter documentation
Jun 5, 2019
178ccee
remove excessive logging
Jun 10, 2019
bc936c0
improve logging
Jun 11, 2019
09bbfe7
revert change
Jun 11, 2019
236dd54
fix return of _mapAdUnitPathToElementId()
Jun 11, 2019
6c097ff
improve logging of _mapAdUnitPathToElementId()
Jun 12, 2019
05f2753
Merge pull request #19 from 33Across/oculus-82-locate-ad-slot-element…
glebglushtsov Jun 12, 2019
acb0162
do not use Array.find()
Jun 17, 2019
3ca6029
Merge remote-tracking branch 'upstream/master'
Jun 17, 2019
c2cb54d
return id once element is found
Jun 18, 2019
5bcde42
return id once element is found
Jun 18, 2019
a72b1a0
let -> const
Jun 18, 2019
11b1e96
Merge pull request #20 from 33Across/oculus-82-locate-ad-slot-element…
glebglushtsov Jun 18, 2019
0a84973
Removing killswitch behavior for GDPR
Jun 25, 2019
ecefa15
Updated comments to reflect current gdpr logic
Jun 25, 2019
0a74fd9
URI encode consent string
Jun 26, 2019
5b1eb46
Merge pull request #21 from 33Across/XCH-1388_gdpr_compliance
curlyblueeagle Jun 26, 2019
2366af3
Merge remote-tracking branch 'prebid/master'
Jun 26, 2019
ced5902
Updated example site ID to help Prebid team e2e test our adapter
Jul 2, 2019
9f3113a
Merge branch 'master' of github.com:prebid/Prebid.js
Jan 28, 2020
281814b
send page url in ortb
Jan 28, 2020
dbbecb0
Removed redundant pageUrl default
Jan 28, 2020
8398b50
Merge pull request #22 from 33Across/XCH-1723_set_pageurl_in_request
curlyblueeagle Jan 29, 2020
623f155
Restored package-log.json that mirrors prebid's repo
Jan 29, 2020
34cd133
Merge pull request #23 from 33Across/testing_revert
curlyblueeagle Jan 29, 2020
305ddfa
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jun 3, 2020
176a5d7
Sending USP string during buildRequest
Jun 4, 2020
f6c94b2
Adding USP consent data to user sync
Jun 4, 2020
8822c1b
add unit test for syncing without bidrequest
Jun 4, 2020
94714fa
Changed to uspConsent to make the connatation consistent
Jun 4, 2020
3e94296
Resetting adapter state in adapter after user sync rather than exposi…
Jun 8, 2020
99e2d01
removed console log
Jun 8, 2020
c979ddc
Adding schain info
Jun 8, 2020
be12cd5
remove setting empty format ext
Jun 8, 2020
77b0aa4
better tests invalid values
Jun 9, 2020
c4b94bd
removing validation of schain
Jun 11, 2020
4a31c03
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jun 11, 2020
17a958e
Merge pull request #26 from 33Across/XCH-1862_schain_support
curlyblueeagle Jun 11, 2020
eb7efa1
Merge pull request #25 from 33Across/XCH-1859_ccpa_compliance
curlyblueeagle Jun 11, 2020
3246318
Merge branch 'master' of https://github.com/33Across/Prebid.js
Jun 11, 2020
b7118f1
Fixed lint errors
Jun 16, 2020
d3884f5
First cut for bidfloors support
Jun 12, 2020
56ca427
fixed where getFloors is read
Jun 16, 2020
2e46605
Merge pull request #27 from 33Across/XCH-1803_bid_floors_support
curlyblueeagle Jun 22, 2020
63d2e70
Merge branch 'master' of https://github.com/prebid/Prebid.js
Jun 22, 2020
091c23e
fixed merge conflicts
Jun 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 46 additions & 3 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import * as utils from '../src/utils.js';
const BIDDER_CODE = '33across';
const END_POINT = 'https://ssc.33across.com/api/v1/hb';
const SYNC_ENDPOINT = 'https://ssc-cms.33across.com/ps/?m=xch&rt=html&ru=deb';
const MEDIA_TYPE = 'banner';
const CURRENCY = 'USD';

const adapterState = {
uniqueSiteIds: []
Expand Down Expand Up @@ -67,11 +69,27 @@ function _getAdSlotHTMLElement(adUnitCode) {

// Infer the necessary data from valid bid for a minimal ttxRequest and create HTTP request
// NOTE: At this point, TTX only accepts request for a single impression
function _createServerRequest(bidRequest, gdprConsent = {}, uspConsent, pageUrl) {
function _createServerRequest({bidRequest, gdprConsent = {}, uspConsent, pageUrl}) {
const ttxRequest = {};
const params = bidRequest.params;
const element = _getAdSlotHTMLElement(bidRequest.adUnitCode);
const sizes = _transformSizes(bidRequest.sizes);

let format;

// We support size based bidfloors so obtain one if there's a rule associated
if (typeof bidRequest.getFloor === 'function') {
let getFloor = bidRequest.getFloor.bind(bidRequest);

format = sizes.map((size) => {
const formatExt = _getBidFloors(getFloor, size);

return Object.assign({}, size, formatExt);
});
} else {
format = sizes;
}

const minSize = _getMinSize(sizes);

const viewabilityAmount = _isViewabilityMeasurable(element)
Expand All @@ -86,7 +104,7 @@ function _createServerRequest(bidRequest, gdprConsent = {}, uspConsent, pageUrl)
ttxRequest.imp = [];
ttxRequest.imp[0] = {
banner: {
format: sizes
format
},
ext: {
ttx: {
Expand Down Expand Up @@ -179,6 +197,24 @@ function _createSync({ siteId = 'zzz000000000003zzz', gdprConsent = {}, uspConse
return sync;
}

function _getBidFloors(getFloor, size) {
const bidFloors = getFloor({
currency: CURRENCY,
mediaType: MEDIA_TYPE,
size: [ size.w, size.h ]
});

if (!isNaN(bidFloors.floor) && (bidFloors.currency === CURRENCY)) {
return {
ext: {
ttx: {
bidfloors: [ bidFloors.floor ]
}
}
}
}
}

function _getSize(size) {
return {
w: parseInt(size[0], 10),
Expand Down Expand Up @@ -320,7 +356,14 @@ function buildRequests(bidRequests, bidderRequest) {

adapterState.uniqueSiteIds = bidRequests.map(req => req.params.siteId).filter(utils.uniques);

return bidRequests.map(req => _createServerRequest(req, gdprConsent, uspConsent, pageUrl));
return bidRequests.map(bidRequest => _createServerRequest(
{
bidRequest,
gdprConsent,
uspConsent,
pageUrl
})
);
}

// NOTE: At this point, the response from 33exchange will only ever contain one bid i.e. the highest bid
Expand Down
67 changes: 67 additions & 0 deletions test/spec/modules/33acrossBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ describe('33acrossBidAdapter:', function () {
return this;
};

this.withFormatFloors = floors => {
const format = ttxRequest.imp[0].banner.format.map((fm, i) => {
return Object.assign(fm, {
ext: {
ttx: {
bidfloors: [ floors[i] ]
}
}
})
});

ttxRequest.imp[0].banner.format = format;

return this;
};

this.build = () => ttxRequest;
}

Expand Down Expand Up @@ -667,6 +683,57 @@ describe('33acrossBidAdapter:', function () {
expect(builtServerRequests).to.deep.equal([serverRequest]);
});
});

context('when price floor module is not enabled in bidRequest', function() {
it('does not set any bidfloors in ttxRequest', function() {
const ttxRequest = new TtxRequestBuilder()
.build();
const serverRequest = new ServerRequestBuilder()
.withData(ttxRequest)
.build();
const builtServerRequests = spec.buildRequests(bidRequests, {});

expect(builtServerRequests).to.deep.equal([serverRequest]);
});
});

context('when price floor module is enabled in bidRequest', function() {
it('does not set any bidfloors in ttxRequest if there is no floor', function() {
bidRequests[0].getFloor = () => ({});

const ttxRequest = new TtxRequestBuilder()
.build();
const serverRequest = new ServerRequestBuilder()
.withData(ttxRequest)
.build();
const builtServerRequests = spec.buildRequests(bidRequests, {});

expect(builtServerRequests).to.deep.equal([serverRequest]);
});

it('sets bidfloors in ttxRequest if there is a floor', function() {
bidRequests[0].getFloor = ({size, currency, mediaType}) => {
const floor = (size[0] === 300 && size[1] === 250) ? 1.0 : 0.10
return (
{
floor,
currency: 'USD'
}
);
};

const ttxRequest = new TtxRequestBuilder()
.withFormatFloors([ 1.0, 0.10 ])
.build();

const serverRequest = new ServerRequestBuilder()
.withData(ttxRequest)
.build();
const builtServerRequests = spec.buildRequests(bidRequests, {});

expect(builtServerRequests).to.deep.equal([serverRequest]);
});
});
});

describe('interpretResponse', function() {
Expand Down