From 199eb7dbffdffa368a6531024c1aab833c74ab4c Mon Sep 17 00:00:00 2001 From: Benoit Liabastre Date: Thu, 28 Oct 2021 23:23:35 +0200 Subject: [PATCH] Adomik Analytics Adapter: change bid.placementCode to bid.adUnitCode (#7610) * AdomikAnalyticsAdapter: change placementCode to adUnitCode * AdomikAnalyticsAdapter: split GET URLs only for MSIE browser --- modules/adomikAnalyticsAdapter.js | 14 ++++++++++---- test/spec/modules/adomikAnalyticsAdapter_spec.js | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/adomikAnalyticsAdapter.js b/modules/adomikAnalyticsAdapter.js index 5bbee86df54..99f079b2574 100644 --- a/modules/adomikAnalyticsAdapter.js +++ b/modules/adomikAnalyticsAdapter.js @@ -12,6 +12,7 @@ const bidRequested = CONSTANTS.EVENTS.BID_REQUESTED; const bidResponse = CONSTANTS.EVENTS.BID_RESPONSE; const bidWon = CONSTANTS.EVENTS.BID_WON; const bidTimeout = CONSTANTS.EVENTS.BID_TIMEOUT; +const ua = navigator.userAgent; let adomikAdapter = Object.assign(adapter({}), { @@ -47,7 +48,7 @@ let adomikAdapter = Object.assign(adapter({}), type: 'request', event: { bidder: bid.bidder.toUpperCase(), - placementCode: bid.placementCode + placementCode: bid.adUnitCode } }); }); @@ -67,6 +68,10 @@ adomikAdapter.initializeBucketEvents = function() { adomikAdapter.bucketEvents = []; } +adomikAdapter.maxPartLength = function () { + return (ua.includes(' MSIE ')) ? 1600 : 60000; +}; + adomikAdapter.sendTypedEvent = function() { const groupedTypedEvents = adomikAdapter.buildTypedEvents(); @@ -108,9 +113,10 @@ adomikAdapter.sendTypedEvent = function() { // Encode object in base64 const encodedBuf = window.btoa(stringBulkEvents); - // Create final url and split it in 1600 characters max (+endpoint length) + // Create final url and split it (+endpoint length) const encodedUri = encodeURIComponent(encodedBuf); - const splittedUrl = encodedUri.match(/.{1,1600}/g); + const maxLength = adomikAdapter.maxPartLength(); + const splittedUrl = encodedUri.match(new RegExp(`.{1,${maxLength}}`, 'g')); splittedUrl.forEach((split, i) => { const partUrl = `${split}&id=${adomikAdapter.currentContext.id}&part=${i}&on=${splittedUrl.length - 1}`; @@ -121,7 +127,7 @@ adomikAdapter.sendTypedEvent = function() { adomikAdapter.sendWonEvent = function (wonEvent) { const stringWonEvent = JSON.stringify(wonEvent) - logInfo('Won event sent to adomik prebid analytic ' + wonEvent); + logInfo('Won event sent to adomik prebid analytic ' + stringWonEvent); // Encode object in base64 const encodedBuf = window.btoa(stringWonEvent); diff --git a/test/spec/modules/adomikAnalyticsAdapter_spec.js b/test/spec/modules/adomikAnalyticsAdapter_spec.js index 1414b2402b9..8f87c73f1b4 100644 --- a/test/spec/modules/adomikAnalyticsAdapter_spec.js +++ b/test/spec/modules/adomikAnalyticsAdapter_spec.js @@ -1,5 +1,6 @@ import adomikAnalytics from 'modules/adomikAnalyticsAdapter.js'; import {expect} from 'chai'; + let events = require('src/events'); let adapterManager = require('src/adapterManager').default; let constants = require('src/constants.json'); @@ -8,6 +9,7 @@ describe('Adomik Prebid Analytic', function () { let sendEventStub; let sendWonEventStub; let clock; + before(function () { clock = sinon.useFakeTimers(); }); @@ -91,7 +93,7 @@ describe('Adomik Prebid Analytic', function () { type: 'request', event: { bidder: 'BIDDERTEST', - placementCode: 'placementtest', + placementCode: '0000', } });