Skip to content

Commit

Permalink
Prebid Core: Added aliasRegistry to the Public API (prebid#9467)
Browse files Browse the repository at this point in the history
* added aliasRegistry to the public api

* reverted a few changes made for local dev

* addressed feedback
  • Loading branch information
jlquaccia authored and JacobKlein26 committed Feb 8, 2023
1 parent 8e3abe0 commit 3742203
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/prebid.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,14 @@ $$PREBID_GLOBAL$$.aliasBidder = function (bidderCode, alias, options) {
}
};

/**
* @alias module:pbjs.aliasRegistry
*/
$$PREBID_GLOBAL$$.aliasRegistry = adapterManager.aliasRegistry;
config.getConfig('aliasRegistry', config => {
if (config.aliasRegistry === 'private') delete $$PREBID_GLOBAL$$.aliasRegistry;
});

/**
* The bid response object returned by an external bidder adapter during the auction.
* @typedef {Object} AdapterBidResponse
Expand Down
14 changes: 14 additions & 0 deletions test/spec/unit/pbjs_api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3017,6 +3017,20 @@ describe('Unit: Prebid Module', function () {
});
});

describe('aliasRegistry', function () {
it('should return the same value as adapterManager.aliasRegistry by default', function () {
const adapterManagerAliasRegistry = adapterManager.aliasRegistry;
const pbjsAliasRegistry = $$PREBID_GLOBAL$$.aliasRegistry;
assert.equal(adapterManagerAliasRegistry, pbjsAliasRegistry);
});

it('should return undefined if the aliasRegistry config option is set to private', function () {
configObj.setConfig({ aliasRegistry: 'private' });
const pbjsAliasRegistry = $$PREBID_GLOBAL$$.aliasRegistry;
assert.equal(pbjsAliasRegistry, undefined);
});
});

describe('setPriceGranularity', function () {
it('should log error when not passed granularity', function () {
const logErrorSpy = sinon.spy(utils, 'logError');
Expand Down

0 comments on commit 3742203

Please sign in to comment.