Skip to content

Commit 1b26c62

Browse files
committed
Medianet analytics adapter updates
1 parent 981c0dd commit 1b26c62

File tree

4 files changed

+39
-40
lines changed

4 files changed

+39
-40
lines changed

libraries/medianetUtils/constants.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ export const mnetGlobals = {
99
refererInfo: null,
1010
};
1111

12-
export const LOGGING_DELAY = 2000;
13-
14-
export const LOG_TYPE_ID = 'kfk';
15-
export const LOG_EVT_ID = 'projectevents';
12+
export const LOGGING_DELAY = 500;
1613
export const EVENT_PIXEL_URL = 'https://qsearch-a.akamaihd.net/log';
1714
export const POST_ENDPOINT = 'https://navvy.media.net/log';
18-
export const GET_ENDPOINT = 'https://pb-logs.media.net/log';
15+
export const POST_ENDPOINT_RA = 'https://navvy.media.net/clog';
16+
export const GET_ENDPOINT_RA = 'https://pb-logs.media.net/clog';
1917
export const ANALYTICS_VERSION = '2.0.0';
2018
export const PREBID_VERSION = '$prebid.version$';
2119
export const MEDIANET = 'medianet';
@@ -41,7 +39,6 @@ export const DBF_PRIORITY = {
4139
};
4240

4341
// Properties
44-
export const SEND_ALL_BID_PROP = 'enableSendAllBids';
4542
export const AUCTION_OPTIONS = 'auctionOptions';
4643

4744
// Errors
@@ -55,7 +52,7 @@ export const ERROR_IWB_BID_MISSING = 'iwb_bid_missing';
5552
export const CONFIG_PENDING = 0;
5653
export const CONFIG_PASS = 1;
5754
export const CONFIG_ERROR = 3;
58-
export const DEFAULT_LOGGING_PERCENT = 50;
55+
export const DEFAULT_LOGGING_PERCENT = 10;
5956
export const CONFIG_URL = 'https://prebid.media.net/rtb/prebid/analytics/config';
6057
// Dummy Bidder
6158
export const DUMMY_BIDDER = '-2';
@@ -76,3 +73,8 @@ export const VIDEO_PLACEMENT = {
7673
// Log Types
7774
export const LOG_APPR = 'APPR';
7875
export const LOG_RA = 'RA';
76+
export const LOGGING_TOPICS = {
77+
[LOG_RA]: 'pba_aw',
78+
[LOG_APPR]: 'prebid_analytics_events_client',
79+
PROJECT_EVENTS: 'projectevents',
80+
};

libraries/medianetUtils/logKeys.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const KeysMap = {
3838
'bidderRequests.0.ortb2.sup_log',
3939
'bidderRequests.0.bids.0.floorData',
4040
'bidderRequests.0.refererInfo',
41-
'bidderRequests.0 as consentInfo', (consentInfo) => pick(consentInfo, ['gdprConsent', 'uspConsent']),
41+
'bidderRequests.0 as consentInfo', (consentInfo) => pick(consentInfo, ['gdprConsent', 'uspConsent', 'gppConsent']),
4242
],
4343
AdSlot: [
4444
'code',
@@ -139,7 +139,7 @@ export const KeysMap = {
139139
'supcrid',
140140
'code as og_supcrid',
141141
'context as vplcmtt', (context) => VIDEO_PLACEMENT[context] || 0,
142-
'ortb2Imp.instl as oop',
142+
'ortb2Imp.instl as instl', (instl) => instl || 0,
143143
'targeting as targ', (targeting) => safeJSONEncode(targeting),
144144
'adext', (adext) => encodeURIComponent(safeJSONEncode(adext)),
145145
],
@@ -149,6 +149,8 @@ export const KeysMap = {
149149
'consentInfo.gdprConsent.consentString as gdprConsent',
150150
'consentInfo.uspConsent as ccpa',
151151
'consentInfo.gdprConsent.gdprApplies as gdpr', (gdprApplies) => (gdprApplies ? '1' : '0'),
152+
'consentInfo.gppConsent.gppString as gpp_str',
153+
'consentInfo.gppConsent.applicableSections as gpp_sid', (applicableSections) => safeJSONEncode(applicableSections),
152154
'coppa', () => (config.getConfig('coppa') === true ? 1 : 0),
153155
'hasEnded as aucstatus', (hasEnded) => (hasEnded ? AUCTION_COMPLETED : AUCTION_IN_PROGRESS),
154156
'availableUids as uid_mod_avb', (availableUids) => safeJSONEncode(availableUids),

libraries/medianetUtils/logger.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { formatQS, triggerPixel, isPlainObject } from '../../src/utils.js';
33
import {
44
ANALYTICS_VERSION, BID_SUCCESS,
55
EVENT_PIXEL_URL, LOG_APPR,
6-
LOG_EVT_ID,
7-
LOG_TYPE_ID,
6+
LOGGING_TOPICS,
87
mnetGlobals, POST_ENDPOINT,
98
PREBID_VERSION
109
} from './constants.js';
@@ -28,8 +27,8 @@ export function errorLogger(event, data = undefined, analytics = true) {
2827
const refererInfo = mnetGlobals.refererInfo || getRefererInfo();
2928
const errorData = Object.assign({},
3029
{
31-
logid: LOG_TYPE_ID,
32-
evtid: LOG_EVT_ID,
30+
logid: 'kfk',
31+
evtid: LOGGING_TOPICS.PROJECT_EVENTS,
3332
project: project || (analytics ? 'prebidanalytics' : 'prebid'),
3433
dn: refererInfo.domain || '',
3534
requrl: refererInfo.topmostLocation || '',
@@ -47,7 +46,7 @@ export function errorLogger(event, data = undefined, analytics = true) {
4746

4847
function send() {
4948
if (!analytics) {
50-
fireAjaxLog(loggingHost, payload, pick(errorData, ['cid', 'project', 'event as value']));
49+
fireAjaxLog(loggingHost, payload, pick(errorData, ['cid', 'project', 'name as value']));
5150
return;
5251
}
5352
const pixelUrl = getUrl();
@@ -65,26 +64,28 @@ export function errorLogger(event, data = undefined, analytics = true) {
6564
};
6665
}
6766

68-
export function getLoggingPayload(queryParams) {
69-
return `logid=kfk&evtid=prebid_analytics_events_client&${queryParams}`;
67+
// Log generation for APPR & RA
68+
export function getLoggingPayload(queryParams, logType) {
69+
const loggingTopic = LOGGING_TOPICS[logType];
70+
return `logid=kfk&evtid=${loggingTopic}&${queryParams}`;
7071
}
7172

72-
export function firePostLog(url, payload) {
73+
export function firePostLog(loggingHost, payload) {
7374
try {
74-
mnetGlobals.logsQueue.push(url + '?' + payload);
75-
const isSent = sendBeacon(url, payload);
75+
mnetGlobals.logsQueue.push(loggingHost + '?' + payload);
76+
const isSent = sendBeacon(loggingHost, payload);
7677
if (!isSent) {
77-
fireAjaxLog(url, payload);
78+
fireAjaxLog(loggingHost, payload);
7879
errorLogger('sb_log_failed').send();
7980
}
8081
} catch (e) {
81-
fireAjaxLog(url, payload);
82+
fireAjaxLog(loggingHost, payload);
8283
errorLogger('sb_not_supported').send();
8384
}
8485
}
8586

86-
export function fireAjaxLog(url, payload, errorData = {}) {
87-
ajax(url,
87+
export function fireAjaxLog(loggingHost, payload, errorData = {}) {
88+
ajax(loggingHost,
8889
{
8990
success: () => undefined,
9091
error: (_, {reason}) => errorLogger(Object.assign(errorData, {name: 'ajax_log_failed', relatedData: reason})).send()

modules/medianetAnalyticsAdapter.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,20 @@ import {
4949
DUMMY_BIDDER,
5050
ERROR_CONFIG_FETCH,
5151
ERROR_CONFIG_JSON_PARSE,
52-
GET_ENDPOINT,
52+
GET_ENDPOINT_RA,
5353
GLOBAL_VENDOR_ID,
5454
LOG_APPR,
5555
LOG_RA,
5656
mnetGlobals,
5757
NOBID_AFTER_AUCTION,
5858
PBS_ERROR_STATUS_START,
5959
POST_ENDPOINT,
60-
SEND_ALL_BID_PROP,
6160
SUCCESS_AFTER_AUCTION,
6261
TIMEOUT_AFTER_AUCTION,
6362
VIDEO_CONTEXT,
6463
VIDEO_UUID_PENDING,
6564
WINNING_AUCTION_MISSING_ERROR,
66-
WINNING_BID_ABSENT_ERROR, ERROR_IWB_BID_MISSING
65+
WINNING_BID_ABSENT_ERROR, ERROR_IWB_BID_MISSING, POST_ENDPOINT_RA
6766
} from '../libraries/medianetUtils/constants.js';
6867
import {getGlobal} from '../src/prebidGlobal.js';
6968

@@ -156,9 +155,9 @@ function initConfiguration(eventType, configuration) {
156155
// ======================[ LOGGING AND TRACKING ]===========================
157156
function doLogging(auctionObj, adUnitCode, logType, bidObj) {
158157
const queryParams = getQueryString(auctionObj, adUnitCode, logType, bidObj);
159-
// Use the generated queryParams for logging
160-
const payload = getLoggingPayload(queryParams);
161-
firePostLog(POST_ENDPOINT, payload);
158+
const loggingHost = (logType === LOG_RA) ? POST_ENDPOINT_RA : POST_ENDPOINT;
159+
const payload = getLoggingPayload(queryParams, logType);
160+
firePostLog(loggingHost, payload);
162161
auctionObj.adSlots[adUnitCode].logged[logType] = true;
163162
}
164163

@@ -216,7 +215,7 @@ function vastTrackerHandler(bidResponse, { auction, bidRequest }) {
216215
return [
217216
{
218217
event: 'impressions',
219-
url: `${GET_ENDPOINT}?${getLoggingPayload(queryParams)}`,
218+
url: `${GET_ENDPOINT_RA}?${getLoggingPayload(queryParams, LOG_RA)}`,
220219
},
221220
];
222221
} catch (e) {
@@ -332,8 +331,6 @@ function isHigher(newBid, currentBid = {}) {
332331
}
333332

334333
function markWinningBidsAndImpressionStatus(auctionObj) {
335-
const sendAllBidsEnabled = config.getConfig(SEND_ALL_BID_PROP) === true;
336-
337334
const updatePsiBid = (winner, adUnitCode, winnersAdIds) => {
338335
const psiBidObj = findBidObj(auctionObj.psiBids, 'adUnitCode', adUnitCode);
339336
if (!psiBidObj) {
@@ -354,15 +351,12 @@ function markWinningBidsAndImpressionStatus(auctionObj) {
354351
};
355352

356353
const markValidBidsAsWinners = (winnersAdIds) => {
357-
if (!sendAllBidsEnabled) {
358-
return;
359-
}
360354
winnersAdIds.forEach((adId) => {
361-
const sendAllWinnerBid = findBidObj(auctionObj.bidsReceived, 'adId', adId);
362-
if (sendAllWinnerBid) {
363-
sendAllWinnerBid.iwb = 1;
364-
}
365-
});
355+
const winnerBid = findBidObj(auctionObj.bidsReceived, 'adId', adId);
356+
if (winnerBid) {
357+
winnerBid.iwb = 1;
358+
}
359+
});
366360
};
367361

368362
const checkWinnersForIwb = (winner, winningBidObj) => {

0 commit comments

Comments
 (0)