Skip to content

adnuntias Bid Adapter: Added GDPR support and segment passing - #6796

Merged
mmoschovas merged 8 commits into
prebid:masterfrom
Adnuntius:master
Jun 3, 2021
Merged

adnuntias Bid Adapter: Added GDPR support and segment passing#6796
mmoschovas merged 8 commits into
prebid:masterfrom
Adnuntius:master

Conversation

@mikael-lundin

Copy link
Copy Markdown
Contributor

Type of change

  • Bugfix
  • Feature
  • New bidder adapter
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Does this change affect user-facing APIs or examples documented on http://prebid.org?
  • Other

Description of change

Adding GDPR support for the bid adapter and allowing customers to pass segments through the bidder config. If a user has accepted our GLV ID we will use the segments passed on to the adserver. If not, they will not be matched against targeted line items by the adserver.

For any changes that affect user-facing APIs or example code documented on http://prebid.org, please provide:

Other information

@patmmccann patmmccann changed the title Master merge issues adnuntias Bid Adapter: Master merge issues May 19, 2021
@mikael-lundin mikael-lundin changed the title adnuntias Bid Adapter: Master merge issues adnuntias Bid Adapter: Added GDPR support and segment passing May 20, 2021
@ChrisHuie

Copy link
Copy Markdown
Collaborator

@mikael-lundin can you please add some test coverage to this pr please 🙏

@mikael-lundin

Copy link
Copy Markdown
Contributor Author

I will since you asked so friendly 😄

@mikael-lundin

Copy link
Copy Markdown
Contributor Author

Tests are now added. 🥇 <- I give this to myself 😃

@mmoschovas mmoschovas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikael-lundin a few comments here

Comment thread modules/adnuntiusBidAdapter.js Outdated
const bidRequests = {};
const requests = [];
const segments = config.getConfig('segments');
utils.logMessage('CONF', segments)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be removed entirely, as this does not seem like a necessary log to me. I believe that we would rather not inflate code with messaging that is not pertinent as this is neither a user warning/error or really clear in label as to what is being logged - also this can be achieved in the console via a pbjs.getConfig('segments').

@mikael-lundin mikael-lundin May 26, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that was just a blunder from me, will remove that.

Comment thread modules/adnuntiusBidAdapter.js Outdated
const networks = {};
const bidRequests = {};
const requests = [];
const segments = config.getConfig('segments');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not so much of a change request, but more curious about this config setting. I am not aware of segments being set under the config at the top level, so I am curious if this is something specific to your adapter and if so, should it be in your docs? I also want to make sure that this is not meant to be first party segment data that is defined to be passed via ortb2.user.data and ortb2.site.content.data respectively

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was strugling to find where to put it, and yes it's just meant to be for our adapter only, but if ortb2.user.data is the place to put it I will go for it. Should I also prefix our segments (like adn-segments) or are there any other rules for how to structure it?

@mmoschovas mmoschovas May 26, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can offer suggestions, but Im not sure where you mean to put the prefix. Maybe reviewing this will offer a better understanding of first party segment data: https://docs.prebid.org/features/firstPartyData.html. You can see under ortb2.user.data, this is an array of objects that "should" include at the very least name and segment (with segment as an array of objects), as well as ext property that can contain other data. Let me know if this helps in any way. Also, the pubs will have the option to utilize setBidderConfig to set config data meant only for specific adapters, meaning that only your adapter will receive those values if set using your bidder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now be solved and the documentation is filed under this pull request:
prebid/prebid.github.io#2975

Comment thread modules/adnuntiusBidAdapter.js Outdated
let segments;
if (userData) {
userData.forEach(userdat => {
segments = (userdat.segment) ? userdat.segment.map(segment => segment.id) : undefined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikael-lundin thanks for updating. Do you only want to pass those segments defined with the name 'adnuntius'? Currently there is no filter setup for this here, meaning that if any segment data defined after this type will overwrite the data I believe you are intended to leverage. i.e. if the below is defined in the config, you will only receive the segment 3 and not 1 and 2.

ortb2: {
    user: {							
        data: [{								
            name: "adnuntius",								
            segment: [	{ id: "1" },	{ id: "2" }	]							
        },{								
            name: "other",								
            segment: [	{ id: "3" }]							
        }]						
    }					
}

I would suggest either setting a filter for the name so you only match on those segments like:

userData.filter(data => data.name === 'adnuntius').forEach(userdat => {...});

Or if you want to collect all segment data, I would suggest something along the lines of this seeing as you check for segment length and then you can also remove the first two parts of the condition since segments will always be an array:

let segments = [];
  if (userData) {
    userData.forEach(userdat => {
      if (userdat.segment) segments.push(...userdat.segment.map(segment => segment.id));
    });
  }

A bunch of ways you can do this, but I wanted to make sure that this is corrected so you receive the data you are expecting. Also, I may suggest adding a filter prior to the segment map function to ensure the index of the array contains a property called id - the reason being is that this data structure is fairly new and if a pub were to create it using an array like ['1234','5678'] instead of [{id: '1234'}, {id:'5678'}] you will receive empty comma separated values. Could be something as simple as the following I think would work:

userdat.segment.filter(seg => seg.id).map(...);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that, you kind of saved my ass a bit! :D I've added some changes to it so that it works more as you say, and for now we will just pass all the segments that we see to the adserver.

@lgtm-com

lgtm-com Bot commented May 31, 2021

Copy link
Copy Markdown

This pull request introduces 1 alert when merging 21a1cb1 into 8183e85 - view on LGTM.com

new alerts:

  • 1 for Comparison between inconvertible types

@mmoschovas

Copy link
Copy Markdown
Contributor

@mikael-lundin can you fix this LGTM alert? Since the getSegmentsFromOrtb always returns an array there is no need for those two checks - as the array will always exist and be of type array. I think you should be fine simply checking the array length in your condition, which I think should remove this LGTM alert

@mikael-lundin

mikael-lundin commented Jun 3, 2021

Copy link
Copy Markdown
Contributor Author

I think I've done what you asked for :D Saw no alerts on my end while testing.

@mmoschovas mmoschovas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these updates! LGTM

@mmoschovas
mmoschovas merged commit 70317f9 into prebid:master Jun 3, 2021
@jsnellbaker jsnellbaker added patch and removed minor labels Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants