From 2025bcfdd333571c06cda3769a20ed467f723e80 Mon Sep 17 00:00:00 2001 From: TheMediaGrid Date: Tue, 6 Jun 2023 15:35:24 +0300 Subject: [PATCH 1/3] TheMediaGrid: added onDataDeletionRequest handler --- modules/gridBidAdapter.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index 130eac9512d..f59b93c48d8 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -11,6 +11,7 @@ import { isNumber, isStr } from '../src/utils.js'; +import { ajax } from '../src/ajax.js'; import { registerBidder } from '../src/adapters/bidderFactory.js'; import { Renderer } from '../src/Renderer.js'; import { VIDEO, BANNER } from '../src/mediaTypes.js'; @@ -20,6 +21,7 @@ import { find } from '../src/polyfill.js'; const BIDDER_CODE = 'grid'; const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson'; +const USP_DELETE_DATA_HANDLER = 'https://grid.bidswitch.net/uspapi_delete' const ADAPTER_VERSION_FOR_CRITEO_MODE = 34; const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb'; @@ -496,6 +498,19 @@ export const spec = { url: syncUrl + params }; } + }, + + onDataDeletionRequest: function(data) { + const uids = []; + const aliases = [spec.code , ...spec.aliases.map((alias) => alias.code || alias)]; + data.forEach(({ bids }) => bids && bids.forEach(({ bidder, params }) => { + if (aliases.includes(bidder) && params && params.uid) { + uids.push(params.uid); + } + })); + if (uids.length) { + ajax(USP_DELETE_DATA_HANDLER, () => {}, JSON.stringify({ uids }), {contentType: 'application/json', method: 'POST'}); + } } }; From b4946e5714c99b7a5e9bd02ca3a6a4db1a5207e5 Mon Sep 17 00:00:00 2001 From: TheMediaGrid Date: Tue, 6 Jun 2023 16:54:27 +0300 Subject: [PATCH 2/3] TheMediaGrid: fix endpoint for USP delete data handler --- modules/gridBidAdapter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index f59b93c48d8..87e85f9ff35 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -21,7 +21,7 @@ import { find } from '../src/polyfill.js'; const BIDDER_CODE = 'grid'; const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson'; -const USP_DELETE_DATA_HANDLER = 'https://grid.bidswitch.net/uspapi_delete' +const USP_DELETE_DATA_HANDLER = 'https://media.grid.bidswitch.net/uspapi_delete' const ADAPTER_VERSION_FOR_CRITEO_MODE = 34; const CDB_ENDPOINT = 'https://bidder.criteo.com/cdb'; From 632f22a77e48739d5dca2620702dc9130ba846e6 Mon Sep 17 00:00:00 2001 From: TheMediaGrid Date: Wed, 28 Jun 2023 20:45:21 +0300 Subject: [PATCH 3/3] TheMediaGrid: added tests --- modules/gridBidAdapter.js | 8 +++-- test/spec/modules/gridBidAdapter_spec.js | 42 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/modules/gridBidAdapter.js b/modules/gridBidAdapter.js index 0d10f981232..ee8712b1de3 100644 --- a/modules/gridBidAdapter.js +++ b/modules/gridBidAdapter.js @@ -466,16 +466,20 @@ export const spec = { } }, + ajaxCall: function(url, cb, data, options) { + return ajax(url, cb, data, options); + }, + onDataDeletionRequest: function(data) { const uids = []; - const aliases = [spec.code , ...spec.aliases.map((alias) => alias.code || alias)]; + const aliases = [spec.code, ...spec.aliases.map((alias) => alias.code || alias)]; data.forEach(({ bids }) => bids && bids.forEach(({ bidder, params }) => { if (aliases.includes(bidder) && params && params.uid) { uids.push(params.uid); } })); if (uids.length) { - ajax(USP_DELETE_DATA_HANDLER, () => {}, JSON.stringify({ uids }), {contentType: 'application/json', method: 'POST'}); + spec.ajaxCall(USP_DELETE_DATA_HANDLER, () => {}, JSON.stringify({ uids }), {contentType: 'application/json', method: 'POST'}); } } }; diff --git a/test/spec/modules/gridBidAdapter_spec.js b/test/spec/modules/gridBidAdapter_spec.js index c1edff46dc0..2f6e3990d82 100644 --- a/test/spec/modules/gridBidAdapter_spec.js +++ b/test/spec/modules/gridBidAdapter_spec.js @@ -2,6 +2,7 @@ import { expect } from 'chai'; import { spec, resetUserSync, getSyncUrl, storage } from 'modules/gridBidAdapter.js'; import { newBidder } from 'src/adapters/bidderFactory.js'; import { config } from 'src/config.js'; +import {ENDPOINT_DOMAIN, ENDPOINT_PROTOCOL} from '../../../modules/adpartnerBidAdapter'; describe('TheMediaGrid Adapter', function () { const adapter = newBidder(spec); @@ -1465,6 +1466,47 @@ describe('TheMediaGrid Adapter', function () { }); }); + describe('onDataDeletionRequest', function() { + let ajaxStub; + beforeEach(function() { + ajaxStub = sinon.stub(spec, 'ajaxCall'); + }); + + it('should send right request on onDataDeletionRequest call', function() { + spec.onDataDeletionRequest([{ + bids: [ + { + bidder: 'grid', + params: { + uid: 1 + } + }, + { + bidder: 'grid', + params: { + uid: 2 + } + }, + { + bidder: 'another', + params: { + uid: 3 + } + }, + { + bidder: 'gridNM', + params: { + uid: 4 + } + } + ], + }]); + expect(ajaxStub.calledOnce).to.equal(true); + expect(ajaxStub.firstCall.args[0]).to.equal('https://media.grid.bidswitch.net/uspapi_delete'); + expect(ajaxStub.firstCall.args[2]).to.equal('{"uids":[1,2,4]}'); + }); + }); + describe('user sync', function () { const syncUrl = getSyncUrl();