Skip to content
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

Remove pixels on non-event and add onBidWon #22

Merged
merged 7 commits into from
Apr 8, 2020
Merged
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
37 changes: 19 additions & 18 deletions modules/sublimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import * as utils from '../src/utils.js';
import * as url from '../src/url.js';

const BIDDER_CODE = 'sublime';
const BIDDER_GVLID = 114;
const DEFAULT_BID_HOST = 'pbjs.sskzlabs.com';
const DEFAULT_CURRENCY = 'EUR';
const DEFAULT_PROTOCOL = 'https';
const DEFAULT_TTL = 600;
const SUBLIME_ANTENNA = 'antenna.ayads.co';
const SUBLIME_VERSION = '0.5.1';
const SUBLIME_VERSION = '0.5.2';

/**
* Debug log message
Expand Down Expand Up @@ -38,10 +39,8 @@ 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 {Boolean=} isMandatoryPixel - If set to true, will always send the pixel
*/
export function sendEvent(eventName, isMandatoryPixel = false) {
const shoudSendPixel = (isMandatoryPixel || state.debug);
export function sendEvent(eventName) {
SublimeLeo marked this conversation as resolved.
Show resolved Hide resolved
const ts = Date.now();
const eventObject = {
t: ts,
Expand All @@ -54,14 +53,10 @@ export function sendEvent(eventName, isMandatoryPixel = false) {
ver: SUBLIME_VERSION,
};

if (shoudSendPixel) {
log('Sending pixel for event: ' + eventName, eventObject);
log('Sending pixel for event: ' + eventName, eventObject);

const queryString = url.formatQS(eventObject);
utils.triggerPixel('https://' + SUBLIME_ANTENNA + '/?' + queryString);
} else {
log('Not sending pixel for event (use debug: true to send it): ' + eventName, eventObject);
}
const queryString = url.formatQS(eventObject);
utils.triggerPixel('https://' + SUBLIME_ANTENNA + '/?' + queryString);
}

/**
Expand Down Expand Up @@ -150,9 +145,7 @@ function buildRequests(validBidRequests, bidderRequest) {
function interpretResponse(serverResponse, bidRequest) {
const bidResponses = [];
const response = serverResponse.body;

sendEvent('dintres');


if (response) {
if (response.timeout || !response.ad || /<!--\s+No\s+ad\s+-->/gmi.test(response.ad)) {
return bidResponses;
Expand Down Expand Up @@ -187,30 +180,38 @@ function interpretResponse(serverResponse, bidRequest) {
pbav: SUBLIME_VERSION
};

sendEvent('bida', true);
bidResponses.push(bidResponse);
} else {
sendEvent('dnobid');
}

return bidResponses;
}

/**
* Send pixel when bidWon event is triggered
* @param {Object} timeoutData
*/
function onBidWon(bid) {
log('Bid won', bid);
sendEvent('bidwon');
}

/**
* Send debug when we timeout
* @param {Object} timeoutData
*/
function onTimeout(timeoutData) {
log('Timeout from adapter', timeoutData);
sendEvent('dbidtimeout', true);
sendEvent('bidtimeout');
}

export const spec = {
code: BIDDER_CODE,
gvlid: BIDDER_GVLID,
aliases: [],
isBidRequestValid: isBidRequestValid,
buildRequests: buildRequests,
interpretResponse: interpretResponse,
onBidWon: onBidWon,
onTimeout: onTimeout,
};

Expand Down