Skip to content

Medianet Analytics Adapter : updates to endpoint configuration and logging behavior #13403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/scripts/codepath-notification
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ rubicon|magnite : [email protected]
appnexus : [email protected]
pubmatic : [email protected]
openx : [email protected]
medianet : [email protected]
(modules|libraries)/medianet : [email protected]
16 changes: 9 additions & 7 deletions libraries/medianetUtils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ export const mnetGlobals = {
refererInfo: null,
};

export const LOGGING_DELAY = 2000;

export const LOG_TYPE_ID = 'kfk';
export const LOG_EVT_ID = 'projectevents';
export const LOGGING_DELAY = 500;
export const EVENT_PIXEL_URL = 'https://qsearch-a.akamaihd.net/log';
export const POST_ENDPOINT = 'https://navvy.media.net/log';
export const GET_ENDPOINT = 'https://pb-logs.media.net/log';
export const POST_ENDPOINT_RA = 'https://navvy.media.net/clog';
export const GET_ENDPOINT_RA = 'https://pb-logs.media.net/clog';
export const ANALYTICS_VERSION = '2.0.0';
export const PREBID_VERSION = '$prebid.version$';
export const MEDIANET = 'medianet';
Expand All @@ -41,7 +39,6 @@ export const DBF_PRIORITY = {
};

// Properties
export const SEND_ALL_BID_PROP = 'enableSendAllBids';
export const AUCTION_OPTIONS = 'auctionOptions';

// Errors
Expand All @@ -55,7 +52,7 @@ export const ERROR_IWB_BID_MISSING = 'iwb_bid_missing';
export const CONFIG_PENDING = 0;
export const CONFIG_PASS = 1;
export const CONFIG_ERROR = 3;
export const DEFAULT_LOGGING_PERCENT = 50;
export const DEFAULT_LOGGING_PERCENT = 10;
export const CONFIG_URL = 'https://prebid.media.net/rtb/prebid/analytics/config';
// Dummy Bidder
export const DUMMY_BIDDER = '-2';
Expand All @@ -76,3 +73,8 @@ export const VIDEO_PLACEMENT = {
// Log Types
export const LOG_APPR = 'APPR';
export const LOG_RA = 'RA';
export const LOGGING_TOPICS = {
[LOG_RA]: 'pba_aw',
[LOG_APPR]: 'prebid_analytics_events_client',
PROJECT_EVENTS: 'projectevents',
};
6 changes: 4 additions & 2 deletions libraries/medianetUtils/logKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const KeysMap = {
'bidderRequests.0.ortb2.sup_log',
'bidderRequests.0.bids.0.floorData',
'bidderRequests.0.refererInfo',
'bidderRequests.0 as consentInfo', (consentInfo) => pick(consentInfo, ['gdprConsent', 'uspConsent']),
'bidderRequests.0 as consentInfo', (consentInfo) => pick(consentInfo, ['gdprConsent', 'uspConsent', 'gppConsent']),
],
AdSlot: [
'code',
Expand Down Expand Up @@ -139,7 +139,7 @@ export const KeysMap = {
'supcrid',
'code as og_supcrid',
'context as vplcmtt', (context) => VIDEO_PLACEMENT[context] || 0,
'ortb2Imp.instl as oop',
'ortb2Imp.instl as instl', (instl) => instl || 0,
'targeting as targ', (targeting) => safeJSONEncode(targeting),
'adext', (adext) => encodeURIComponent(safeJSONEncode(adext)),
],
Expand All @@ -149,6 +149,8 @@ export const KeysMap = {
'consentInfo.gdprConsent.consentString as gdprConsent',
'consentInfo.uspConsent as ccpa',
'consentInfo.gdprConsent.gdprApplies as gdpr', (gdprApplies) => (gdprApplies ? '1' : '0'),
'consentInfo.gppConsent.gppString as gpp_str',
'consentInfo.gppConsent.applicableSections as gpp_sid', (applicableSections) => safeJSONEncode(applicableSections),
'coppa', () => (config.getConfig('coppa') === true ? 1 : 0),
'hasEnded as aucstatus', (hasEnded) => (hasEnded ? AUCTION_COMPLETED : AUCTION_IN_PROGRESS),
'availableUids as uid_mod_avb', (availableUids) => safeJSONEncode(availableUids),
Expand Down
29 changes: 15 additions & 14 deletions libraries/medianetUtils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { formatQS, triggerPixel, isPlainObject } from '../../src/utils.js';
import {
ANALYTICS_VERSION, BID_SUCCESS,
EVENT_PIXEL_URL, LOG_APPR,
LOG_EVT_ID,
LOG_TYPE_ID,
LOGGING_TOPICS,
mnetGlobals, POST_ENDPOINT,
PREBID_VERSION
} from './constants.js';
Expand All @@ -28,8 +27,8 @@ export function errorLogger(event, data = undefined, analytics = true) {
const refererInfo = mnetGlobals.refererInfo || getRefererInfo();
const errorData = Object.assign({},
{
logid: LOG_TYPE_ID,
evtid: LOG_EVT_ID,
logid: 'kfk',
evtid: LOGGING_TOPICS.PROJECT_EVENTS,
project: project || (analytics ? 'prebidanalytics' : 'prebid'),
dn: refererInfo.domain || '',
requrl: refererInfo.topmostLocation || '',
Expand All @@ -47,7 +46,7 @@ export function errorLogger(event, data = undefined, analytics = true) {

function send() {
if (!analytics) {
fireAjaxLog(loggingHost, payload, pick(errorData, ['cid', 'project', 'event as value']));
fireAjaxLog(loggingHost, payload, pick(errorData, ['cid', 'project', 'name as value']));
return;
}
const pixelUrl = getUrl();
Expand All @@ -65,26 +64,28 @@ export function errorLogger(event, data = undefined, analytics = true) {
};
}

export function getLoggingPayload(queryParams) {
return `logid=kfk&evtid=prebid_analytics_events_client&${queryParams}`;
// Log generation for APPR & RA
export function getLoggingPayload(queryParams, logType) {
const loggingTopic = LOGGING_TOPICS[logType];
return `logid=kfk&evtid=${loggingTopic}&${queryParams}`;
}

export function firePostLog(url, payload) {
export function firePostLog(loggingHost, payload) {
try {
mnetGlobals.logsQueue.push(url + '?' + payload);
const isSent = sendBeacon(url, payload);
mnetGlobals.logsQueue.push(loggingHost + '?' + payload);
const isSent = sendBeacon(loggingHost, payload);
if (!isSent) {
fireAjaxLog(url, payload);
fireAjaxLog(loggingHost, payload);
errorLogger('sb_log_failed').send();
}
} catch (e) {
fireAjaxLog(url, payload);
fireAjaxLog(loggingHost, payload);
errorLogger('sb_not_supported').send();
}
}

export function fireAjaxLog(url, payload, errorData = {}) {
ajax(url,
export function fireAjaxLog(loggingHost, payload, errorData = {}) {
ajax(loggingHost,
{
success: () => undefined,
error: (_, {reason}) => errorLogger(Object.assign(errorData, {name: 'ajax_log_failed', relatedData: reason})).send()
Expand Down
28 changes: 11 additions & 17 deletions modules/medianetAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,20 @@ import {
DUMMY_BIDDER,
ERROR_CONFIG_FETCH,
ERROR_CONFIG_JSON_PARSE,
GET_ENDPOINT,
GET_ENDPOINT_RA,
GLOBAL_VENDOR_ID,
LOG_APPR,
LOG_RA,
mnetGlobals,
NOBID_AFTER_AUCTION,
PBS_ERROR_STATUS_START,
POST_ENDPOINT,
SEND_ALL_BID_PROP,
SUCCESS_AFTER_AUCTION,
TIMEOUT_AFTER_AUCTION,
VIDEO_CONTEXT,
VIDEO_UUID_PENDING,
WINNING_AUCTION_MISSING_ERROR,
WINNING_BID_ABSENT_ERROR, ERROR_IWB_BID_MISSING
WINNING_BID_ABSENT_ERROR, ERROR_IWB_BID_MISSING, POST_ENDPOINT_RA
} from '../libraries/medianetUtils/constants.js';
import {getGlobal} from '../src/prebidGlobal.js';

Expand Down Expand Up @@ -156,9 +155,9 @@ function initConfiguration(eventType, configuration) {
// ======================[ LOGGING AND TRACKING ]===========================
function doLogging(auctionObj, adUnitCode, logType, bidObj) {
const queryParams = getQueryString(auctionObj, adUnitCode, logType, bidObj);
// Use the generated queryParams for logging
const payload = getLoggingPayload(queryParams);
firePostLog(POST_ENDPOINT, payload);
const loggingHost = (logType === LOG_RA) ? POST_ENDPOINT_RA : POST_ENDPOINT;
const payload = getLoggingPayload(queryParams, logType);
firePostLog(loggingHost, payload);
auctionObj.adSlots[adUnitCode].logged[logType] = true;
}

Expand Down Expand Up @@ -216,7 +215,7 @@ function vastTrackerHandler(bidResponse, { auction, bidRequest }) {
return [
{
event: 'impressions',
url: `${GET_ENDPOINT}?${getLoggingPayload(queryParams)}`,
url: `${GET_ENDPOINT_RA}?${getLoggingPayload(queryParams, LOG_RA)}`,
},
];
} catch (e) {
Expand Down Expand Up @@ -332,8 +331,6 @@ function isHigher(newBid, currentBid = {}) {
}

function markWinningBidsAndImpressionStatus(auctionObj) {
const sendAllBidsEnabled = config.getConfig(SEND_ALL_BID_PROP) === true;

const updatePsiBid = (winner, adUnitCode, winnersAdIds) => {
const psiBidObj = findBidObj(auctionObj.psiBids, 'adUnitCode', adUnitCode);
if (!psiBidObj) {
Expand All @@ -354,15 +351,12 @@ function markWinningBidsAndImpressionStatus(auctionObj) {
};

const markValidBidsAsWinners = (winnersAdIds) => {
if (!sendAllBidsEnabled) {
return;
}
winnersAdIds.forEach((adId) => {
const sendAllWinnerBid = findBidObj(auctionObj.bidsReceived, 'adId', adId);
if (sendAllWinnerBid) {
sendAllWinnerBid.iwb = 1;
}
});
const winnerBid = findBidObj(auctionObj.bidsReceived, 'adId', adId);
if (winnerBid) {
winnerBid.iwb = 1;
}
});
};

const checkWinnersForIwb = (winner, winningBidObj) => {
Expand Down