Skip to content

Commit

Permalink
Revert "Sublime Bid Adapter : refactoring notifyId, bid request valid…
Browse files Browse the repository at this point in the history
…ation, & device detection fix (#7327)"

This reverts commit ca5c28c.
  • Loading branch information
ChrisHuie authored Aug 25, 2021
1 parent d151e00 commit 0c2d2c2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 322 deletions.
71 changes: 13 additions & 58 deletions modules/sublimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ const DEFAULT_CURRENCY = 'EUR';
const DEFAULT_PROTOCOL = 'https';
const DEFAULT_TTL = 600;
const SUBLIME_ANTENNA = 'antenna.ayads.co';
const SUBLIME_VERSION = '0.8.0';
const SUBLIME_VERSION = '0.7.3';

/**
* Identify the current device type
* @returns {string}
*/
function detectDevice() {
const isMobile = /(?:phone|windows\s+phone|ipod|blackberry|Galaxy Nexus|SM-G892A|(?:android|bbd+|meego|silk|googlebot) .+?mobile|palm|windows\s+ce|opera mini|avantgo|docomo)/i;
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;
const isTablet = /(?:ipad|playbook|Tablet|(?:android|bb\\d+|meego|silk)(?! .+? mobile))/i;

return (
(isMobile.test(navigator.userAgent) && 'm') || // mobile
Expand All @@ -27,16 +27,6 @@ function detectDevice() {
);
}

const UUID_V4_RE = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i;
/**
* Checks whether a notifyId is well-formed
* @param {*} value
* @returns {boolean}
*/
function isValidNotifyId(value) {
return UUID_V4_RE.test(value);
}

/**
* Debug log message
* @param {String} msg
Expand All @@ -63,26 +53,6 @@ export function setState(value) {
log('State has been updated :', state);
}

/**
* Get a notifyId from bid params or from sublime global
* @param {Object} params - The bid params
* @return {string}
*/
function getNotifyId(params) {
const sublime = window.sublime = window.sublime || {};

let notifyId = params.notifyId || sublime.notifyId;
if (!notifyId) {
notifyId = utils.generateUUID();
log('generating a notifyId', notifyId);
}
if (!sublime.notifyId) {
sublime.notifyId = notifyId;
}

return notifyId;
}

/**
* Send pixel to our debug endpoint
* @param {string} eventName - Event name that will be send in the e= query string
Expand Down Expand Up @@ -121,16 +91,6 @@ export function sendEvent(eventName, sspName) {
* @return {Boolean} True if this is a valid bid, and false otherwise.
*/
function isBidRequestValid(bid) {
const notifyId = getNotifyId(bid.params);
if (!isValidNotifyId(notifyId)) {
log(`invalid notifyId format, got "${notifyId}"`);
return false;
}
if (notifyId !== window.sublime.notifyId) {
log(`notifyId mismatch: params [${bid.params.notifyId}] / sublime [${window.sublime.notifyId}]`);
return false;
}

return !!Number(bid.params.zoneId);
}

Expand Down Expand Up @@ -167,11 +127,9 @@ function buildRequests(validBidRequests, bidderRequest) {
const bidHost = bid.params.bidHost || DEFAULT_BID_HOST;
const protocol = bid.params.protocol || DEFAULT_PROTOCOL;

const notifyId = getNotifyId(bid.params);

setState({
transactionId: bid.transactionId,
notifyId,
notifyId: bid.params.notifyId,
zoneId: bid.params.zoneId,
debug: bid.params.debug || false,
});
Expand All @@ -188,7 +146,7 @@ function buildRequests(validBidRequests, bidderRequest) {
h: size[1],
})),
transactionId: bid.transactionId,
notifyId,
notifyId: bid.params.notifyId,
zoneId: bid.params.zoneId,
};

Expand Down Expand Up @@ -292,18 +250,15 @@ export const spec = {
code: BIDDER_CODE,
gvlid: BIDDER_GVLID,
aliases: [],
isBidRequestValid,
buildRequests,
interpretResponse,
onBidWon,
onTimeout,
isBidRequestValid: isBidRequestValid,
buildRequests: buildRequests,
interpretResponse: interpretResponse,
onBidWon: onBidWon,
onTimeout: onTimeout,
// Exposed for test purpose
sendEvent,
setState,
state,
detectDevice,
getNotifyId,
isValidNotifyId,
sendEvent: sendEvent,
setState: setState,
state: state,
};

registerBidder(spec);
Loading

0 comments on commit 0c2d2c2

Please sign in to comment.