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

SeedingAlliance Bid Adapter : get and set UUID and read EIDs where applicable #11201

Merged
merged 29 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7281e54
add seedingAlliance Adapter
sag-jonhil Dec 17, 2019
4612570
Merge pull request #1 from prebid/master
Jan 24, 2020
043b2a0
add two native default params
sag-jonhil Feb 11, 2020
bd9a1cd
...
sag-jonhil Feb 11, 2020
bfe4fdf
...
sag-jonhil Feb 11, 2020
4e6e34a
Merge pull request #2 from prebid/master
Feb 11, 2020
1771978
seedingAlliance Adapter: add two more default native params
sag-jonhil Feb 11, 2020
a193ea7
Merge branch 'seedingAlliance' of https://github.com/SeedingAllianceT…
sag-jonhil Feb 11, 2020
39feec3
Merge pull request #3 from prebid/master
Jul 20, 2020
4036c82
Merge branch 'master' into seedingAlliance
sag-jonhil Jul 20, 2020
717c487
updating seedingAlliance Adapter
sag-jonhil Jul 20, 2020
d7840c3
Merge pull request #4 from prebid/master
Sep 15, 2021
351a503
fix for merge
sag-jonhil Sep 15, 2021
29dd4db
Merge pull request #6 from prebid/master
Sep 16, 2021
c77748b
Merge branch 'master' into seedingAlliance
sag-jonhil Sep 16, 2021
26eaa2b
seedingAlliance Adapter
sag-jonhil Sep 16, 2021
5dd6c15
Merge pull request #7 from prebid/master
Jan 7, 2022
85072ca
Merge branch 'seedingAlliance' into master
Jan 7, 2022
097defa
Merge pull request #9 from prebid/master
Apr 5, 2022
df192cc
Merge pull request #10 from prebid/master
Apr 19, 2022
29a2437
Merge branch 'prebid:master' into master
sag-henmus Jul 7, 2022
a652d13
Merge pull request #13 from prebid/master
sag-jonhil Jan 9, 2023
a1a92b9
Merge branch 'prebid:master' into master
sag-henmus Jul 7, 2023
548f7e8
Merge branch 'prebid:master' into master
sag-henmus Jan 16, 2024
96681fd
Merge branch 'prebid:master' into master
sag-henmus Jan 18, 2024
f08d6e4
Add UUID from LocalStorage
sag-henmus Jan 18, 2024
83a93b4
get eids and add nativendo first party id
sag-henmus Mar 5, 2024
80bba34
Add Unit Tests for UUID and EIDs
sag-henmus Jun 4, 2024
d8548b5
fix minor lint error
sag-henmus Jun 4, 2024
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
51 changes: 49 additions & 2 deletions modules/seedingAllianceBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

import {registerBidder} from '../src/adapters/bidderFactory.js';
import {BANNER, NATIVE} from '../src/mediaTypes.js';
import {_map, deepSetValue, isArray, isEmpty, replaceAuctionPrice} from '../src/utils.js';
import {_map, generateUUID, deepSetValue, isArray, isEmpty, replaceAuctionPrice} from '../src/utils.js';
import {config} from '../src/config.js';
import {convertOrtbRequestToProprietaryNative} from '../src/native.js';
import {getStorageManager} from '../src/storageManager.js';

const GVL_ID = 371;
const BIDDER_CODE = 'seedingAlliance';
const DEFAULT_CUR = 'EUR';
const ENDPOINT_URL = 'https://b.nativendo.de/cds/rtb/bid?format=openrtb2.5&ssp=pb';
const NATIVENDO_KEY = 'nativendo_id';

const NATIVE_ASSET_IDS = { 0: 'title', 1: 'body', 2: 'sponsoredBy', 3: 'image', 4: 'cta', 5: 'icon' };

export const storage = getStorageManager({bidderCode: BIDDER_CODE});

const NATIVE_PARAMS = {
title: { id: 0, name: 'title' },
body: { id: 1, name: 'data', type: 2 },
Expand All @@ -37,6 +41,7 @@ export const spec = {
validBidRequests = convertOrtbRequestToProprietaryNative(validBidRequests);

let url = bidderRequest.refererInfo.page;
let eids = getEids(validBidRequests[0]);

const imps = validBidRequests.map((bidRequest, id) => {
const imp = {
Expand Down Expand Up @@ -130,11 +135,14 @@ export const spec = {

deepSetValue(request, 'user.ext.consent', bidderRequest.gdprConsent.consentString);
deepSetValue(request, 'regs.ext.gdpr', (typeof bidderRequest.gdprConsent.gdprApplies === 'boolean' && bidderRequest.gdprConsent.gdprApplies) ? 1 : 0);
deepSetValue(request, 'user.ext.eids', eids);
}

let endpoint = config.getConfig('seedingAlliance.endpoint') || ENDPOINT_URL;

return {
method: 'POST',
url: config.getConfig('seedingAlliance.endpoint') || ENDPOINT_URL,
url: endpoint,
data: JSON.stringify(request),
bidRequests: validBidRequests
};
Expand Down Expand Up @@ -191,6 +199,45 @@ export const spec = {
}
};

const getNativendoID = () => {
let nativendoID = storage.localStorageIsEnabled() &&
storage.getDataFromLocalStorage(NATIVENDO_KEY);

if (!nativendoID) {
if (storage.localStorageIsEnabled()) {
nativendoID = generateUUID();
storage.setDataInLocalStorage(NATIVENDO_KEY, nativendoID);
}
}

return nativendoID;
}

const getEids = (bidRequest) => {
const eids = [];
const nativendoID = getNativendoID();

if (nativendoID) {
const nativendoUserEid = {
source: 'nativendo.de',
uids: [
{
id: nativendoID,
atype: 1
}
]
};

eids.push(nativendoUserEid);
}

if (bidRequest.userIdAsEids) {
eids.push(bidRequest.userIdAsEids);
}

return eids;
}

function transformSizes(requestSizes) {
if (!isArray(requestSizes)) {
return [];
Expand Down
79 changes: 79 additions & 0 deletions test/spec/modules/seedingAllianceAdapter_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// jshint esversion: 6, es3: false, node: true
import {assert, expect} from 'chai';
import {getStorageManager} from 'src/storageManager.js';
import {spec} from 'modules/seedingAllianceBidAdapter.js';
import { NATIVE } from 'src/mediaTypes.js';
import { config } from 'src/config.js';
Expand Down Expand Up @@ -100,6 +101,84 @@ describe('SeedingAlliance adapter', function () {
});
});

describe('check user ID functionality', function () {
let storage = getStorageManager({ bidderCode: 'seedingAlliance' });
let localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled');
let getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage');
const bidRequests = [{
bidId: 'bidId',
params: {}
}];
const bidderRequest = {
refererInfo: { referer: 'page' },
gdprConsent: 'CP0j9IAP0j9IAAGABCENAYEgAP_gAAAAAAYgIxBVBCpNDWFAMHBVAJIgCYAU1sARIAQAABCAAyAFAAOA8IAA0QECEAQAAAACAAAAgVABAAAAAABEAACAAAAEAQFkAAQQgAAIAAAAAAEQQgBQAAgAAAAAEAAIgAABAwQAkACQIYLEBUCAhIAgCgAAAIgBgICAAgMACEAYAAAAAAIAAIBAAgIEMIAAAAECAQAAAFhIEoACAAKgAcgA-AEAAMgAaABEACYAG8APwAhIBDAESAJYATQAw4B9gH6ARQAjQBKQC5gF6AMUAbQA3ACdgFDgLzAYMAw0BmYDVwGsgOCAcmA8cCEMELQQuCAAgGQgQMHQKAAKgAcgA-AEAAMgAaABEACYAG8AP0AhgCJAEsAJoAYYA0YB9gH6ARQAiwBIgCUgFzAL0AYoA2gBuAEXgJkATsAocBeYDBgGGgMqAZYAzMBpoDVwHFgOTAeOBC0cAHAAQABcAKACEAF0AMEAZCQgFABMADeARQAlIBcwDFAG0AeOBCgCFpAAGAAgBggEMyUAwABAAHAAPgBEACZAIYAiQB-AFzAMUAi8BeYEISQAMAC4DLAIZlIEAAFQAOQAfACAAGQANAAiABMACkAH6AQwBEgDRgH4AfoBFgCRAEpALmAYoA2gBuAEXgJ2AUOAvMBhoDLAGsgOCAcmA8cCEIELQIZlAAoAFwB9gLoAYIBAwtADAL0AzMB44AAA.f_wAAAAAAAAA'
}
let request;

before(function () {
storage.removeDataFromLocalStorage('nativendo_id');
const localStorageData = {
nativendo_id: '123'
};

getDataFromLocalStorageStub.callsFake(function (key) {
return localStorageData[key];
});
});

it('should return an empty array if local storage is not enabled', function () {
localStorageIsEnabledStub.returns(false);
$$PREBID_GLOBAL$$.bidderSettings = {
seedingAlliance: {
storageAllowed: false
}
};

request = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);
expect(request.user.ext.eids).to.be.an('array').that.is.empty;
});

it('should return an empty array if local storage is enabled but storageAllowed is false', function () {
$$PREBID_GLOBAL$$.bidderSettings = {
seedingAlliance: {
storageAllowed: false
}
};
localStorageIsEnabledStub.returns(true);

request = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);
expect(request.user.ext.eids).to.be.an('array').that.is.empty;
});

it('should return a non empty array if local storage is enabled and storageAllowed is true', function () {
$$PREBID_GLOBAL$$.bidderSettings = {
seedingAlliance: {
storageAllowed: true
}
};
localStorageIsEnabledStub.returns(true);

request = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);
expect(request.user.ext.eids).to.be.an('array').that.is.not.empty;
});

it('should return an array containing the nativendoUserEid', function () {
$$PREBID_GLOBAL$$.bidderSettings = {
seedingAlliance: {
storageAllowed: true
}
};
localStorageIsEnabledStub.returns(true);

let nativendoUserEid = { source: 'nativendo.de', uids: [{ id: '123', atype: 1 }] };
storage.setDataInLocalStorage('nativendo_id', '123');

request = JSON.parse(spec.buildRequests(bidRequests, bidderRequest).data);

expect(request.user.ext.eids).to.deep.include(nativendoUserEid);
});
});

describe('interpretResponse', function () {
const goodNativeResponse = {
body: {
Expand Down
Loading