forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AdTelligent Bid Adapter: remove onefiftytwo alias (prebid#10025)
* Smartadserver Bid Adapter: support GPID (prebid#10004) * Smartadserver Bid Adapter: Add support for SDA user and site * Smartadserver Bid Adapter: Fix SDA support getConfig and add to unit testing * support floors per media type * Add GPP support * Rework payloads enriching * Add gpid support --------- Co-authored-by: Meven Courouble <mcourouble@smartadserver.com> Co-authored-by: Krzysztof Sokół <88041828+smart-adserver@users.noreply.github.com> * chore: update default video placement value [PB-1560] (prebid#9948) Co-authored-by: Chris Corbo <chris.corbo@indexexchange.com> * ShareThrough Bid Adapter : fix playerSize (prebid#10011) * fix sharethrough playersize * fix unit test --------- Co-authored-by: Reinout Stevens <reinout@crazygames.com> * GrowthCode RTD : initial release (prebid#9852) * The New RTD Module * GrowthCode new RTD Module * Fixed to Prebid Added Testing Added Docs * Fixed to Prebid Added Testing Added Docs * Completed testing spec * Update the MD file to provide more infomation about what the module does * Update sample to point to the correct server for testing. * Stv Bid Adapter: add schain support (prebid#10010) * initial commit * adapted buildRequests function * refinement pfilter and bcat * refinement * adapted tests for isBidRequestValid,buildRequests * adaptations for test * finished building stvBidAdapter.js * finished: ran tests, coverage 99% * update: rename w->srw, h->srh * adapt stvBidAdapter.md * remove dspx from stv adapters * some changes (missing: getUserSyncs, but is the same as in radsBidAdapter) * added checks in getUserSyncs; ran tests * added schain support (94.8% coverage) * correct schain encoding --------- Co-authored-by: theo_ <theo_@IDEA3> * fix module type (prebid#10019) * Update ad generation adapter 1.6.0: update userSync (prebid#9984) * Update AdGenerationAdapter: update userSync * update test spec * remove onefiftytwo alias --------- Co-authored-by: Krzysztof Sokół <88041828+krzysztofequativ@users.noreply.github.com> Co-authored-by: Meven Courouble <mcourouble@smartadserver.com> Co-authored-by: Krzysztof Sokół <88041828+smart-adserver@users.noreply.github.com> Co-authored-by: ccorbo <ccorbo2013@gmail.com> Co-authored-by: Chris Corbo <chris.corbo@indexexchange.com> Co-authored-by: Reinout Stevens <518971+ReinoutStevens@users.noreply.github.com> Co-authored-by: Reinout Stevens <reinout@crazygames.com> Co-authored-by: southern-growthcode <79725079+southern-growthcode@users.noreply.github.com> Co-authored-by: theo-stv <120092078+theo-stv@users.noreply.github.com> Co-authored-by: theo_ <theo_@IDEA3> Co-authored-by: Chris Huie <phoenixtechnerd@gmail.com> Co-authored-by: Takaaki.Kojima <banakemi@gmail.com>
- Loading branch information
1 parent
0b65cef
commit 88dbc04
Showing
16 changed files
with
503 additions
and
37 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
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
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
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,131 @@ | ||
/** | ||
* This module adds GrowthCode HEM and other Data to Bid Requests | ||
* @module modules/growthCodeRtdProvider | ||
*/ | ||
import { submodule } from '../src/hook.js' | ||
import { getStorageManager } from '../src/storageManager.js'; | ||
import { | ||
logMessage, logError, tryAppendQueryString, mergeDeep | ||
} from '../src/utils.js'; | ||
import * as ajax from '../src/ajax.js'; | ||
import { MODULE_TYPE_RTD } from '../src/activities/modules.js'; | ||
|
||
const MODULE_NAME = 'growthCodeRtd'; | ||
const LOG_PREFIX = 'GrowthCodeRtd: '; | ||
const ENDPOINT_URL = 'https://p2.gcprivacy.com/v2/rtd?' | ||
const RTD_EXPIRE_KEY = 'gc_rtd_expires_at' | ||
const RTD_CACHE_KEY = 'gc_rtd_items' | ||
|
||
export const storage = getStorageManager({ moduleType: MODULE_TYPE_RTD, moduleName: MODULE_NAME }); | ||
let items | ||
|
||
export const growthCodeRtdProvider = { | ||
name: MODULE_NAME, | ||
init: init, | ||
getBidRequestData: alterBidRequests, | ||
addData: addData, | ||
callServer: callServer | ||
}; | ||
|
||
/** | ||
* Parse json if possible, else return null | ||
* @param data | ||
* @returns {any|null} | ||
*/ | ||
function tryParse(data) { | ||
try { | ||
return JSON.parse(data); | ||
} catch (err) { | ||
logError(err); | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Init The RTD Module | ||
* @param config | ||
* @param userConsent | ||
* @returns {boolean} | ||
*/ | ||
function init(config, userConsent) { | ||
logMessage(LOG_PREFIX + 'Init RTB'); | ||
|
||
if (config == null) { | ||
return false | ||
} | ||
|
||
const configParams = (config && config.params) || {}; | ||
let expiresAt = parseInt(storage.getDataFromLocalStorage(RTD_EXPIRE_KEY, null)); | ||
|
||
items = tryParse(storage.getDataFromLocalStorage(RTD_CACHE_KEY, null)); | ||
|
||
return callServer(configParams, items, expiresAt, userConsent); | ||
} | ||
function callServer(configParams, items, expiresAt, userConsent) { | ||
// Expire Cache | ||
let now = Math.trunc(Date.now() / 1000); | ||
if ((!isNaN(expiresAt)) && (now > expiresAt)) { | ||
expiresAt = NaN; | ||
storage.removeDataFromLocalStorage(RTD_CACHE_KEY, null) | ||
storage.removeDataFromLocalStorage(RTD_EXPIRE_KEY, null) | ||
} | ||
if ((items === null) && (isNaN(expiresAt))) { | ||
let gcid = localStorage.getItem('gcid') | ||
|
||
let url = configParams.url ? configParams.url : ENDPOINT_URL; | ||
url = tryAppendQueryString(url, 'pid', configParams.pid); | ||
url = tryAppendQueryString(url, 'u', window.location.href); | ||
url = tryAppendQueryString(url, 'gcid', gcid); | ||
if ((userConsent !== null) && (userConsent.gdpr !== null) && (userConsent.gdpr.consentData.getTCData.tcString)) { | ||
url = tryAppendQueryString(url, 'tcf', userConsent.gdpr.consentData.getTCData.tcString) | ||
} | ||
|
||
ajax.ajaxBuilder()(url, { | ||
success: response => { | ||
let respJson = tryParse(response); | ||
// If response is a valid json and should save is true | ||
if (respJson && respJson.results >= 1) { | ||
storage.setDataInLocalStorage(RTD_CACHE_KEY, JSON.stringify(respJson.items), null); | ||
storage.setDataInLocalStorage(RTD_EXPIRE_KEY, respJson.expires_at, null) | ||
} else { | ||
storage.setDataInLocalStorage(RTD_EXPIRE_KEY, respJson.expires_at, null) | ||
} | ||
}, | ||
error: error => { | ||
logError(LOG_PREFIX + 'ID fetch encountered an error', error); | ||
} | ||
}, undefined, {method: 'GET', withCredentials: true}) | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function addData(reqBidsConfigObj, items) { | ||
let merge = false | ||
|
||
for (let j = 0; j < items.length; j++) { | ||
let item = items[j] | ||
let data = JSON.parse(item.parameters); | ||
if (item['attachment_point'] === 'data') { | ||
mergeDeep(reqBidsConfigObj.ortb2Fragments.bidder, data) | ||
merge = true | ||
} | ||
} | ||
return merge | ||
} | ||
|
||
/** | ||
* Alter the Bid Request for additional information such as HEM or 3rd Party Ids | ||
* @param reqBidsConfigObj | ||
* @param callback | ||
* @param config | ||
* @param userConsent | ||
*/ | ||
function alterBidRequests(reqBidsConfigObj, callback, config, userConsent) { | ||
if (items != null) { | ||
addData(reqBidsConfigObj, items) | ||
} | ||
callback(); | ||
} | ||
|
||
submodule('realTimeData', growthCodeRtdProvider); |
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,55 @@ | ||
## GrowthCode Real-time Data Submodule | ||
|
||
The [GrowthCode](https://growthcode.io) real-time data module in Prebid enables publishers to fully | ||
leverage the potential of their first-party audiences and contextual data. | ||
With an integrated cookieless GrowthCode identity, this module offers real-time | ||
contextual and audience segmentation (IAB Taxonomy 2.2, cattax: 6) capabilities, and HEMs that can seamlessly | ||
integrate into your existing Prebid deployment, making it easy to maximize | ||
your advertising strategies. | ||
|
||
## Building Prebid with GrowthCode Support | ||
|
||
Compile the GrowthCode RTD module into your Prebid build: | ||
|
||
`gulp serve --modules=userId,rtdModule,appnexusBidAdapter,growthCodeRtdProvider,sharedIdSystem,criteoBidAdapter` | ||
|
||
Please visit https://growthcode.io/ for more information. | ||
|
||
``` | ||
pbjs.setConfig( | ||
... | ||
realTimeData: { | ||
auctionDelay: 1000, | ||
dataProviders: [ | ||
{ | ||
name: 'growthCodeRtd', | ||
waitForIt: true, | ||
params: { | ||
pid: 'TEST01', | ||
} | ||
} | ||
] | ||
} | ||
... | ||
} | ||
``` | ||
|
||
### Parameter Descriptions for the GrowthCode Configuration Section | ||
|
||
| Name | Type | Description | Notes | | ||
|:---------------------------------|:--------|:--------------------------------------------------------------------------|:----------------------------| | ||
| name | String | Real time data module name | Always 'growthCodeRtd' | | ||
| waitForIt | Boolean | Required to ensure that the auction is delayed until prefetch is complete | Optional. Defaults to false | | ||
| params | Object | | | | ||
| params.pid | String | This is the Parter ID value obtained from GrowthCode | `TEST01` | | ||
| params.url | String | Custom URL for server | Optional | | ||
|
||
## Testing | ||
|
||
To view an example of GrowthCode backends: | ||
|
||
`gulp serve --modules=userId,rtdModule,appnexusBidAdapter,growthCodeRtdProvider,sharedIdSystem,criteoBidAdapter` | ||
|
||
and then point your browser at: | ||
|
||
`http://localhost:9999/integrationExamples/gpt/growthcode.html` |
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
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
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
Oops, something went wrong.