Skip to content

Commit

Permalink
ucfunnel adapter update request parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhsiehucf committed Jun 1, 2020
1 parent 3004ad9 commit f34f753
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
36 changes: 30 additions & 6 deletions modules/ucfunnelBidAdapter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, VIDEO, NATIVE} from '../src/mediaTypes.js';

import { getStorageManager } from '../src/storageManager.js';
import * as utils from '../src/utils.js';
const storage = getStorageManager();
const COOKIE_NAME = 'ucf_uid';
const VER = 'ADGENT_PREBID-2018011501';
const BIDDER_CODE = 'ucfunnel';

Expand Down Expand Up @@ -183,9 +186,6 @@ function getSupplyChain(schain) {

function getRequestData(bid, bidderRequest) {
const size = parseSizes(bid);
const loc = window.location;
const host = loc.host;
const page = loc.href;
const language = navigator.language;
const dnt = (navigator.doNotTrack == 'yes' || navigator.doNotTrack == '1' || navigator.msDoNotTrack == '1') ? 1 : 0;
const userIdTdid = (bid.userId && bid.userId.tdid) ? bid.userId.tdid : '';
Expand All @@ -197,14 +197,38 @@ function getRequestData(bid, bidderRequest) {
bl: language,
je: 1,
dnt: dnt,
host: host,
u: page,
adid: bid.params.adid,
tdid: userIdTdid,
schain: supplyChain,
fp: bid.params.bidfloor
};

try {
bidData.host = window.top.location.hostname;
bidData.u = window.top.location.href;
bidData.xr = 0;
} catch (e) {
bidData.host = window.location.hostname;
bidData.u = document.referrer || window.location.href;
bidData.xr = 1;
}

if (window.location.ancestorOrigins && window.location.ancestorOrigins.length > 0) {
bidData.ao = window.location.ancestorOrigins[window.location.ancestorOrigins.length - 1];
}

if (storage.cookiesAreEnabled()) {
let ucfUid = '';
if (storage.getCookie(COOKIE_NAME) != undefined) {
ucfUid = storage.getCookie(COOKIE_NAME);
bidData.ucfUid = ucfUid;
} else {
ucfUid = utils.generateUUID();
bidData.ucfUid = ucfUid;
storage.setCookie(COOKIE_NAME, ucfUid);
}
}

if (size != undefined && size.length == 2) {
bidData.w = size[0];
bidData.h = size[1];
Expand Down
18 changes: 18 additions & 0 deletions test/spec/modules/ucfunnelBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,22 @@ describe('ucfunnel Adapter', function () {
});
});
});

describe('cookie sync', function () {
describe('cookie sync iframe', function () {
const result = spec.getUserSyncs({'iframeEnabled': true});

it('should return cookie sync iframe info', function () {
expect(result[0].type).to.equal('iframe');
expect(result[0].url).to.equal('https://cdn.aralego.net/ucfad/cookie/sync.html');
});
});
describe('cookie sync image', function () {
const result = spec.getUserSyncs({'pixelEnabled': true});
it('should return cookie sync image info', function () {
expect(result[0].type).to.equal('image');
expect(result[0].url).to.equal('https://sync.aralego.com/idSync');
});
});
});
});

0 comments on commit f34f753

Please sign in to comment.