From 7de083c079e6ccd294f6fb25763886f6d034a368 Mon Sep 17 00:00:00 2001 From: Marcin Komorski Date: Mon, 16 Sep 2024 19:55:31 +0200 Subject: [PATCH 1/2] Adding useBaseGvlid to aliasBidAdapter --- src/adapterManager.js | 6 ++++-- test/spec/unit/core/adapterManager_spec.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/adapterManager.js b/src/adapterManager.js index a571ba62ddc..2023009edab 100644 --- a/src/adapterManager.js +++ b/src/adapterManager.js @@ -553,11 +553,13 @@ adapterManager.aliasBidAdapter = function (bidderCode, alias, options) { newAdapter = new bidAdapter.constructor(); newAdapter.setBidderCode(alias); } else { + const { useBaseGvlid = false } = options || {}; let spec = bidAdapter.getSpec(); - let gvlid = options && options.gvlid; - if (spec.gvlid != null && gvlid == null) { + const gvlid = useBaseGvlid ? spec.gvlid : options?.gvlid; + if (!useBaseGvlid && spec.gvlid != null && options?.gvlid == null) { logWarn(`Alias '${alias}' will NOT re-use the GVL ID of the original adapter ('${spec.code}', gvlid: ${spec.gvlid}). Functionality that requires TCF consent may not work as expected.`) } + let skipPbsAliasing = options && options.skipPbsAliasing; newAdapter = newBidder(Object.assign({}, spec, { code: alias, gvlid, skipPbsAliasing })); _aliasRegistry[alias] = bidderCode; diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index a68634501ac..c787754ada8 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -1630,6 +1630,16 @@ describe('adapterManager tests', function () { expect(adapterManager.videoAdapters).to.include(alias); } }); + + it('should use gvlid of original adapter when option set', () => { + const mediaType = FEATURES.VIDEO ? 'video' : 'banner' + const gvlid = 'origvlid'; + let thisSpec = Object.assign(spec, { supportedMediaTypes: [mediaType], gvlid }); + registerBidder(thisSpec); + const alias = 'bidderWithGvlid'; + adapterManager.aliasBidAdapter(CODE, alias, {useBaseGvlid: true}); + expect(adapterManager.bidderRegistry[alias].getSpec()?.gvlid).to.deep.eql(gvlid); + }) }); describe('special case for s2s-only bidders', function () { From 674efe85e3d0d16f883287c6ff9a1b4bbc023a29 Mon Sep 17 00:00:00 2001 From: Marcin Komorski Date: Tue, 17 Sep 2024 15:33:51 +0200 Subject: [PATCH 2/2] refactor --- src/adapterManager.js | 2 +- test/spec/unit/core/adapterManager_spec.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/adapterManager.js b/src/adapterManager.js index 2023009edab..63ecfc280be 100644 --- a/src/adapterManager.js +++ b/src/adapterManager.js @@ -556,7 +556,7 @@ adapterManager.aliasBidAdapter = function (bidderCode, alias, options) { const { useBaseGvlid = false } = options || {}; let spec = bidAdapter.getSpec(); const gvlid = useBaseGvlid ? spec.gvlid : options?.gvlid; - if (!useBaseGvlid && spec.gvlid != null && options?.gvlid == null) { + if (gvlid == null && spec.gvlid != null) { logWarn(`Alias '${alias}' will NOT re-use the GVL ID of the original adapter ('${spec.code}', gvlid: ${spec.gvlid}). Functionality that requires TCF consent may not work as expected.`) } diff --git a/test/spec/unit/core/adapterManager_spec.js b/test/spec/unit/core/adapterManager_spec.js index c787754ada8..3974cfde68f 100644 --- a/test/spec/unit/core/adapterManager_spec.js +++ b/test/spec/unit/core/adapterManager_spec.js @@ -1632,9 +1632,8 @@ describe('adapterManager tests', function () { }); it('should use gvlid of original adapter when option set', () => { - const mediaType = FEATURES.VIDEO ? 'video' : 'banner' const gvlid = 'origvlid'; - let thisSpec = Object.assign(spec, { supportedMediaTypes: [mediaType], gvlid }); + let thisSpec = Object.assign(spec, { gvlid }); registerBidder(thisSpec); const alias = 'bidderWithGvlid'; adapterManager.aliasBidAdapter(CODE, alias, {useBaseGvlid: true});