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

Sublime Bid Adapter: v0.7.1 & add extra information in tracking pixels #6442

Merged
merged 11 commits into from
Mar 19, 2021
33 changes: 29 additions & 4 deletions modules/sublimeBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,23 @@ const DEFAULT_CURRENCY = 'EUR';
const DEFAULT_PROTOCOL = 'https';
const DEFAULT_TTL = 600;
const SUBLIME_ANTENNA = 'antenna.ayads.co';
const SUBLIME_VERSION = '0.7.0';
const SUBLIME_VERSION = '0.7.1';

/**
* Identify the current device type
* @returns {string}
*/
function detectDevice() {
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;

return (
(isMobile.test(navigator.userAgent) && 'm') || // mobile
(isTablet.test(navigator.userAgent) && 't') || // tablet
'd' // desktop
);
}

/**
* Debug log message
Expand Down Expand Up @@ -39,8 +55,9 @@ 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 {string} [sspName] - The optionnal name of the AD provider
*/
export function sendEvent(eventName) {
export function sendEvent(eventName, sspName) {
const ts = Date.now();
const eventObject = {
t: ts,
Expand All @@ -51,8 +68,15 @@ export function sendEvent(eventName) {
puid: state.transactionId || state.notifyId,
trId: state.transactionId || state.notifyId,
pbav: SUBLIME_VERSION,
pubtimeout: config.getConfig('bidderTimeout'),
pubpbv: '$prebid.version$',
device: detectDevice(),
};

if (eventName === 'bidwon') {
eventObject.sspname = sspName || '';
}

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

const queryString = utils.formatQS(eventObject);
Expand Down Expand Up @@ -179,7 +203,8 @@ function interpretResponse(serverResponse, bidRequest) {
netRevenue: response.netRevenue || true,
ttl: response.ttl || DEFAULT_TTL,
ad: response.ad,
pbav: SUBLIME_VERSION
pbav: SUBLIME_VERSION,
sspname: response.sspname || null
};

bidResponses.push(bidResponse);
Expand All @@ -194,7 +219,7 @@ function interpretResponse(serverResponse, bidRequest) {
*/
function onBidWon(bid) {
log('Bid won', bid);
sendEvent('bidwon');
sendEvent('bidwon', bid.sspname);
}

/**
Expand Down
15 changes: 12 additions & 3 deletions test/spec/modules/sublimeBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ describe('Sublime Adapter', function() {
'puid',
'trId',
'pbav',
'pubpbv',
'device',
'pubtimeout',
];

beforeEach(function () {
Expand Down Expand Up @@ -139,6 +142,7 @@ describe('Sublime Adapter', function() {
describe('interpretResponse', function() {
let serverResponse = {
'request_id': '3db3773286ee59',
'sspname': 'foo',
'cpm': 0.5,
'ad': '<!-- Creative -->',
};
Expand All @@ -160,9 +164,10 @@ describe('Sublime Adapter', function() {
creativeId: 1,
dealId: 1,
currency: 'USD',
sspname: 'foo',
netRevenue: true,
ttl: 600,
pbav: '0.7.0',
pbav: '0.7.1',
ad: '',
},
];
Expand All @@ -173,6 +178,7 @@ describe('Sublime Adapter', function() {
it('should get correct default size for 1x1', function() {
let serverResponse = {
'requestId': 'xyz654_2',
'sspname': 'sublime',
'cpm': 0.5,
'ad': '<!-- Creative -->',
};
Expand Down Expand Up @@ -204,7 +210,8 @@ describe('Sublime Adapter', function() {
netRevenue: true,
ttl: 600,
ad: '<!-- Creative -->',
pbav: '0.7.0',
pbav: '0.7.1',
sspname: 'sublime'
};

expect(result[0]).to.deep.equal(expectedResponse);
Expand All @@ -224,6 +231,7 @@ describe('Sublime Adapter', function() {
it('should return bid with default value in response', function () {
let serverResponse = {
'requestId': 'xyz654_2',
'sspname': 'sublime',
'ad': '<!-- ad -->',
};

Expand Down Expand Up @@ -251,10 +259,11 @@ describe('Sublime Adapter', function() {
creativeId: 1,
dealId: 1,
currency: 'EUR',
sspname: 'sublime',
netRevenue: true,
ttl: 600,
ad: '<!-- ad -->',
pbav: '0.7.0',
pbav: '0.7.1',
};

expect(result[0]).to.deep.equal(expectedResponse);
Expand Down