From 81a9e2b432a5e1c6d1692d330fff7b1b0bcdbd39 Mon Sep 17 00:00:00 2001 From: Jeremie Patonnier Date: Fri, 19 Mar 2021 15:43:19 +0100 Subject: [PATCH] Sublime Bid Adapter: v0.7.1 & add extra information in tracking pixels (#6442) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add prebid version of adapter * Feature/update sublime adapter (#21) * Update sublimeBidAdapter to 0.5.1 * Add tests for private functions * Remove window.sublime * Update pixel name for bid event * Remove pixels on non-event and add onBidWon (#22) * add prebid version of adapter * Feature/update sublime adapter (#21) * Update sublimeBidAdapter to 0.5.1 * Add tests for private functions * Remove window.sublime * Update pixel name for bid event * Remove pixels on non-event and add onBidWon * Incremente version of sublimeBidAdapter * Renamed pixel for timeout and introduce gvlid * Remove unnecessary params for sendEvent Co-Authored-By: fgcloutier Co-authored-by: Gaby Co-authored-by: fgcloutier * Remove trailing-space * Fix version in tests * sublimeAdapter: Improve pixels data * sublimeAdapter: Update tests * sublimeAdapter: Rename data Co-authored-by: Gaby Co-authored-by: Léo <51166933+SublimeLeo@users.noreply.github.com> Co-authored-by: fgcloutier Co-authored-by: Léo GRAND --- modules/sublimeBidAdapter.js | 33 ++++++++++++++++++--- test/spec/modules/sublimeBidAdapter_spec.js | 15 ++++++++-- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/modules/sublimeBidAdapter.js b/modules/sublimeBidAdapter.js index 7a573ca4c4b..41fdb72e76e 100644 --- a/modules/sublimeBidAdapter.js +++ b/modules/sublimeBidAdapter.js @@ -9,7 +9,23 @@ const DEFAULT_CURRENCY = 'EUR'; const DEFAULT_PROTOCOL = 'https'; const DEFAULT_TTL = 600; const SUBLIME_ANTENNA = 'antenna.ayads.co'; -const SUBLIME_VERSION = '0.7.0'; +const SUBLIME_VERSION = '0.7.1'; + +/** + * Identify the current device type + * @returns {string} + */ +function detectDevice() { + const isMobile = /(?:phone|windowss+phone|ipod|blackberry|Galaxy Nexus|SM-G892A|(?:android|bbd+|meego|silk|googlebot) .+?mobile|palm|windowss+ce|opera mini|avantgo|docomo)/i; + + const isTablet = /(?:ipad|playbook|Tablet|(?:android|bb\\d+|meego|silk)(?! .+? mobile))/i; + + return ( + (isMobile.test(navigator.userAgent) && 'm') || // mobile + (isTablet.test(navigator.userAgent) && 't') || // tablet + 'd' // desktop + ); +} /** * Debug log message @@ -39,8 +55,9 @@ export function setState(value) { /** * Send pixel to our debug endpoint * @param {string} eventName - Event name that will be send in the e= query string + * @param {string} [sspName] - The optionnal name of the AD provider */ -export function sendEvent(eventName) { +export function sendEvent(eventName, sspName) { const ts = Date.now(); const eventObject = { t: ts, @@ -51,8 +68,15 @@ export function sendEvent(eventName) { puid: state.transactionId || state.notifyId, trId: state.transactionId || state.notifyId, pbav: SUBLIME_VERSION, + pubtimeout: config.getConfig('bidderTimeout'), + pubpbv: '$prebid.version$', + device: detectDevice(), }; + if (eventName === 'bidwon') { + eventObject.sspname = sspName || ''; + } + log('Sending pixel for event: ' + eventName, eventObject); const queryString = utils.formatQS(eventObject); @@ -179,7 +203,8 @@ function interpretResponse(serverResponse, bidRequest) { netRevenue: response.netRevenue || true, ttl: response.ttl || DEFAULT_TTL, ad: response.ad, - pbav: SUBLIME_VERSION + pbav: SUBLIME_VERSION, + sspname: response.sspname || null }; bidResponses.push(bidResponse); @@ -194,7 +219,7 @@ function interpretResponse(serverResponse, bidRequest) { */ function onBidWon(bid) { log('Bid won', bid); - sendEvent('bidwon'); + sendEvent('bidwon', bid.sspname); } /** diff --git a/test/spec/modules/sublimeBidAdapter_spec.js b/test/spec/modules/sublimeBidAdapter_spec.js index a0765a0d396..2e1d65f0533 100644 --- a/test/spec/modules/sublimeBidAdapter_spec.js +++ b/test/spec/modules/sublimeBidAdapter_spec.js @@ -18,6 +18,9 @@ describe('Sublime Adapter', function() { 'puid', 'trId', 'pbav', + 'pubpbv', + 'device', + 'pubtimeout', ]; beforeEach(function () { @@ -139,6 +142,7 @@ describe('Sublime Adapter', function() { describe('interpretResponse', function() { let serverResponse = { 'request_id': '3db3773286ee59', + 'sspname': 'foo', 'cpm': 0.5, 'ad': '', }; @@ -160,9 +164,10 @@ describe('Sublime Adapter', function() { creativeId: 1, dealId: 1, currency: 'USD', + sspname: 'foo', netRevenue: true, ttl: 600, - pbav: '0.7.0', + pbav: '0.7.1', ad: '', }, ]; @@ -173,6 +178,7 @@ describe('Sublime Adapter', function() { it('should get correct default size for 1x1', function() { let serverResponse = { 'requestId': 'xyz654_2', + 'sspname': 'sublime', 'cpm': 0.5, 'ad': '', }; @@ -204,7 +210,8 @@ describe('Sublime Adapter', function() { netRevenue: true, ttl: 600, ad: '', - pbav: '0.7.0', + pbav: '0.7.1', + sspname: 'sublime' }; expect(result[0]).to.deep.equal(expectedResponse); @@ -224,6 +231,7 @@ describe('Sublime Adapter', function() { it('should return bid with default value in response', function () { let serverResponse = { 'requestId': 'xyz654_2', + 'sspname': 'sublime', 'ad': '', }; @@ -251,10 +259,11 @@ describe('Sublime Adapter', function() { creativeId: 1, dealId: 1, currency: 'EUR', + sspname: 'sublime', netRevenue: true, ttl: 600, ad: '', - pbav: '0.7.0', + pbav: '0.7.1', }; expect(result[0]).to.deep.equal(expectedResponse);