From 517c2526aaa0ad1eea901e1881d8c6f1f0d0ce21 Mon Sep 17 00:00:00 2001 From: msm0504 <51493331+msm0504@users.noreply.github.com> Date: Mon, 22 Jul 2019 21:11:58 -0400 Subject: [PATCH] Rubicon integration type (#4008) * Add microadBidAdapter * Remove unnecessary encodeURIComponent from microadBidAdapter * Submit Advangelists Prebid Adapter * Submit Advangelists Prebid Adapter 1.1 * Correct procudtion endpoint for prebid * analytics update with wrapper name * reverted error merge * Update Rubicon Bid and Analytics Adapters to read int_type from config * Unit tests for changes to Rubicon bid and analytics adapters --- modules/rubiconAnalyticsAdapter.js | 4 +-- modules/rubiconBidAdapter.js | 6 +++-- .../modules/rubiconAnalyticsAdapter_spec.js | 27 +++++++++++++++++++ test/spec/modules/rubiconBidAdapter_spec.js | 13 +++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/modules/rubiconAnalyticsAdapter.js b/modules/rubiconAnalyticsAdapter.js index a00c727d470..e9e7daa59b3 100644 --- a/modules/rubiconAnalyticsAdapter.js +++ b/modules/rubiconAnalyticsAdapter.js @@ -28,7 +28,7 @@ config.getConfig('s2sConfig', ({s2sConfig}) => { }); export const SEND_TIMEOUT = 3000; -const INTEGRATION = 'pbjs'; +const DEFAULT_INTEGRATION = 'pbjs'; const cache = { auctions: {}, @@ -139,7 +139,7 @@ function sendMessage(auctionId, bidWonId) { let referrer = config.getConfig('pageUrl') || utils.getTopWindowUrl(); let message = { eventTimeMillis: Date.now(), - integration: INTEGRATION, + integration: config.getConfig('rubicon.int_type') || DEFAULT_INTEGRATION, version: '$prebid.version$', referrerUri: referrer }; diff --git a/modules/rubiconBidAdapter.js b/modules/rubiconBidAdapter.js index b4b8e98e393..d8b101b6318 100644 --- a/modules/rubiconBidAdapter.js +++ b/modules/rubiconBidAdapter.js @@ -3,7 +3,7 @@ import {registerBidder} from '../src/adapters/bidderFactory'; import {config} from '../src/config'; import {BANNER, VIDEO} from '../src/mediaTypes'; -const INTEGRATION = 'pbjs_lite_v$prebid.version$'; +const DEFAULT_INTEGRATION = 'pbjs_lite'; function isSecure() { return location.protocol === 'https:'; @@ -385,6 +385,8 @@ export const spec = { const [latitude, longitude] = params.latLong || []; + const configIntType = config.getConfig('rubicon.int_type'); + const data = { 'account_id': params.accountId, 'site_id': params.siteId, @@ -394,7 +396,7 @@ export const spec = { 'p_pos': params.position === 'atf' || params.position === 'btf' ? params.position : 'unknown', 'rp_floor': (params.floor = parseFloat(params.floor)) > 0.01 ? params.floor : 0.01, 'rp_secure': isSecure() ? '1' : '0', - 'tk_flint': INTEGRATION, + 'tk_flint': `${configIntType || DEFAULT_INTEGRATION}_v$prebid.version$`, 'x_source.tid': bidRequest.transactionId, 'p_screen_res': _getScreenResolution(), 'kw': Array.isArray(params.keywords) ? params.keywords.join(',') : '', diff --git a/test/spec/modules/rubiconAnalyticsAdapter_spec.js b/test/spec/modules/rubiconAnalyticsAdapter_spec.js index c6b0ca8d29f..5fb7fd7bf79 100644 --- a/test/spec/modules/rubiconAnalyticsAdapter_spec.js +++ b/test/spec/modules/rubiconAnalyticsAdapter_spec.js @@ -728,4 +728,31 @@ describe('rubicon analytics adapter', function () { expect(bidResponseObj.bidPriceUSD).to.equal(1.0); }); }); + + describe('config with integration type', () => { + it('should use the integration type provided in the config instead of the default', () => { + sandbox.stub(config, 'getConfig').callsFake(function (key) { + const config = { + 'rubicon.int_type': 'testType' + }; + return config[key]; + }); + + rubiconAnalyticsAdapter.enableAnalytics({ + options: { + endpoint: '//localhost:9999/event', + accountId: 1001 + } + }); + + performStandardAuction(); + + expect(requests.length).to.equal(1); + const request = requests[0]; + const message = JSON.parse(request.requestBody); + expect(message.integration).to.equal('testType'); + + rubiconAnalyticsAdapter.disableAnalytics(); + }); + }); }); diff --git a/test/spec/modules/rubiconBidAdapter_spec.js b/test/spec/modules/rubiconBidAdapter_spec.js index 0ad20001536..988b518f348 100644 --- a/test/spec/modules/rubiconBidAdapter_spec.js +++ b/test/spec/modules/rubiconBidAdapter_spec.js @@ -2011,6 +2011,19 @@ describe('the rubicon adapter', function () { expect(bids[0].height).to.equal(480); }); }); + + describe('config with integration type', () => { + it('should use the integration type provided in the config instead of the default', () => { + sandbox.stub(config, 'getConfig').callsFake(function (key) { + const config = { + 'rubicon.int_type': 'testType' + }; + return config[key]; + }); + const [request] = spec.buildRequests(bidderRequest.bids, bidderRequest); + expect(parseQuery(request.data).tk_flint).to.equal('testType_v$prebid.version$'); + }); + }); }); });