Skip to content

Commit

Permalink
Sublime Bid Adapter: v0.7.1 & add extra information in tracking pixels (
Browse files Browse the repository at this point in the history
prebid#6442)

* add prebid version of adapter

* Feature/update sublime adapter (#21)

* Update sublimeBidAdapter to 0.5.1
* Add tests for private functions
* Remove window.sublime
* Update pixel name for bid event

* Remove pixels on non-event and add onBidWon (#22)

* add prebid version of adapter
* Feature/update sublime adapter (#21)
* Update sublimeBidAdapter to 0.5.1
* Add tests for private functions
* Remove window.sublime
* Update pixel name for bid event
* Remove pixels on non-event and add onBidWon
* Incremente version of sublimeBidAdapter
* Renamed pixel for timeout and introduce gvlid
* Remove unnecessary params for sendEvent

Co-Authored-By: fgcloutier <[email protected]>
Co-authored-by: Gaby <[email protected]>
Co-authored-by: fgcloutier <[email protected]>

* Remove trailing-space

* Fix version in tests

* sublimeAdapter: Improve pixels data

* sublimeAdapter: Update tests

* sublimeAdapter: Rename data

Co-authored-by: Gaby <[email protected]>
Co-authored-by: Léo <[email protected]>
Co-authored-by: fgcloutier <[email protected]>
Co-authored-by: Léo GRAND <[email protected]>
  • Loading branch information
5 people authored Mar 19, 2021
1 parent a13c619 commit 81a9e2b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
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

0 comments on commit 81a9e2b

Please sign in to comment.