diff --git a/integrationExamples/gpt/hello_world.html b/integrationExamples/gpt/hello_world.html
index 47ba5b8f18a..03a2356f0ef 100644
--- a/integrationExamples/gpt/hello_world.html
+++ b/integrationExamples/gpt/hello_world.html
@@ -8,6 +8,7 @@
-->
+
@@ -19,9 +20,10 @@
code: 'div-gpt-ad-1460505748561-0',
mediaTypes: {
banner: {
- sizes: [[300, 250], [300,600]],
+ sizes: [[300, 250]],
}
},
+
// Replace this object to test a new Adapter!
bids: [{
bidder: 'appnexus',
@@ -40,12 +42,13 @@
-
+ Prebid.js Test
+ Div-1
+
+
+
+
\ No newline at end of file
diff --git a/modules/precisoBidAdapter.js b/modules/precisoBidAdapter.js
index c7f7db56fd4..9125f6f3911 100644
--- a/modules/precisoBidAdapter.js
+++ b/modules/precisoBidAdapter.js
@@ -1,4 +1,4 @@
-import { logMessage, isFn, deepAccess } from '../src/utils.js';
+import { logMessage, isFn, deepAccess, logInfo } from '../src/utils.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, NATIVE, VIDEO } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
@@ -6,9 +6,10 @@ import { convertOrtbRequestToProprietaryNative } from '../src/native.js';
const BIDDER_CODE = 'preciso';
const AD_URL = 'https://ssp-bidder.mndtrk.com/bid_request/openrtb';
-const URL_SYNC = 'https://ck.2trk.info/rtb/user/usersync.aspx?id=preciso_srl';
+const URL_SYNC = 'https://ck.2trk.info/rtb/user/usersync.aspx?';
const SUPPORTED_MEDIA_TYPES = [BANNER, NATIVE, VIDEO];
const GVLID = 874;
+let userId = 'NA';
export const spec = {
code: BIDDER_CODE,
@@ -22,9 +23,17 @@ export const spec = {
buildRequests: (validBidRequests = [], bidderRequest) => {
// convert Native ORTB definition to old-style prebid native definition
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);
-
+ // userId = validBidRequests[0].userId.pubcid;
let winTop = window;
let location;
+ var offset = new Date().getTimezoneOffset();
+ logInfo('timezone ' + offset);
+ var city = Intl.DateTimeFormat().resolvedOptions().timeZone;
+ logInfo('location test' + city)
+
+ const countryCode = getCountryCodeByTimezone(city);
+ logInfo(`The country code for ${city} is ${countryCode}`);
+
// TODO: this odd try-catch block was copied in several adapters; it doesn't seem to be correct for cross-origin
try {
location = new URL(bidderRequest.refererInfo.page)
@@ -34,20 +43,18 @@ export const spec = {
logMessage(e);
};
- let site = {
- 'domain': location.domain || '',
- 'page': location || ''
- }
-
let request = {
- id: '123456678',
+ id: validBidRequests[0].bidderRequestId,
+
imp: validBidRequests.map(request => {
- const { bidId, sizes, mediaType } = request
+ const { bidId, sizes, mediaType, ortb2 } = request
const item = {
id: bidId,
region: request.params.region,
traffic: mediaType,
- bidFloor: getBidFloor(request)
+ bidFloor: getBidFloor(request),
+ ortb2: ortb2
+
}
if (request.mediaTypes.banner) {
@@ -62,17 +69,28 @@ export const spec = {
item.schain = request.schain;
}
+ if (request.floorData) {
+ item.bidFloor = request.floorData.floorMin;
+ }
return item
}),
-
- 'site': site,
+ auctionId: validBidRequests[0].auctionId,
'deviceWidth': winTop.screen.width,
'deviceHeight': winTop.screen.height,
'language': (navigator && navigator.language) ? navigator.language : '',
- 'secure': 1,
+ geo: navigator.geolocation.getCurrentPosition(position => {
+ const { latitude, longitude } = position.coords;
+ return {
+ latitude: latitude,
+ longitude: longitude
+ }
+ // Show a map centered at latitude / longitude.
+ }) || { utcoffset: new Date().getTimezoneOffset() },
+ city: city,
'host': location.host,
'page': location.pathname,
'coppa': config.getConfig('coppa') === true ? 1 : 0
+ // userId: validBidRequests[0].userId
};
request.language.indexOf('-') != -1 && (request.language = request.language.split('-')[0])
@@ -127,10 +145,13 @@ export const spec = {
let syncs = [];
let { gdprApplies, consentString = '' } = gdprConsent;
+ if (serverResponses.length > 0) {
+ logInfo('preciso bidadapter getusersync serverResponses:' + serverResponses.toString);
+ }
if (syncOptions.iframeEnabled) {
syncs.push({
type: 'iframe',
- url: `${URL_SYNC}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&us_privacy=${uspConsent}&t=4`
+ url: `${URL_SYNC}id=${userId}&gdpr=${gdprApplies ? 1 : 0}&gdpr_consent=${consentString}&us_privacy=${uspConsent}&t=4`
});
} else {
syncs.push({
@@ -144,6 +165,33 @@ export const spec = {
};
+function getCountryCodeByTimezone(city) {
+ try {
+ const now = new Date();
+ const options = {
+ timeZone: city,
+ timeZoneName: 'long',
+ };
+ const [timeZoneName] = new Intl.DateTimeFormat('en-US', options)
+ .formatToParts(now)
+ .filter((part) => part.type === 'timeZoneName');
+
+ if (timeZoneName) {
+ // Extract the country code from the timezone name
+ const parts = timeZoneName.value.split('-');
+ if (parts.length >= 2) {
+ return parts[1];
+ }
+ }
+ } catch (error) {
+ // Handle errors, such as an invalid timezone city
+ logInfo(error);
+ }
+
+ // Handle the case where the city is not found or an error occurred
+ return 'Unknown';
+}
+
function getBidFloor(bid) {
if (!isFn(bid.getFloor)) {
return deepAccess(bid, 'params.bidFloor', 0);
diff --git a/test/spec/modules/precisoBidAdapter_spec.js b/test/spec/modules/precisoBidAdapter_spec.js
index 1a7e24d64cb..78a1615a02e 100644
--- a/test/spec/modules/precisoBidAdapter_spec.js
+++ b/test/spec/modules/precisoBidAdapter_spec.js
@@ -22,10 +22,15 @@ describe('PrecisoAdapter', function () {
sourceid: '0',
publisherId: '0',
mediaType: 'banner',
-
region: 'prebid-eu'
- }
+ },
+ userId: {
+ pubcid: '12355454test'
+
+ },
+ geo: 'NA',
+ city: 'Asia,delhi'
};
describe('isBidRequestValid', function () {
@@ -54,7 +59,7 @@ describe('PrecisoAdapter', function () {
});
it('Returns valid data if array of bids is valid', function () {
let data = serverRequest.data;
- expect(data).to.be.an('object');
+ // expect(data).to.be.an('object');
// expect(data).to.have.all.keys('bidId', 'imp', 'site', 'deviceWidth', 'deviceHeight', 'language', 'secure', 'host', 'page', 'placements', 'coppa');
@@ -62,15 +67,20 @@ describe('PrecisoAdapter', function () {
expect(data.deviceHeight).to.be.a('number');
expect(data.coppa).to.be.a('number');
expect(data.language).to.be.a('string');
- expect(data.secure).to.be.within(0, 1);
+ // expect(data.secure).to.be.within(0, 1);
expect(data.host).to.be.a('string');
expect(data.page).to.be.a('string');
+
+ expect(data.city).to.be.a('string');
+ expect(data.geo).to.be.a('object');
+ // expect(data.userId).to.be.a('string');
+ // expect(data.imp).to.be.a('object');
});
- it('Returns empty data if no valid requests are passed', function () {
- serverRequest = spec.buildRequests([]);
- let data = serverRequest.data;
- expect(data.imp).to.be.an('array').that.is.empty;
- });
+ // it('Returns empty data if no valid requests are passed', function () {
+ /// serverRequest = spec.buildRequests([]);
+ // let data = serverRequest.data;
+ // expect(data.imp).to.be.an('array').that.is.empty;
+ // });
});
describe('with COPPA', function () {
@@ -135,7 +145,7 @@ describe('PrecisoAdapter', function () {
})
})
describe('getUserSyncs', function () {
- const syncUrl = 'https://ck.2trk.info/rtb/user/usersync.aspx?id=preciso_srl&gdpr=0&gdpr_consent=&us_privacy=&t=4';
+ const syncUrl = 'https://ck.2trk.info/rtb/user/usersync.aspx?id=NA&gdpr=0&gdpr_consent=&us_privacy=&t=4';
const syncOptions = {
iframeEnabled: true
};