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

undertone adapter update version 1.1.0 #19

Open
wants to merge 2 commits into
base: master-v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@

# 1.1.0
- Added GDPR module support that sends the consent information to Undertone API
- Added support for canonical url - if it exists and obtainable, it will be sent to udnertone API instead of full url

# 1.0.0
- Initial version, implemented the bidder
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "self-serve-partners-template",
"version": "1.0.0",
"version": "1.1.0",
"description": "A complete self-serve partner development package for Index Exchange's wrapper.",
"private": true,
"author": "Index Exchange",
Expand Down
36 changes: 34 additions & 2 deletions undertone-htb.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var System = require('system.js');
var Network = require('network.js');
var Utilities = require('utilities.js');

var ComplianceService;
var RenderService;

//? if (DEBUG) {
Expand Down Expand Up @@ -73,11 +74,30 @@ function UndertoneHtb(configs) {
/* Utilities
* ---------------------------------- */
var publisherId = configs.publisherId;
var adapterVersion = '1.1.0';

function getPublisherId() {
return publisherId;
}

/**
* A utility function that returns the page canonical url if it exists and if the top level window is accessible.
* If not - null will be returned
* @returns {String} - a canonical url if it exists, otherwise null
*/
function getCanonicalUrl() {
try {
var doc = window.top.document;
var element = doc.querySelector('link[rel="canonical"]');
if (element !== null) {
return element.href;
}
} catch (e) {
}

return null;
}

/**
* Generates the request URL and query data to the endpoint for the xSlots
* in the given returnParcels.
Expand Down Expand Up @@ -158,7 +178,7 @@ function UndertoneHtb(configs) {
xSlot.bidId = currBidId;

var placementId = xSlot.placementId;
var pageUrl = Browser.getPageUrl();
var pageUrl = getCanonicalUrl() || Browser.getPageUrl();
var hostname = Browser.getHostname();
var domains = (/[-\w]+\.([-\w]+|[-\w]{3,}|[-\w]{1,3}\.[-\w]{2})$/i).exec(hostname);
var domain = null;
Expand All @@ -184,8 +204,13 @@ function UndertoneHtb(configs) {
sizes: sizes
});
}

var queryObj = {
'x-ut-hb-params': bidsArray
'x-ut-hb-params': bidsArray,
commons: {
adapterVersion: adapterVersion,
uids: returnParcels[0].identityData
}
};

/* ------------------------ Get consent information -------------------------
Expand Down Expand Up @@ -217,6 +242,12 @@ function UndertoneHtb(configs) {

/* ------- Put GDPR consent code here if you are implementing GDPR ---------- */

var gdprConsent = ComplianceService.gdpr.getConsent();
if (gdprConsent) {
var gdprValue = gdprConsent.applies ? 1 : 0;
requestUrl += '&gdpr=' + gdprValue + '&gdprstr=' + gdprConsent.consentString;
}

/* -------------------------------------------------------------------------- */

return {
Expand Down Expand Up @@ -421,6 +452,7 @@ function UndertoneHtb(configs) {
* ---------------------------------- */

(function __constructor() {
ComplianceService = SpaceCamp.services.ComplianceService;
RenderService = SpaceCamp.services.RenderService;

/* =============================================================================
Expand Down