Repository navigation
[LiveIntent RTD provider]: fix https://github.com/prebid/Prebid.js/issues/16221 #16322
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
Open
3link
wants to merge
2
commits into
prebid:master
Choose a base branch
from
LiveIntent:DATA-80819
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+139
−120
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,116 +1,142 @@ | ||
| import { liveIntentRtdSubmodule } from 'modules/liveIntentRtdProvider.js'; | ||
| import * as utils from 'src/utils.js'; | ||
| import * as prebidGlobal from 'src/prebidGlobal.js'; | ||
| import { expect } from 'chai'; | ||
|
|
||
| describe('LiveIntent Rtd Provider', function () { | ||
| const SUBMODULE_NAME = 'liveintent'; | ||
| const SEGMENTS = ['asa_1231', 'lalo_4311', 'liurl_99123']; | ||
| const EXPECTED_USER_DATA = [{ | ||
| name: 'liveintent.com', | ||
| segment: SEGMENTS.map(id => ({ id })) | ||
| }]; | ||
|
|
||
| describe('submodule `init`', function () { | ||
| const config = { | ||
| name: SUBMODULE_NAME, | ||
| let sandbox; | ||
| let getUserIdsStub; | ||
|
|
||
| function makeReqBidsConfig(globalOrtb2 = {}) { | ||
| return { | ||
| ortb2Fragments: { | ||
| global: globalOrtb2, | ||
| bidder: {} | ||
| } | ||
| }; | ||
| it('init returns true when the subModuleName is defined', function () { | ||
| const value = liveIntentRtdSubmodule.init(config); | ||
| expect(value).to.equal(true); | ||
| } | ||
|
|
||
| function stubUserIds(userIds) { | ||
| getUserIdsStub = sandbox.stub().returns(userIds); | ||
| sandbox.stub(prebidGlobal, 'getGlobal').returns({ | ||
| getUserIds: getUserIdsStub | ||
| }); | ||
| } | ||
|
|
||
| beforeEach(function () { | ||
| sandbox = sinon.createSandbox(); | ||
| }); | ||
|
|
||
| describe('submodule `onBidRequestEvent`', function () { | ||
| const bidRequestExample = { | ||
| bidderCode: 'appnexus', | ||
| auctionId: '8dbd7cb1-7f6d-4f84-946c-d0df4837234a', | ||
| bidderRequestId: '2a038c6820142b', | ||
| bids: [ | ||
| { | ||
| bidder: 'appnexus', | ||
| userId: { | ||
| lipb: { | ||
| segments: [ | ||
| 'asa_1231', | ||
| 'lalo_4311', | ||
| 'liurl_99123' | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }; | ||
| afterEach(function () { | ||
| sandbox.restore(); | ||
| }); | ||
|
|
||
| describe('submodule `init`', function () { | ||
| it('returns true', function () { | ||
| expect(liveIntentRtdSubmodule.init({ name: SUBMODULE_NAME })).to.equal(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('submodule `getBidRequestData`', function () { | ||
| it('exists', function () { | ||
| expect(liveIntentRtdSubmodule.onBidRequestEvent).to.be.a('function'); | ||
| expect(liveIntentRtdSubmodule.getBidRequestData).to.be.a('function'); | ||
| }); | ||
|
|
||
| it('calls callback and leaves ortb2 unchanged when getUserIds is missing', function () { | ||
| sandbox.stub(prebidGlobal, 'getGlobal').returns({}); | ||
| const reqBidsConfigObj = makeReqBidsConfig(); | ||
| const callback = sandbox.spy(); | ||
|
|
||
| liveIntentRtdSubmodule.getBidRequestData(reqBidsConfigObj, callback); | ||
|
|
||
| expect(callback.calledOnce).to.equal(true); | ||
| expect(reqBidsConfigObj.ortb2Fragments.global).to.deep.equal({}); | ||
| }); | ||
|
|
||
| it('undefined segments field does not change the ortb2', function() { | ||
| const bidRequest = { | ||
| bidderCode: 'appnexus', | ||
| auctionId: '8dbd7cb1-7f6d-4f84-946c-d0df4837234a', | ||
| bidderRequestId: '2a038c6820142b', | ||
| bids: [ | ||
| { | ||
| bidder: 'appnexus', | ||
| ortb2: {} | ||
| } | ||
| ] | ||
| it('calls callback and leaves ortb2 unchanged when segments are missing', function () { | ||
| stubUserIds({ lipb: { lipbid: 'abc' } }); | ||
|
|
||
| const existing = { | ||
| name: 'example.com', | ||
| segment: [{ id: 'a_1231' }, { id: 'b_4311' }] | ||
| }; | ||
|
|
||
| liveIntentRtdSubmodule.onBidRequestEvent(bidRequest); | ||
| const ortb2 = bidRequest.bids[0].ortb2; | ||
| expect(ortb2).to.deep.equal({}); | ||
| const reqBidsConfigObj = makeReqBidsConfig({ | ||
| source: {}, | ||
| user: { data: [existing] } | ||
| }); | ||
| const callback = sandbox.spy(); | ||
|
|
||
| liveIntentRtdSubmodule.getBidRequestData(reqBidsConfigObj, callback); | ||
|
|
||
| expect(callback.calledOnce).to.equal(true); | ||
| expect(reqBidsConfigObj.ortb2Fragments.global).to.deep.equal({ | ||
| source: {}, | ||
| user: { data: [existing] } | ||
| }); | ||
| }); | ||
|
|
||
| it('extracts segments and move them to the bidRequest.ortb2.user.data when the ortb2 is undefined', function() { | ||
| const bidRequest = utils.deepClone(bidRequestExample); | ||
| it('calls callback and leaves ortb2 unchanged when segments are empty', function () { | ||
| stubUserIds({ lipb: { segments: [] } }); | ||
| const reqBidsConfigObj = makeReqBidsConfig(); | ||
| const callback = sandbox.spy(); | ||
|
|
||
| liveIntentRtdSubmodule.getBidRequestData(reqBidsConfigObj, callback); | ||
|
|
||
| liveIntentRtdSubmodule.onBidRequestEvent(bidRequest); | ||
| const ortb2 = bidRequest.bids[0].ortb2; | ||
| const expectedOrtb2 = { user: { data: [{ name: 'liveintent.com', segment: [{ id: 'asa_1231' }, { id: 'lalo_4311' }, { id: 'liurl_99123' }] }] } }; | ||
| expect(ortb2).to.deep.equal(expectedOrtb2); | ||
| expect(callback.calledOnce).to.equal(true); | ||
| expect(reqBidsConfigObj.ortb2Fragments.global).to.deep.equal({}); | ||
| }); | ||
|
|
||
| it('extracts segments and move them to the bidRequest.ortb2.user.data when user is undefined', function() { | ||
| bidRequestExample.bids[0].ortb2 = { source: {} }; | ||
| const bidRequest = utils.deepClone(bidRequestExample); | ||
| it('writes liveintent.com user.data from getUserIds().lipb.segments', function () { | ||
| stubUserIds({ lipb: { lipbid: 'abc', segments: SEGMENTS } }); | ||
| const reqBidsConfigObj = makeReqBidsConfig(); | ||
| const callback = sandbox.spy(); | ||
|
|
||
| liveIntentRtdSubmodule.getBidRequestData(reqBidsConfigObj, callback); | ||
|
|
||
| liveIntentRtdSubmodule.onBidRequestEvent(bidRequest); | ||
| const ortb2 = bidRequest.bids[0].ortb2; | ||
| const expectedOrtb2 = { source: {}, user: { data: [{ name: 'liveintent.com', segment: [{ id: 'asa_1231' }, { id: 'lalo_4311' }, { id: 'liurl_99123' }] }] } }; | ||
| expect(ortb2).to.deep.equal(expectedOrtb2); | ||
| expect(callback.calledOnce).to.equal(true); | ||
| expect(getUserIdsStub.calledOnce).to.equal(true); | ||
| expect(reqBidsConfigObj.ortb2Fragments.global).to.deep.equal({ | ||
| user: { data: EXPECTED_USER_DATA } | ||
| }); | ||
| }); | ||
|
|
||
| it('extracts segments and move them to the bidRequest.ortb2.user.data when data is undefined', function() { | ||
| bidRequestExample.bids[0].ortb2 = { | ||
| source: {}, | ||
| user: {} | ||
| }; | ||
| const bidRequest = utils.deepClone(bidRequestExample); | ||
| it('still writes segments when lipbid is absent', function () { | ||
| stubUserIds({ lipb: { segments: SEGMENTS } }); | ||
| const reqBidsConfigObj = makeReqBidsConfig(); | ||
| const callback = sandbox.spy(); | ||
|
|
||
| liveIntentRtdSubmodule.onBidRequestEvent(bidRequest); | ||
| const ortb2 = bidRequest.bids[0].ortb2; | ||
| const expectedOrtb2 = { source: {}, user: { data: [{ name: 'liveintent.com', segment: [{ id: 'asa_1231' }, { id: 'lalo_4311' }, { id: 'liurl_99123' }] }] } }; | ||
| expect(ortb2).to.deep.equal(expectedOrtb2); | ||
| liveIntentRtdSubmodule.getBidRequestData(reqBidsConfigObj, callback); | ||
|
|
||
| expect(callback.calledOnce).to.equal(true); | ||
| expect(reqBidsConfigObj.ortb2Fragments.global.user.data).to.deep.equal(EXPECTED_USER_DATA); | ||
| }); | ||
|
|
||
| it('extracts segments and move them to the bidRequest.ortb2.user.data with the existing data', function() { | ||
| bidRequestExample.bids[0].ortb2 = { | ||
| source: {}, | ||
| user: { | ||
| data: [ | ||
| { | ||
| name: 'example.com', | ||
| segment: [ | ||
| { id: 'a_1231' }, | ||
| { id: 'b_4311' } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| it('appends to existing global user.data', function () { | ||
| stubUserIds({ lipb: { segments: SEGMENTS } }); | ||
| const existing = { | ||
| name: 'example.com', | ||
| segment: [{ id: 'a_1231' }, { id: 'b_4311' }] | ||
| }; | ||
| const bidRequest = utils.deepClone(bidRequestExample); | ||
| const reqBidsConfigObj = makeReqBidsConfig({ | ||
| source: {}, | ||
| user: { data: [existing] } | ||
| }); | ||
| const callback = sandbox.spy(); | ||
|
|
||
| liveIntentRtdSubmodule.getBidRequestData(reqBidsConfigObj, callback); | ||
|
|
||
| liveIntentRtdSubmodule.onBidRequestEvent(bidRequest); | ||
| const ortb2 = bidRequest.bids[0].ortb2; | ||
| const expectedOrtb2 = { source: {}, user: { data: [{ name: 'example.com', segment: [{ id: 'a_1231' }, { id: 'b_4311' }] }, { name: 'liveintent.com', segment: [{ id: 'asa_1231' }, { id: 'lalo_4311' }, { id: 'liurl_99123' }] }] } }; | ||
| expect(ortb2).to.deep.equal(expectedOrtb2); | ||
| expect(callback.calledOnce).to.equal(true); | ||
| expect(reqBidsConfigObj.ortb2Fragments.global).to.deep.equal({ | ||
| source: {}, | ||
| user: { data: [existing, ...EXPECTED_USER_DATA] } | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a publisher configures LiveIntent with
bidders: ['allowedBidder']inuserSync.userIds,getUserIds()still exposes its segments throughinitializedSubmodules.combined(modules/userId/index.ts:609-610). Writing those segments intoortb2Fragments.globalthen includes them in every bidder's request, including bidders excluded by the publisher's allowlist. Normal User ID enrichment preserves this restriction using bidder-specific fragments. Preserve the same bidder scope when addinguser.data, rather than turning restricted LiveIntent data into globally shared FPD.AGENTS.md reference: AGENTS.md:L119-L119
Useful? React with 👍 / 👎.