Skip to content

Commit

Permalink
ShowHeroes Bid Adapter: added support for USP (#9681)
Browse files Browse the repository at this point in the history
* add ShowHeroes Adapter

* ShowHeroes adapter - expanded outstream support

* Revert "ShowHeroes adapter - expanded outstream support"

This reverts commit bfcdb91.

* ShowHeroes adapter - expanded outstream support

* ShowHeroes adapter - fixes (#4222)

* ShowHeroes adapter - banner and outstream fixes (#4222)

* ShowHeroes adapter - description and outstream changes (#4222)

* ShowHeroes adapter - increase test coverage and small fix

* ShowHeroes Adapter - naming convention issue

* Mixed AdUnits declaration support

* ITDEV-4723 PrebidJS adapter support with SupplyChain module object

* ITDEV-4723 Fix tests

* ITDEV-4723 New entry point

* showheroes-bsBidAdapter: Add support for advertiserDomains

* showheroes-bsBidAdapter: hotfix for outstream render

* showheroes-bsBidAdapter: update renderer url

* showheroes-bsBidAdapter: use only the necessary fields from the gdprConsent

* ShowHeroes adapter - added a new endpoint

* ShowHeroes adapter - unit tests

* Update showheroes-bsBidAdapter.md

* ShowHeroes adapter - added support for USP

---------

Co-authored-by: veranevera <vera.yukhina@showheroes.com>
Co-authored-by: Elizaveta Voziyanova <44549195+h2p4x8@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 23, 2023
1 parent 37976fe commit 4ca23f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
7 changes: 6 additions & 1 deletion modules/showheroes-bsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const spec = {
},
buildRequests: function(validBidRequests, bidderRequest) {
let adUnits = [];
const pageURL = validBidRequests[0].params.contentPageUrl || bidderRequest.refererInfo.referer;
const pageURL = validBidRequests[0].params.contentPageUrl ||
bidderRequest.refererInfo.canonicalUrl ||
deepAccess(window, 'location.href');
const isStage = !!validBidRequests[0].params.stage;
const isViralize = !!validBidRequests[0].params.unitId;
const isOutstream = deepAccess(validBidRequests[0], 'mediaTypes.video.context') === 'outstream';
Expand All @@ -50,6 +52,7 @@ export const spec = {
const defaultSchain = validBidRequests[0].schain || {};

const consentData = bidderRequest.gdprConsent || {};
const uspConsent = bidderRequest.uspConsent || '';
const gdprConsent = {
apiVersion: consentData.apiVersion || 2,
gdprApplies: consentData.gdprApplies || 0,
Expand Down Expand Up @@ -104,6 +107,7 @@ export const spec = {
height: size[1]
};
rBid.gdprConsent = gdprConsent;
rBid.uspConsent = uspConsent;
}

return rBid;
Expand Down Expand Up @@ -138,6 +142,7 @@ export const spec = {
'bidRequests': adUnits,
'context': {
'gdprConsent': gdprConsent,
'uspConsent': uspConsent,
'schain': defaultSchain,
'pageURL': QA.pageURL || encodeURIComponent(pageURL)
}
Expand Down
40 changes: 22 additions & 18 deletions test/spec/modules/showheroes-bsBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {VIDEO, BANNER} from 'src/mediaTypes.js'

const bidderRequest = {
refererInfo: {
referer: 'https://example.com'
canonicalUrl: 'https://example.com'
}
}

Expand All @@ -19,6 +19,8 @@ const gdpr = {
}
}

const uspConsent = '1---';

const schain = {
'schain': {
'validation': 'strict',
Expand Down Expand Up @@ -338,18 +340,28 @@ describe('shBidAdapter', function () {
});
})

it('passes gdpr if present', function () {
const request = spec.buildRequests([bidRequestVideo], {...bidderRequest, ...gdpr})
it('passes gdpr & uspConsent if present', function () {
const request = spec.buildRequests([bidRequestVideo], {
...bidderRequest,
...gdpr,
uspConsent,
})
const payload = request.data.requests[0];
expect(payload).to.be.an('object');
expect(payload.gdprConsent).to.eql(gdpr.gdprConsent)
expect(payload.uspConsent).to.eql(uspConsent)
})

it('passes gdpr if present (V2)', function () {
const request = spec.buildRequests([bidRequestVideoV2], {...bidderRequest, ...gdpr})
it('passes gdpr & usp if present (V2)', function () {
const request = spec.buildRequests([bidRequestVideoV2], {
...bidderRequest,
...gdpr,
uspConsent,
})
const context = request.data.context;
expect(context).to.be.an('object');
expect(context.gdprConsent).to.eql(gdpr.gdprConsent)
expect(context.uspConsent).to.eql(uspConsent)
})

it('passes schain object if present', function() {
Expand Down Expand Up @@ -379,7 +391,7 @@ describe('shBidAdapter', function () {
expect(spec.interpretResponse({body: []}, {data: {meta: {}}}).length).to.equal(0)
})

const vastTag = 'https://video-library.stage.showheroes.com/commercial/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6'
const vastTag = 'https://test.com/commercial/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6'
const vastXml = '<?xml version="1.0" encoding="utf-8"?><VAST version="3.0"><Error><![CDATA[https://static.showheroes.com/shim.gif]]></Error></VAST>'

const basicResponse = {
Expand All @@ -389,7 +401,7 @@ describe('shBidAdapter', function () {
'context': 'instream',
'bidId': '38b373e1e31c18',
'size': {'width': 640, 'height': 480},
'vastTag': 'https:\/\/video-library.stage.showheroes.com\/commercial\/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6',
'vastTag': 'https:\/\/test.com\/commercial\/wrapper?player_id=47427aa0-f11a-4d24-abca-1295a46a46cd&ad_bidder=showheroes-bs&master_shadt=1&description_url=https%3A%2F%2Fbid-service.stage.showheroes.com%2Fvast%2Fad%2Fcache%2F4840b920-40e1-4e09-9231-60bbf088c8d6',
'vastXml': vastXml,
'adomain': adomain,
};
Expand Down Expand Up @@ -423,13 +435,13 @@ describe('shBidAdapter', function () {
'height': 480,
'advertiserDomain': [],
'callbacks': {
'won': ['https://api-n729.qa.viralize.com/track/?ver=15&session_id=01ecd03ce381505ccdeb88e555b05001&category=request_session&type=event&request_session_id=01ecd03ce381505ccdeb88e555b05001&label=prebid_won&reason=ok']
'won': ['https://test.com/track/?ver=15&session_id=01ecd03ce381505ccdeb88e555b05001&category=request_session&type=event&request_session_id=01ecd03ce381505ccdeb88e555b05001&label=prebid_won&reason=ok']
},
'mediaType': 'video',
'adomain': adomain,
};

const vastUrl = 'https://api-n729.qa.viralize.com/vast/?zid=AACBWAcof-611K4U&u=https://example.org/?foo=bar&gdpr=0&cs=XXXXXXXXXXXXXXXXXXXX&sid=01ecd03ce381505ccdeb88e555b05001&width=300&height=200&prebidmode=1'
const vastUrl = 'https://test.com/vast/?zid=AACBWAcof-611K4U&u=https://example.org/?foo=bar&gdpr=0&cs=XXXXXXXXXXXXXXXXXXXX&sid=01ecd03ce381505ccdeb88e555b05001&width=300&height=200&prebidmode=1'

const responseVideoV2 = {
'bidResponses': [{
Expand All @@ -443,7 +455,7 @@ describe('shBidAdapter', function () {
'bidResponses': [{
...basicResponseV2,
'context': 'outstream',
'ad': '<script id="testScript" data-wid="auto" type="text/javascript" src="https://ads.viralize.tv/display/?zid=AACBTwsZVANd9NlB&u=https%3A%2F%2Fexample.org%2F%3Ffoo%3Dbar&gdpr=0&cs=XXXXXXXXXXXXXXXXXXXX&sid=01ececb3b4c19270d6a77ccf75433001&width=300&height=200&prebidmode=1"></script>',
'ad': '<script id="testScript" data-wid="auto" type="text/javascript" src="https://test.tv/display/?zid=AACBTwsZVANd9NlB&u=https%3A%2F%2Fexample.org%2F%3Ffoo%3Dbar&gdpr=0&cs=XXXXXXXXXXXXXXXXXXXX&sid=01ececb3b4c19270d6a77ccf75433001&width=300&height=200&prebidmode=1"></script>',
}],
};

Expand Down Expand Up @@ -533,10 +545,6 @@ describe('shBidAdapter', function () {
expect(renderer.config.vastUrl).to.equal(vastTag)
renderer.render(bid)

// TODO: fix these. our tests should not be reliant on third-party scripts. wtf
// const scripts = document.querySelectorAll('script[src="https://static.showheroes.com/publishertag.js"]')
// expect(scripts.length).to.equal(1)

const spots = document.querySelectorAll('.showheroes-spot')
expect(spots.length).to.equal(1)
})
Expand Down Expand Up @@ -590,8 +598,6 @@ describe('shBidAdapter', function () {
renderer.render(bid)

const iframeDocument = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document)
// const scripts = iframeDocument.querySelectorAll('script[src="https://static.showheroes.com/publishertag.js"]')
// expect(scripts.length).to.equal(1)
const spots = iframeDocument.querySelectorAll('.showheroes-spot')
expect(spots.length).to.equal(1)
})
Expand All @@ -602,8 +608,6 @@ describe('shBidAdapter', function () {
customRender: function (bid, embedCode) {
const container = document.createElement('div')
container.appendChild(embedCode)
// const scripts = container.querySelectorAll('script[src="https://static.showheroes.com/publishertag.js"]')
// expect(scripts.length).to.equal(1)
const spots = container.querySelectorAll('.showheroes-spot')
expect(spots.length).to.equal(1)

Expand Down

0 comments on commit 4ca23f7

Please sign in to comment.