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 update #4447

Merged
merged 24 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
57210b5
Added Grid Bid Adapter
TheMediaGrid Oct 16, 2018
2a0bad2
remove priceType from TheMediaGrid Bid Adapter
TheMediaGrid Oct 19, 2018
12b9f52
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Feb 5, 2019
f3a8ffe
Add video support in Grid Bid Adapter
TheMediaGrid Feb 8, 2019
8e2083c
Added test parameter for video slot
TheMediaGrid Feb 12, 2019
bc9d9d4
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Feb 18, 2019
14e9ed7
update Grid Bid Adapter to set size in response bid
TheMediaGrid Feb 18, 2019
5978540
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Mar 13, 2019
0c2702f
Update Grid Bid Adapter to support identical uids in parameters
TheMediaGrid Mar 14, 2019
a7549ef
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Mar 25, 2019
2bb0c05
Fix typo in test file for Grid Bid Adapter
TheMediaGrid Mar 25, 2019
e63ae93
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 5, 2019
906d1a9
Update The Grid Media Bidder Adapter to send refererInfo.referer as '…
TheMediaGrid Jul 5, 2019
01bc84a
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Jul 30, 2019
fb96ea9
Hotfix for referrer in Grid Bid Adapter
TheMediaGrid Jul 30, 2019
31d29fb
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Oct 23, 2019
2f54618
Grid Bid Adapter: added wrapperType and wrappweVersion to the ad request
TheMediaGrid Oct 23, 2019
5855899
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Oct 31, 2019
aef566d
TheMediaGrid Bid Adapter: added sync url
TheMediaGrid Oct 31, 2019
4e3d612
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Nov 6, 2019
f7acabc
TheMediaGrid Bid Adapter: added GDPR params to sync url
TheMediaGrid Nov 6, 2019
9eba827
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Nov 11, 2019
78cd4fd
Merge remote-tracking branch 'upstream/master'
TheMediaGrid Nov 18, 2019
9a4a769
TheMediaGrid Bid Adapter: added tests for getUserSyncs function
TheMediaGrid Nov 18, 2019
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
30 changes: 30 additions & 0 deletions modules/gridBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { VIDEO, BANNER } from '../src/mediaTypes';

const BIDDER_CODE = 'grid';
const ENDPOINT_URL = '//grid.bidswitch.net/hb';
const SYNC_URL = '//x.bidswitch.net/sync?ssp=iow_labs';
const TIME_TO_LIVE = 360;
const RENDERER_URL = '//acdn.adnxs.com/video/outstream/ANOutstreamVideo.js';

let hasSynced = false;

const LOG_ERROR_MESS = {
noAuid: 'Bid from response has no auid parameter - ',
noAdm: 'Bid from response has no adm parameter - ',
Expand Down Expand Up @@ -136,6 +139,25 @@ export const spec = {
}
if (errorMessage) utils.logError(errorMessage);
return bidResponses;
},
getUserSyncs: function (syncOptions, responses, gdprConsent) {
if (!hasSynced && syncOptions.pixelEnabled) {
let params = '';

if (gdprConsent && typeof gdprConsent.consentString === 'string') {
if (typeof gdprConsent.gdprApplies === 'boolean') {
params += `&gdpr=${Number(gdprConsent.gdprApplies)}&gdpr_consent=${gdprConsent.consentString}`;
} else {
params += `&gdpr_consent=${gdprConsent.consentString}`;
}
}

hasSynced = true;
return {
type: 'image',
url: SYNC_URL + params
};
}
}
};

Expand Down Expand Up @@ -244,4 +266,12 @@ function createRenderer (bid, rendererParams) {
return renderer;
}

export function resetUserSync() {
hasSynced = false;
}

export function getSyncUrl() {
return SYNC_URL;
}

registerBidder(spec);
89 changes: 88 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 } from 'modules/gridBidAdapter';
import { spec, resetUserSync, getSyncUrl } from 'modules/gridBidAdapter';
import { newBidder } from 'src/adapters/bidderFactory';

describe('TheMediaGrid Adapter', function () {
Expand Down Expand Up @@ -577,4 +577,91 @@ describe('TheMediaGrid Adapter', function () {
expect(result).to.deep.equal(expectedResponse);
});
});

describe('user sync', function () {
const syncUrl = getSyncUrl();

beforeEach(function () {
resetUserSync();
});

it('should register the Emily iframe', function () {
let syncs = spec.getUserSyncs({
pixelEnabled: true
});

expect(syncs).to.deep.equal({type: 'image', url: syncUrl});
});

it('should not register the Emily iframe more than once', function () {
let syncs = spec.getUserSyncs({
pixelEnabled: true
});
expect(syncs).to.deep.equal({type: 'image', url: syncUrl});

// when called again, should still have only been called once
syncs = spec.getUserSyncs();
expect(syncs).to.equal(undefined);
});

it('should pass gdpr params if consent is true', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {
gdprApplies: true, consentString: 'foo'
})).to.deep.equal({
type: 'image', url: `${syncUrl}&gdpr=1&gdpr_consent=foo`
});
});

it('should pass gdpr params if consent is false', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {
gdprApplies: false, consentString: 'foo'
})).to.deep.equal({
type: 'image', url: `${syncUrl}&gdpr=0&gdpr_consent=foo`
});
});

it('should pass gdpr param gdpr_consent only when gdprApplies is undefined', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {
consentString: 'foo'
})).to.deep.equal({
type: 'image', url: `${syncUrl}&gdpr_consent=foo`
});
});

it('should pass no params if gdpr consentString is not defined', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {})).to.deep.equal({
type: 'image', url: syncUrl
});
});

it('should pass no params if gdpr consentString is a number', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {
consentString: 0
})).to.deep.equal({
type: 'image', url: syncUrl
});
});

it('should pass no params if gdpr consentString is null', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {
consentString: null
})).to.deep.equal({
type: 'image', url: syncUrl
});
});

it('should pass no params if gdpr consentString is a object', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, {
consentString: {}
})).to.deep.equal({
type: 'image', url: syncUrl
});
});

it('should pass no params if gdpr is not defined', function () {
expect(spec.getUserSyncs({ pixelEnabled: true }, {}, undefined)).to.deep.equal({
type: 'image', url: syncUrl
});
});
});
});