Skip to content

Commit

Permalink
AdMatic Bid Adapter : gvlid and video renderer feature added (#11212)
Browse files Browse the repository at this point in the history
* Admatic Bidder Adaptor

* Update admaticBidAdapter.md

* Update admaticBidAdapter.md

* remove floor parameter

* Update admaticBidAdapter.js

* Admatic Bid Adapter: alias and bid floor features activated

* Admatic adapter: host param control changed

* Alias name changed.

* Revert "Admatic adapter: host param control changed"

This reverts commit de7ac85.

* added alias feature and host param

* Revert "added alias feature and host param"

This reverts commit 6ec8f45.

* Revert "Alias name changed."

This reverts commit 661c54f.

* Revert "Admatic Bid Adapter: alias and bid floor features activated"

This reverts commit 7a2e0e2.

* Revert "Update admaticBidAdapter.js"

This reverts commit 7a845b7.

* Revert "remove floor parameter"

This reverts commit 7a23b05.

* Admatic adapter: host param control && Add new Bidder

* Revert "Admatic adapter: host param control && Add new Bidder"

This reverts commit 3c797b1.

* commit new features

* Update admaticBidAdapter.js

* updated for coverage

* sync updated

* Update adloader.js

* AdMatic Bidder: development of user sync url

* Update admaticBidAdapter.js

* Set currency for AdserverCurrency: bug fix

* Update admaticBidAdapter.js

* update

* admatic adapter video params update

* Update admaticBidAdapter.js

* update

* Update admaticBidAdapter.js

* update

* update

* Update admaticBidAdapter_spec.js

* Update admaticBidAdapter.js

* Update admaticBidAdapter.js

* Revert "Update admaticBidAdapter.js"

This reverts commit 1216892.

* Revert "Update admaticBidAdapter.js"

This reverts commit b1929ec.

* Revert "Update admaticBidAdapter_spec.js"

This reverts commit 1ca6597.

* Revert "update"

This reverts commit 689ce9d.

* Revert "update"

This reverts commit f381a45.

* Revert "Update admaticBidAdapter.js"

This reverts commit 38fd7ab.

* Revert "update"

This reverts commit a5316e7.

* Revert "Update admaticBidAdapter.js"

This reverts commit 60a28ca.

* Revert "admatic adapter video params update"

This reverts commit 31e69e8.

* update

* Update admaticBidAdapter.js

* Update admaticBidAdapter_spec.js

* mime_type add

* add native adapter

* AdMatic Adapter: Consent Management

* added gvlid
  • Loading branch information
fatihkaya84 authored Mar 22, 2024
1 parent 9088112 commit d9245b0
Show file tree
Hide file tree
Showing 2 changed files with 299 additions and 71 deletions.
104 changes: 74 additions & 30 deletions modules/admaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {getValue, formatQS, logError, deepAccess, isArray, getBidIdParameter} fr
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { config } from '../src/config.js';
import { BANNER, VIDEO, NATIVE } from '../src/mediaTypes.js';
import { Renderer } from '../src/Renderer.js';

/**
* @typedef {import('../src/adapters/bidderFactory.js').BidRequest} BidRequest
Expand Down Expand Up @@ -33,11 +34,13 @@ export const OPENRTB = {

let SYNC_URL = '';
const BIDDER_CODE = 'admatic';
const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';

export const spec = {
code: BIDDER_CODE,
gvlid: 1281,
aliases: [
{code: 'pixad'}
{code: 'pixad', gvlid: 1281}
],
supportedMediaTypes: [BANNER, VIDEO, NATIVE],
/**
Expand Down Expand Up @@ -190,38 +193,45 @@ export const spec = {
interpretResponse: (response, request) => {
const body = response.body;
const bidResponses = [];

if (body && body?.data && isArray(body.data)) {
body.data.forEach(bid => {
const resbid = {
requestId: bid.id,
cpm: bid.price,
width: bid.width,
height: bid.height,
currency: body.cur || 'TRY',
netRevenue: true,
creativeId: bid.creative_id,
meta: {
model: bid.mime_type,
advertiserDomains: bid && bid.adomain ? bid.adomain : []
},
bidder: bid.bidder,
mediaType: bid.type,
ttl: 60
};

if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) {
resbid.vastUrl = bid.party_tag;
resbid.vastImpUrl = bid.iurl;
} else if (resbid.mediaType === 'video') {
resbid.vastXml = bid.party_tag;
resbid.vastImpUrl = bid.iurl;
} else if (resbid.mediaType === 'banner') {
resbid.ad = bid.party_tag;
} else if (resbid.mediaType === 'native') {
resbid.native = interpretNativeAd(bid.party_tag)
};
const bidRequest = getAssociatedBidRequest(request.data.imp, bid);
if (bidRequest) {
const resbid = {
requestId: bid.id,
cpm: bid.price,
width: bid.width,
height: bid.height,
currency: body.cur || 'TRY',
netRevenue: true,
creativeId: bid.creative_id,
meta: {
model: bid.mime_type,
advertiserDomains: bid && bid.adomain ? bid.adomain : []
},
bidder: bid.bidder,
mediaType: bid.type,
ttl: 60
};

if (resbid.mediaType === 'video' && isUrl(bid.party_tag)) {
resbid.vastUrl = bid.party_tag;
} else if (resbid.mediaType === 'video') {
resbid.vastXml = bid.party_tag;
} else if (resbid.mediaType === 'banner') {
resbid.ad = bid.party_tag;
} else if (resbid.mediaType === 'native') {
resbid.native = interpretNativeAd(bid.party_tag)
};

const context = deepAccess(bidRequest, 'mediatype.context');
if (resbid.mediaType === 'video' && context === 'outstream') {
resbid.renderer = createOutstreamVideoRenderer(bid);
}

bidResponses.push(resbid);
bidResponses.push(resbid);
}
});
}
return bidResponses;
Expand Down Expand Up @@ -272,6 +282,40 @@ function isUrl(str) {
}
};

function outstreamRender (bid) {
bid.renderer.push(() => {
window.ANOutstreamVideo.renderAd({
targetId: bid.adUnitCode,
adResponse: bid.adResponse
});
});
}

function createOutstreamVideoRenderer(bid) {
const renderer = Renderer.install({
id: bid.bidId,
url: RENDERER_URL,
loaded: false
});

try {
renderer.setRender(outstreamRender);
} catch (err) {
logError('Prebid Error calling setRender on renderer' + err);
}

return renderer;
}

function getAssociatedBidRequest(bidRequests, bid) {
for (const request of bidRequests) {
if (request.id === bid.id) {
return request;
}
}
return undefined;
}

function enrichSlotWithFloors(slot, bidRequest) {
try {
const slotFloors = {};
Expand Down
Loading

0 comments on commit d9245b0

Please sign in to comment.