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

CRITEO RTUS Integration with Yieldmo Prebid #5075

Merged
merged 65 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
889e5f0
update maintainer email
Feb 9, 2018
147c1a0
Merge remote-tracking branch 'upstream/master'
ym-elber Jul 29, 2019
8729d7c
Merge pull request #3 from yieldmo/upstream-sync
Jul 30, 2019
32c1c68
Merge branch 'master' of https://github.com/prebid/Prebid.js
Oct 15, 2019
4fd8634
add stringified schain
Oct 15, 2019
75d3036
Revert "add stringified schain"
Oct 15, 2019
4efef2a
pass along gdpr consent string and gdpr applies through get
Oct 16, 2019
05dbe64
use paramter gdprConsent
Oct 17, 2019
c4820cb
Merge pull request #5 from yieldmo/FS-7684-pass-consent-string
MelodyLi2017 Oct 18, 2019
49de31f
add stringified schain
Oct 15, 2019
3e384c9
don't change other files
Oct 15, 2019
5a71559
Merge pull request #4 from yieldmo/FS-7695-schain
MelodyLi2017 Oct 21, 2019
17108a4
change parameter namves
Oct 21, 2019
c1f47bf
Merge pull request #6 from yieldmo/change-param-names
MelodyLi2017 Oct 22, 2019
217eb0c
updates bidder module to be 3.0 compliant, and tests
HolzAndrew Oct 25, 2019
eeff0f4
Merge pull request #7 from yieldmo/FS-7762
HolzAndrew Oct 28, 2019
5854686
deletes openxoutstream adapter
HolzAndrew Nov 1, 2019
6b16a1f
fix broken yieldmo test
HolzAndrew Nov 1, 2019
8f3f98a
remove log
HolzAndrew Nov 1, 2019
5398c6d
Merge pull request #8 from yieldmo/FS-7766
Nov 12, 2019
c0cab3e
remove utils functions that will be depricated in 3.0 and use new ref…
HolzAndrew Nov 22, 2019
18ed64c
Merge pull request #9 from yieldmo/FS-7762-updates
HolzAndrew Nov 22, 2019
32bef9d
use prebids gettopwindow util functions. update markdown with 3.0 com…
HolzAndrew Nov 26, 2019
1ec3f23
Merge pull request #10 from yieldmo/FS-7762-updates
HolzAndrew Nov 26, 2019
e5af53a
Pass along us_privacy string
ym-elber Nov 26, 2019
7012a86
Merge pull request #11 from yieldmo/FS-7901-us-privacy
Nov 27, 2019
c3fdba6
remove blank.min
ym-elber Nov 27, 2019
8f93b8f
Fix unit tests and remove unused variables and methods
ym-elber Nov 27, 2019
6dc4d82
add stringified schain
Oct 15, 2019
078dde0
Revert "add stringified schain"
Oct 15, 2019
76395db
pass along gdpr consent string and gdpr applies through get
Oct 16, 2019
c8f1bb6
use paramter gdprConsent
Oct 17, 2019
f44b9ba
add stringified schain
Oct 15, 2019
3c08912
don't change other files
Oct 15, 2019
2bd4486
change parameter namves
Oct 21, 2019
b05b9af
updates bidder module to be 3.0 compliant, and tests
HolzAndrew Oct 25, 2019
317b18f
deletes openxoutstream adapter
HolzAndrew Nov 1, 2019
493ea66
fix broken yieldmo test
HolzAndrew Nov 1, 2019
f66291a
remove log
HolzAndrew Nov 1, 2019
ba44122
remove utils functions that will be depricated in 3.0 and use new ref…
HolzAndrew Nov 22, 2019
e185504
use prebids gettopwindow util functions. update markdown with 3.0 com…
HolzAndrew Nov 26, 2019
0072141
Pass along us_privacy string
ym-elber Nov 26, 2019
11366c8
Merge pull request #13 from yieldmo/master-copy-2
HolzAndrew Dec 16, 2019
9e3fcc4
Merge pull request #12 from yieldmo/FS-7860-remove-blank
Dec 19, 2019
b871655
update maintainer email
Feb 9, 2018
828a404
add stringified schain
Oct 15, 2019
34b7b87
Revert "add stringified schain"
Oct 15, 2019
af9fa8c
add stringified schain
Oct 15, 2019
94fc46a
don't change other files
Oct 15, 2019
b221b68
change parameter namves
Oct 21, 2019
76aed8a
updates bidder module to be 3.0 compliant, and tests
HolzAndrew Oct 25, 2019
9c11524
fix broken yieldmo test
HolzAndrew Nov 1, 2019
6911ad8
remove utils functions that will be depricated in 3.0 and use new ref…
HolzAndrew Nov 22, 2019
797b040
use prebids gettopwindow util functions. update markdown with 3.0 com…
HolzAndrew Nov 26, 2019
d257f97
Pass along us_privacy string
ym-elber Dec 20, 2019
b212e38
Clean up console
ym-elber Dec 23, 2019
0185407
Do not undo my featureeee
ym-elber Dec 23, 2019
97ef3d6
Merge branch 'master' into rebase-upstream
Dec 26, 2019
c2ea708
Merge pull request #14 from yieldmo/rebase-upstream
Dec 26, 2019
09301d1
CRITEO RTUS For prebid
fasola81 Mar 31, 2020
dfd8c58
Tests for CRITEO RTUS For prebid
fasola81 Mar 31, 2020
03c3411
Merge pull request #15 from yieldmo/FS-8104-CRITEO_RTUS_For_prebid
mglowackiym Apr 2, 2020
4fa7cef
Revert "Do not undo my featureeee"
Apr 3, 2020
28c143b
linting
Apr 3, 2020
3bf64e0
add test back in:
Apr 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 71 additions & 43 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: ['banner'],
/**
* Determines whether or not the given bid request is valid.
* @param {object} bid, bid to validate
* @return boolean, true if valid, otherwise false
*/
* Determines whether or not the given bid request is valid.
* @param {object} bid, bid to validate
* @return boolean, true if valid, otherwise false
*/
isBidRequestValid: function(bid) {
return !!(bid && bid.adUnitCode && bid.bidId);
},
Expand All @@ -41,13 +41,19 @@ export const spec = {
h: localWindow.innerHeight,
userConsent: JSON.stringify({
// case of undefined, stringify will remove param
gdprApplies: bidderRequest && bidderRequest.gdprConsent ? bidderRequest.gdprConsent.gdprApplies : undefined,
cmp: bidderRequest && bidderRequest.gdprConsent ? bidderRequest.gdprConsent.consentString : undefined
gdprApplies:
bidderRequest && bidderRequest.gdprConsent
? bidderRequest.gdprConsent.gdprApplies
: undefined,
cmp:
bidderRequest && bidderRequest.gdprConsent
? bidderRequest.gdprConsent.consentString
: undefined
}),
us_privacy: bidderRequest && bidderRequest.us_privacy,
us_privacy: bidderRequest && bidderRequest.us_privacy
};

bidRequests.forEach((request) => {
bidRequests.forEach(request => {
serverRequest.p.push(addPlacement(request));
const pubcid = getId(request, 'pubcid');
if (pubcid) {
Expand All @@ -61,6 +67,10 @@ export const spec = {
if (tdid) {
serverRequest.tdid = tdid;
}
const criteoId = getId(request, 'criteoId');
if (criteoId) {
serverRequest.cri_prebid = criteoId;
}
if (request.schain) {
serverRequest.schain = JSON.stringify(request.schain);
}
Expand All @@ -70,7 +80,7 @@ export const spec = {
method: 'GET',
url: SERVER_ENDPOINT,
data: serverRequest
}
};
},
/**
* Makes Yieldmo Ad Server response compatible to Prebid specs
Expand All @@ -81,7 +91,7 @@ export const spec = {
let bids = [];
let data = serverResponse.body;
if (data.length > 0) {
data.forEach((response) => {
data.forEach(response => {
if (response.cpm && response.cpm > 0) {
bids.push(createNewBid(response));
}
Expand All @@ -91,15 +101,17 @@ export const spec = {
},
getUserSync: function(syncOptions) {
if (trackingEnabled(syncOptions)) {
return [{
type: 'iframe',
url: SYNC_ENDPOINT + utils.getOrigin()
}];
return [
{
type: 'iframe',
url: SYNC_ENDPOINT + utils.getOrigin()
}
];
} else {
return [];
}
}
}
};
registerBidder(spec);

/***************************************
Expand All @@ -115,7 +127,7 @@ function addPlacement(request) {
placement_id: request.adUnitCode,
callback_id: request.bidId,
sizes: request.mediaTypes.banner.sizes
}
};
if (request.params) {
if (request.params.placementId) {
placementInfo.ym_placement_id = request.params.placementId;
Expand All @@ -128,9 +140,9 @@ function addPlacement(request) {
}

/**
* creates a new bid with response information
* @param response server response
*/
* creates a new bid with response information
* @param response server response
*/
function createNewBid(response) {
return {
requestId: response['callback_id'],
Expand All @@ -150,31 +162,35 @@ function createNewBid(response) {
* @returns false if dnt or if not iframe/pixel enabled
*/
function trackingEnabled(options) {
return (isIOS() && !getDNT() && options.iframeEnabled);
return isIOS() && !getDNT() && options.iframeEnabled;
}

/**
* Detects whether we're in iOS
* @returns true if in iOS
*/
* Detects whether we're in iOS
* @returns true if in iOS
*/
function isIOS() {
return /iPhone|iPad|iPod/i.test(window.navigator.userAgent);
}

/**
* Detects whether dnt is true
* @returns true if user enabled dnt
*/
* Detects whether dnt is true
* @returns true if user enabled dnt
*/
function getDNT() {
return window.doNotTrack === '1' || window.navigator.doNotTrack === '1' || false;
return (
window.doNotTrack === '1' || window.navigator.doNotTrack === '1' || false
);
}

/**
* get page description
*/
function getPageDescription() {
if (document.querySelector('meta[name="description"]')) {
return document.querySelector('meta[name="description"]').getAttribute('content'); // Value of the description metadata from the publisher's page.
return document
.querySelector('meta[name="description"]')
.getAttribute('content'); // Value of the description metadata from the publisher's page.
} else {
return '';
}
Expand All @@ -200,9 +216,9 @@ function getPageDescription() {
*/

/**
* Detects what environment we're in
* @returns Environment kind
*/
* Detects what environment we're in
* @returns Environment kind
*/
function getEnvironment() {
if (isSuperSandboxedIframe()) {
return 89;
Expand All @@ -228,28 +244,31 @@ function getEnvironment() {
}

/**
* @returns true if we are running on the top window at dispatch time
*/
* @returns true if we are running on the top window at dispatch time
*/
function isCodeOnPage() {
return window === window.parent;
}

/**
* @returns true if the environment is both DFP and AMP
*/
* @returns true if the environment is both DFP and AMP
*/
function isDfpInAmp() {
return isDfp() && isAmp();
}

/**
* @returns true if the window is in an iframe whose id and parent element id match DFP
*/
* @returns true if the window is in an iframe whose id and parent element id match DFP
*/
function isDfp() {
try {
const frameElement = window.frameElement;
const parentElement = window.frameElement.parentNode;
if (frameElement && parentElement) {
return frameElement.id.indexOf('google_ads_iframe') > -1 && parentElement.id.indexOf('google_ads_iframe') > -1;
return (
frameElement.id.indexOf('google_ads_iframe') > -1 &&
parentElement.id.indexOf('google_ads_iframe') > -1
);
}
return false;
} catch (e) {
Expand All @@ -258,8 +277,8 @@ function isDfp() {
}

/**
* @returns true if there is an AMP context object
*/
* @returns true if there is an AMP context object
*/
function isAmp() {
try {
const ampContext = window.context || window.parent.context;
Expand All @@ -285,7 +304,11 @@ function isSafeFrame() {
function isDFPSafeFrame() {
if (window.location && window.location.href) {
const href = window.location.href;
return isSafeFrame() && href.indexOf('google') !== -1 && href.indexOf('safeframe') !== -1;
return (
isSafeFrame() &&
href.indexOf('google') !== -1 &&
href.indexOf('safeframe') !== -1
);
}
return false;
}
Expand Down Expand Up @@ -318,7 +341,7 @@ function isSuperSandboxedIframe() {
* @returns true if the window has the attribute identifying MRAID
*/
function isMraid() {
return !!(window.mraid);
return !!window.mraid;
}

/**
Expand All @@ -329,7 +352,12 @@ function isMraid() {
*/
function getId(request, idType) {
let id;
if (request && request.userId && request.userId[idType] && typeof request.userId === 'object') {
if (
request &&
request.userId &&
request.userId[idType] &&
typeof request.userId === 'object'
) {
id = request.userId[idType];
}
return id;
Expand Down
1 change: 1 addition & 0 deletions modules/yieldmoBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Module Name: Yieldmo Bid Adapter
Module Type: Bidder Adapter
Maintainer: opensource@yieldmo.com
Note: Our ads will only render in mobile
```

# Description
Expand Down
Loading