-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SSMas Bid adapter : Initial release (#10171)
* add ssmas adapter * ssmas adapter * privacy regulations * user sync * user sync consent * user sync params * set tagId * fix bid adapter doc * clean
- Loading branch information
Showing
3 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { BANNER } from '../src/mediaTypes.js'; | ||
import { registerBidder } from '../src/adapters/bidderFactory.js'; | ||
import { triggerPixel, deepSetValue } from '../src/utils.js'; | ||
import { ortbConverter } from '../libraries/ortbConverter/converter.js'; | ||
import {config} from '../src/config.js'; | ||
|
||
export const SSMAS_CODE = 'ssmas'; | ||
const SSMAS_SERVER = 'ads.ssmas.com'; | ||
export const SSMAS_ENDPOINT = `http://${SSMAS_SERVER}/ortb`; | ||
const SYNC_URL = `http://sync.ssmas.com/user_sync`; | ||
export const SSMAS_REQUEST_METHOD = 'POST'; | ||
const GDPR_VENDOR_ID = 1183; | ||
|
||
export const ssmasOrtbConverter = ortbConverter({ | ||
context: { | ||
netRevenue: true, | ||
ttl: 300, | ||
mediaType: BANNER, | ||
}, | ||
imp(buildImp, bidRequest, context) { | ||
const imp = buildImp(bidRequest, context); | ||
deepSetValue(imp, 'ext.placementId', bidRequest.params.placementId); | ||
return imp; | ||
}, | ||
}); | ||
|
||
export const spec = { | ||
code: SSMAS_CODE, | ||
supportedMediaTypes: [BANNER], | ||
gvlid: GDPR_VENDOR_ID, | ||
|
||
isBidRequestValid: (bid) => { | ||
return !!bid.params.placementId && !!bid.bidId && bid.bidder === SSMAS_CODE; | ||
}, | ||
|
||
buildRequests: (bidRequests, bidderRequest) => { | ||
const data = ssmasOrtbConverter.toORTB({ bidRequests, bidderRequest }); | ||
|
||
const options = { | ||
contentType: 'application/json', | ||
withCredentials: false, | ||
}; | ||
|
||
data.imp && data.imp.forEach(imp => { | ||
if (imp.ext && imp.ext.placementId) { | ||
imp.tagId = imp.ext.placementId; | ||
} | ||
}); | ||
|
||
data.regs = data.regs || {}; | ||
data.regs.ext = data.regs.ext || {}; | ||
|
||
if (bidderRequest.gdprConsent) { | ||
data.regs.ext.consent = bidderRequest.gdprConsent.consentString; | ||
data.regs.ext.gdpr = bidderRequest.gdprConsent.gdprApplies ? 1 : 0; | ||
} | ||
if (bidderRequest.uspConsent) { | ||
data.regs.ext.consent = bidderRequest.uspConsent.consentString; | ||
data.regs.ext.ccpa = 1; | ||
} | ||
if (config.getConfig('coppa') === true) { | ||
data.regs.coppa = 1; | ||
} | ||
|
||
return [ | ||
{ | ||
method: SSMAS_REQUEST_METHOD, | ||
url: SSMAS_ENDPOINT, | ||
data, | ||
options, | ||
}, | ||
]; | ||
}, | ||
|
||
interpretResponse: (serverResponse, bidRequest) => { | ||
const bids = ssmasOrtbConverter.fromORTB({ | ||
response: serverResponse.body, | ||
request: bidRequest.data, | ||
}).bids; | ||
|
||
return bids.filter((bid) => { | ||
return bid.cpm > 0; | ||
}); | ||
}, | ||
|
||
onBidWon: (bid) => { | ||
if (bid.burl) { | ||
triggerPixel(bid.burl); | ||
} | ||
}, | ||
|
||
getUserSyncs: ( | ||
syncOptions, | ||
serverResponses, | ||
gdprConsent, | ||
uspConsent | ||
) => { | ||
const syncs = []; | ||
|
||
let params = ['pbjs=1']; | ||
|
||
if (gdprConsent) { | ||
if (typeof gdprConsent.gdprApplies === 'boolean') { | ||
params.push(`gdpr=${Boolean(gdprConsent.gdprApplies)}&gdpr_consent=${ | ||
gdprConsent.consentString | ||
}`); | ||
} else { | ||
params.push(`gdpr_consent=${gdprConsent.consentString}`); | ||
} | ||
} | ||
|
||
if (uspConsent && uspConsent.consentString) { | ||
params.push(`ccpa_consent=${uspConsent.consentString}`); | ||
} | ||
|
||
if (syncOptions.pixelEnabled && serverResponses.length > 0) { | ||
syncs.push({ | ||
type: 'image', | ||
url: `${SYNC_URL}?${params.join('&')}` | ||
}); | ||
} | ||
return syncs; | ||
}, | ||
}; | ||
|
||
registerBidder(spec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Overview | ||
|
||
Module Name: SSMas Bidder Adapter | ||
Module Type: Bidder Adapter | ||
Maintainer: hzchen.work@gmail.com | ||
|
||
# Description | ||
|
||
Module that connects to Sem Seo & Mas header bidding endpoint to fetch bids. | ||
Supports Banner | ||
Supported currencies: EUR | ||
|
||
Required parameters: | ||
- placement id | ||
|
||
# Test Parameters | ||
``` | ||
var adUnits = [ | ||
// Banner adUnit | ||
{ | ||
code: 'banner-div', | ||
mediaTypes: { | ||
banner: { | ||
sizes: [[300, 250]] | ||
} | ||
}, | ||
bids: [{ | ||
bidder: 'ssmas', | ||
params: { | ||
placementId: "10336" | ||
} | ||
}] | ||
} | ||
]; | ||
``` |
Oops, something went wrong.