Skip to content

Commit

Permalink
PBJS RP adapter: pass analytics flag to server (#6644)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoschovas authored and idettman committed May 21, 2021
1 parent 96192df commit f18b978
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/rubiconBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory.js';
import {config} from '../src/config.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import find from 'core-js-pure/features/array/find.js';
import { getGlobal } from '../src/prebidGlobal.js';

const DEFAULT_INTEGRATION = 'pbjs_lite';
const DEFAULT_PBS_INTEGRATION = 'pbjs';
Expand Down Expand Up @@ -196,6 +197,11 @@ export const spec = {
}
}

let modules = (getGlobal()).installedModules;
if (modules && (!modules.length || modules.indexOf('rubiconAnalyticsAdapter') !== -1)) {
utils.deepSetValue(data, 'ext.prebid.analytics', [{ 'adapter': 'rubicon', 'client-analytics': true }]);
}

let bidFloor;
if (typeof bidRequest.getFloor === 'function' && !rubiConf.disableFloors) {
let floorInfo;
Expand Down
30 changes: 30 additions & 0 deletions test/spec/modules/rubiconBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ describe('the rubicon adapter', function () {
utils.logError.restore();
config.resetConfig();
resetRubiConf();
delete $$PREBID_GLOBAL$$.installedModules;
});

describe('MAS mapping / ordering', function () {
Expand Down Expand Up @@ -1696,6 +1697,35 @@ describe('the rubicon adapter', function () {
expect(request.data.ext.prebid.multibid).to.deep.equal(expected);
});

it('should pass client analytics to PBS endpoint if all modules included', function () {
createVideoBidderRequest();
$$PREBID_GLOBAL$$.installedModules = [];
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let payload = request.data;

expect(payload.ext.prebid.analytics).to.not.be.undefined;
expect(payload.ext.prebid.analytics).to.deep.equal([{'adapter': 'rubicon', 'client-analytics': true}]);
});

it('should pass client analytics to PBS endpoint if rubicon analytics adapter is included', function () {
createVideoBidderRequest();
$$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter', 'rubiconAnalyticsAdapter'];
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let payload = request.data;

expect(payload.ext.prebid.analytics).to.not.be.undefined;
expect(payload.ext.prebid.analytics).to.deep.equal([{'adapter': 'rubicon', 'client-analytics': true}]);
});

it('should not pass client analytics to PBS endpoint if rubicon analytics adapter is not included', function () {
createVideoBidderRequest();
$$PREBID_GLOBAL$$.installedModules = ['rubiconBidAdapter'];
let [request] = spec.buildRequests(bidderRequest.bids, bidderRequest);
let payload = request.data;

expect(payload.ext.prebid.analytics).to.be.undefined;
});

it('should send video exp param correctly when set', function () {
createVideoBidderRequest();
config.setConfig({s2sConfig: {defaultTtl: 600}});
Expand Down

0 comments on commit f18b978

Please sign in to comment.