Skip to content

Commit

Permalink
GumGum: update jcsi object values (#5258)
Browse files Browse the repository at this point in the history
* updates jcsi object

* adds test for jcsi

* fix lint

* updates due to prebid rollback
  • Loading branch information
susyt authored Jun 5, 2020
1 parent 8d00d1e commit 02d5b67
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
10 changes: 8 additions & 2 deletions modules/gumgumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const storage = getStorageManager();
const BIDDER_CODE = 'gumgum'
const ALIAS_BIDDER_CODE = ['gg']
const BID_ENDPOINT = `https://g2.gumgum.com/hbid/imp`
const JCSI = { t: 0, rq: 8, pbv: '$prebid.version$' }
const SUPPORTED_MEDIA_TYPES = [BANNER, VIDEO]
const TIME_TO_LIVE = 60
const DELAY_REQUEST_TIME = 1800000; // setting to 30 mins
Expand Down Expand Up @@ -62,7 +63,7 @@ function _getBrowserParams(topWindowUrl) {
pu: topUrl,
ce: storage.cookiesAreEnabled(),
dpr: topWindow.devicePixelRatio || 1,
jcsi: encodeURIComponent(JSON.stringify({ t: 0, rq: 8 })),
jcsi: JSON.stringify(JCSI),
ogu: getOgURL()
}

Expand Down Expand Up @@ -323,7 +324,8 @@ function interpretResponse (serverResponse, bidRequest) {
cw: wrapper,
pag: {
pvid
}
},
jcsi
} = Object.assign(defaultResponse, serverResponseBody)
let data = bidRequest.data || {}
let product = data.pi
Expand All @@ -337,6 +339,10 @@ function interpretResponse (serverResponse, bidRequest) {
height = '1'
}

if (jcsi) {
serverResponseBody.jcsi = JCSI
}

// update Page View ID from server response
pageViewId = pvid

Expand Down
22 changes: 16 additions & 6 deletions test/spec/modules/gumgumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { newBidder } from 'src/adapters/bidderFactory.js';
import { spec } from 'modules/gumgumBidAdapter.js';

const ENDPOINT = 'https://g2.gumgum.com/hbid/imp';
const JCSI = { t: 0, rq: 8, pbv: '$prebid.version$' }

describe('gumgumAdapter', function () {
const adapter = newBidder(spec);
Expand Down Expand Up @@ -274,12 +275,13 @@ describe('gumgumAdapter', function () {
expect(bidRequest.data).to.not.include.any.keys('ns');
}
});
it('has jcsi param correctly encoded', function () {
const jcsi = JSON.stringify({ t: 0, rq: 8 });
const encodedJCSI = encodeURIComponent(jcsi);
it('adds jcsi param with correct keys', function () {
const expectedKeys = Object.keys(JCSI).sort();
const jcsi = JSON.stringify(JCSI);
const bidRequest = spec.buildRequests(bidRequests)[0];
expect(bidRequest.data.jcsi).to.not.contain(/\{.*\}/);
expect(bidRequest.data.jcsi).to.eq(encodedJCSI);
const actualKeys = Object.keys(JSON.parse(bidRequest.data.jcsi)).sort();
expect(actualKeys).to.eq(actualKeys);
expect(bidRequest.data.jcsi).to.eq(jcsi);
});
})

Expand All @@ -304,6 +306,7 @@ describe('gumgumAdapter', function () {
'css': 'html { overflow-y: auto }',
'js': 'console.log("environment", env);'
},
'jcsi': { t: 0, rq: 8 },
'thms': 10000
}
let bidRequest = {
Expand Down Expand Up @@ -396,7 +399,14 @@ describe('gumgumAdapter', function () {
let result = spec.interpretResponse({ body: inscreenServerResponse }, inscreenBidRequest);
expect(result[0].width).to.equal('1');
expect(result[0].height).to.equal('1');
})
});

it('updates jcsi object when the server response jcsi prop is found', function () {
const response = Object.assign({cw: 'AD_JSON'}, serverResponse);
const bidResponse = spec.interpretResponse({ body: response }, bidRequest)[0].ad;
const decodedResponse = JSON.parse(atob(bidResponse));
expect(decodedResponse.jcsi).to.eql(JCSI);
});
})
describe('getUserSyncs', function () {
const syncOptions = {
Expand Down

0 comments on commit 02d5b67

Please sign in to comment.