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

TheMediaGrid Bid Adapter: fill user.id from fpd cookie #7279

Merged
merged 76 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
94d2b3a
Added TheMediaGridNM Bid Adapter
TheMediaGrid Mar 12, 2020
3ba8fd8
Updated required params for TheMediaGridNM Bid Adapter
TheMediaGrid Mar 12, 2020
b830678
Update TheMediGridNM Bid Adapter
TheMediaGrid Mar 17, 2020
9675d02
Fix tests for TheMediaGridNM Bid Adapter
TheMediaGrid Mar 17, 2020
65cb00f
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Mar 17, 2020
f1cba4a
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Mar 31, 2020
52e593c
Fixes after review for TheMediaGridNM Bid Adapter
TheMediaGrid Mar 31, 2020
7b99287
Merge remote-tracking branch 'upstream/master'
TheMediaGrid May 12, 2020
83fb2b4
Add support of multi-format in TheMediaGrid Bid Adapter
TheMediaGrid May 12, 2020
926f4d9
Merge remote-tracking branch 'upstream/master'
TheMediaGrid May 26, 2020
66f2ac8
Update sync url for grid and gridNM Bid Adapters
TheMediaGrid May 26, 2020
b2fb704
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jun 9, 2020
4fcf522
TheMediaGrid Bid Adapter: added keywords adUnit parameter
TheMediaGrid Jun 9, 2020
6906f1b
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jun 15, 2020
bfe4f5e
Update TheMediaGrid Bid Adapter to support keywords from config
TheMediaGrid Jun 15, 2020
d2c199b
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 4, 2020
64b5b8d
Implement new request format for TheMediaGrid Bid Adapter
TheMediaGrid Jul 10, 2020
ef493f7
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 23, 2020
4481d01
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 27, 2020
faa9bfb
Fix jwpseg params for TheMediaGrid Bid Adapter
TheMediaGrid Jul 27, 2020
dc645c7
Update unit tests for The Media Grid Bid Adapter
TheMediaGrid Jul 29, 2020
340cae4
Fix typo in TheMediaGrid Bid Adapter
TheMediaGrid Aug 10, 2020
6fa4e21
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Aug 10, 2020
250601e
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Sep 2, 2020
a4904d6
Added test for jwTargeting in TheMediaGrid Bid Adapter
TheMediaGrid Sep 3, 2020
dfef5e1
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Oct 7, 2020
1644021
The new request format was made by default in TheMediaGrid Bid Adapter
TheMediaGrid Oct 8, 2020
54237d7
Update userId format in ad request for TheMediaGrid Bid Adapter
TheMediaGrid Oct 12, 2020
a8c7096
Added bidFloor parameter for TheMediaGrid Bid Adapter
TheMediaGrid Oct 14, 2020
e9fb25d
Fix for review TheMediaGrid Bid Adapter
TheMediaGrid Oct 20, 2020
9039a79
Support floorModule in TheMediaGrid Bid Adapter
TheMediaGrid Oct 20, 2020
07a13b2
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Oct 21, 2020
aea2b2e
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Nov 25, 2020
2347817
Fix empty bidfloor for TheMediaGrid Bid Adapter
TheMediaGrid Nov 25, 2020
a7c3733
Some change to restart autotests
TheMediaGrid Nov 30, 2020
0763615
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Nov 30, 2020
81c6700
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Dec 17, 2020
77ce199
Fix userIds format for TheMediaGrid Bid Adapter
TheMediaGrid Dec 18, 2020
4b944e8
Remove digitrust userId from TheMediaGrid Bid Adapter
TheMediaGrid Dec 21, 2020
192cb9a
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Feb 10, 2021
e7994ca
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Feb 11, 2021
01e4c8e
Protocols was added in video section in ad request for TheMediaGrid B…
TheMediaGrid Feb 11, 2021
a2c90fb
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Feb 26, 2021
97e1c5e
TheMediaGrid: fix trouble with alias using
TheMediaGrid Feb 26, 2021
ae34924
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Mar 1, 2021
21cad2b
TheMediaGridNM: fix trouble with alias
TheMediaGrid Mar 1, 2021
0cf3d1d
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Mar 10, 2021
94fccff
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Apr 12, 2021
ecfa441
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Apr 14, 2021
ebf5684
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Apr 16, 2021
da4e7a3
TheMediaGrid Bid Adapter: added support of PBAdSlot module
TheMediaGrid Apr 16, 2021
419fd89
TheMediaGrid Bid Adapter: fix typo
TheMediaGrid Apr 21, 2021
7845ee4
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Apr 26, 2021
8036bfa
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Apr 26, 2021
3e9b878
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Apr 27, 2021
2645aff
Merge remote-tracking branch 'upstream/master'
TheMediaGrid May 20, 2021
d76839f
GridNM Bid Adapter: use absent in params data from mediaTypes
TheMediaGrid May 24, 2021
126b9af
GridNM Bid Adapter: fix md file + add advertiserDomains support
TheMediaGrid May 24, 2021
5ae8585
Merge remote-tracking branch 'upstream/master'
TheMediaGrid May 31, 2021
3504295
TheMediaGrid and gridNM Bid Adapter: minor netRevenue fixes
TheMediaGrid May 31, 2021
271b24c
gridNM Bid Adapter updates after review
TheMediaGrid Jun 2, 2021
635b87c
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 1, 2021
e299874
TheMediaGrid Bid Adapter: fix keywords workflow
TheMediaGrid Jul 1, 2021
6503708
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 2, 2021
dc7263e
fix testing and kick off lgtm again
ChrisHuie Jul 6, 2021
f5b0acc
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 11, 2021
4452dff
TheMediaGrig: added keywords formating in request
TheMediaGrid Jul 11, 2021
60be56b
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 14, 2021
2a66d3d
TheMediaGrid: added ext.bidder.grid.demandSource processing
TheMediaGrid Jul 14, 2021
7582d84
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Aug 3, 2021
aba9510
TheMediaGrid: added user.id from fpd cookie
TheMediaGrid Aug 9, 2021
afa6dd6
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Aug 9, 2021
8a0ef0c
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Aug 31, 2021
10bd427
TheMediaGrid: control cookie setting via bidder config
TheMediaGrid Aug 31, 2021
199324d
TheMediaGrid: use localStorage instead cookie
TheMediaGrid Sep 2, 2021
0ed526d
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Sep 2, 2021
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
37 changes: 30 additions & 7 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { registerBidder } from '../src/adapters/bidderFactory.js';
import { Renderer } from '../src/Renderer.js';
import { VIDEO, BANNER } from '../src/mediaTypes.js';
import { config } from '../src/config.js';
import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'grid';
const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson';
const SYNC_URL = 'https://x.bidswitch.net/sync?ssp=themediagrid';
const TIME_TO_LIVE = 360;
const USER_ID_KEY = 'tmguid';
const GVLID = 686;
const RENDERER_URL = 'https://acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';

let hasSynced = false;

export const storage = getStorageManager(GVLID, BIDDER_CODE);
const LOG_ERROR_MESS = {
noAuid: 'Bid from response has no auid parameter - ',
noAdm: 'Bid from response has no adm parameter - ',
Expand All @@ -23,6 +24,9 @@ const LOG_ERROR_MESS = {
hasEmptySeatbidArray: 'Response has empty seatbid array',
hasNoArrayOfBids: 'Seatbid from response has no array of bid objects - '
};

let hasSynced = false;

export const spec = {
code: BIDDER_CODE,
supportedMediaTypes: [ BANNER, VIDEO ],
Expand Down Expand Up @@ -50,7 +54,6 @@ export const spec = {
let jwpseg = null;
let content = null;
let schain = null;
let userId = null;
let userIdAsEids = null;
let user = null;
let userExt = null;
Expand All @@ -70,9 +73,6 @@ export const spec = {
if (!schain) {
schain = bid.schain;
}
if (!userId) {
userId = bid.userId;
}
if (!userIdAsEids) {
userIdAsEids = bid.userIdAsEids;
}
Expand All @@ -99,6 +99,8 @@ export const spec = {
impObj.ext.data = ortb2Imp.ext.data;
if (impObj.ext.data.adserver && impObj.ext.data.adserver.adslot) {
impObj.ext.gpid = impObj.ext.data.adserver.adslot;
} else {
impObj.ext.gpid = ortb2Imp.ext.data.pbadslot;
}
}
if (!utils.isEmpty(keywords)) {
Expand Down Expand Up @@ -184,6 +186,13 @@ export const spec = {
user.ext = userExt;
}

const fpdUserId = getUserIdFromFPDStorage();

if (fpdUserId) {
user = user || {};
user.id = fpdUserId;
}

if (user) {
request.user = user;
}
Expand Down Expand Up @@ -427,6 +436,20 @@ function createBannerRequest(bid, mediaType) {
return result;
}

function makeNewUserIdInFPDStorage() {
if (config.getConfig('localStorageWriteAllowed')) {
const value = utils.generateUUID().replace(/-/g, '');

storage.setDataInLocalStorage(USER_ID_KEY, value);
return value;
}
return null;
}

function getUserIdFromFPDStorage() {
return storage.getDataFromLocalStorage(USER_ID_KEY) || makeNewUserIdInFPDStorage();
}

function reformatKeywords(pageKeywords) {
const formatedPageKeywords = {};
Object.keys(pageKeywords).forEach((name) => {
Expand Down
11 changes: 11 additions & 0 deletions modules/gridBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ Maintainer: grid-tech@themediagrid.com
Module that connects to Grid demand source to fetch bids.
Grid bid adapter supports Banner and Video (instream and outstream).

#Bidder Config
You can allow writing in localStorage `pbjs.setBidderConfig` for the bidder `grid`
```
pbjs.setBidderConfig({
bidders: ["grid"],
config: {
localStorageWriteAllowed: true
}
})
```

# Test Parameters
```
var adUnits = [
Expand Down
39 changes: 38 additions & 1 deletion test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { spec, resetUserSync, getSyncUrl } from 'modules/gridBidAdapter.js';
import { spec, resetUserSync, getSyncUrl, storage } from 'modules/gridBidAdapter.js';
import { newBidder } from 'src/adapters/bidderFactory.js';
import { config } from 'src/config.js';

Expand Down Expand Up @@ -119,6 +119,10 @@ describe('TheMediaGrid Adapter', function () {
];

it('should attach valid params to the tag', function () {
const fpdUserIdVal = '0b0f84a1-1596-4165-9742-2e1a7dfac57f';
const getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(
arg => arg === 'tmguid' ? fpdUserIdVal : null);

const request = spec.buildRequests([bidRequests[0]], bidderRequest);
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
Expand All @@ -132,6 +136,9 @@ describe('TheMediaGrid Adapter', function () {
'tid': bidderRequest.auctionId,
'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'}
},
'user': {
'id': fpdUserIdVal
},
'imp': [{
'id': bidRequests[0].bidId,
'tagid': bidRequests[0].params.uid,
Expand All @@ -144,9 +151,15 @@ describe('TheMediaGrid Adapter', function () {
}
}]
});

getDataFromLocalStorageStub.restore();
});

it('make possible to process request without mediaTypes', function () {
const fpdUserIdVal = '0b0f84a1-1596-4165-9742-2e1a7dfac57f';
const getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(
arg => arg === 'tmguid' ? fpdUserIdVal : null);

const request = spec.buildRequests([bidRequests[0], bidRequests[1]], bidderRequest);
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
Expand All @@ -160,6 +173,9 @@ describe('TheMediaGrid Adapter', function () {
'tid': bidderRequest.auctionId,
'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'}
},
'user': {
'id': fpdUserIdVal
},
'imp': [{
'id': bidRequests[0].bidId,
'tagid': bidRequests[0].params.uid,
Expand All @@ -181,9 +197,15 @@ describe('TheMediaGrid Adapter', function () {
}
}]
});

getDataFromLocalStorageStub.restore();
});

it('should attach valid params to the video tag', function () {
const fpdUserIdVal = '0b0f84a1-1596-4165-9742-2e1a7dfac57f';
const getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(
arg => arg === 'tmguid' ? fpdUserIdVal : null);

const request = spec.buildRequests(bidRequests.slice(0, 3), bidderRequest);
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
Expand All @@ -197,6 +219,9 @@ describe('TheMediaGrid Adapter', function () {
'tid': bidderRequest.auctionId,
'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'}
},
'user': {
'id': fpdUserIdVal
},
'imp': [{
'id': bidRequests[0].bidId,
'tagid': bidRequests[0].params.uid,
Expand Down Expand Up @@ -227,9 +252,15 @@ describe('TheMediaGrid Adapter', function () {
}
}]
});

getDataFromLocalStorageStub.restore();
});

it('should support mixed mediaTypes', function () {
const fpdUserIdVal = '0b0f84a1-1596-4165-9742-2e1a7dfac57f';
const getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage').callsFake(
arg => arg === 'tmguid' ? fpdUserIdVal : null);

const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.data).to.be.an('string');
const payload = parseRequest(request.data);
Expand All @@ -243,6 +274,9 @@ describe('TheMediaGrid Adapter', function () {
'tid': bidderRequest.auctionId,
'ext': {'wrapper': 'Prebid_js', 'wrapper_version': '$prebid.version$'}
},
'user': {
'id': fpdUserIdVal
},
'imp': [{
'id': bidRequests[0].bidId,
'tagid': bidRequests[0].params.uid,
Expand Down Expand Up @@ -287,6 +321,8 @@ describe('TheMediaGrid Adapter', function () {
}
}]
});

getDataFromLocalStorageStub.restore();
});

it('if gdprConsent is present payload must have gdpr params', function () {
Expand Down Expand Up @@ -544,6 +580,7 @@ describe('TheMediaGrid Adapter', function () {
divid: bidRequests[2].adUnitCode
});
});

describe('floorModule', function () {
const floorTestData = {
'currency': 'USD',
Expand Down