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: support on data deletion request #10095

Merged
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
19 changes: 19 additions & 0 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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';
Expand All @@ -17,6 +18,7 @@ import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'grid';
const ENDPOINT_URL = 'https://grid.bidswitch.net/hbjson';
const USP_DELETE_DATA_HANDLER = 'https://media.grid.bidswitch.net/uspapi_delete'

const SYNC_URL = 'https://x.bidswitch.net/sync?ssp=themediagrid';
const TIME_TO_LIVE = 360;
Expand Down Expand Up @@ -462,6 +464,23 @@ export const spec = {
url: syncUrl + params
};
}
},

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)];
data.forEach(({ bids }) => bids && bids.forEach(({ bidder, params }) => {
if (aliases.includes(bidder) && params && params.uid) {
uids.push(params.uid);
}
}));
if (uids.length) {
spec.ajaxCall(USP_DELETE_DATA_HANDLER, () => {}, JSON.stringify({ uids }), {contentType: 'application/json', method: 'POST'});
}
}
};

Expand Down
42 changes: 42 additions & 0 deletions test/spec/modules/gridBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down