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

Support for First Party Data #134

Merged
merged 6 commits into from
Aug 29, 2019
Merged

Conversation

yoalex5
Copy link
Collaborator

@yoalex5 yoalex5 commented Aug 6, 2019

GitHub issue #131

//ACL block

  1. Access Control List

TargetingParams API:

void addBidderToAccessControlList(String bidderName)
void removeBidderFromAccessControlList(String bidderName)
void clearAccessControlList()

Example:

TargetingParams.addBidderToAccessControlList(TargetingParams.BIDDER_NAME_RUBICON_PROJECT);

OpenRTB request:

"ext": {
	"prebid": {
		"data": {
			"bidders": [
				"rubicon"]
		}
	}
}

//data block
2. global user data

TargetingParams API:

void addUserData(String key, String value)
void updateUserData(String key, Set<String> value)
void removeUserData(String key)
void clearUserData()

Example:

TargetingParams.addUserData("globalUserDataKey1", "globalUserDataValue1");

OpenRTB request:

"user": {
	"ext": {
		"data": {
			"globalUserDataKey1": [
				"globalUserDataValue1"]
		}
	}
}
  1. global context data

TargetingParams API:

void addContextData(String key, String value)
void updateContextData(String key, Set<String> value)
void removeContextData(String key)
void clearContextData()

Example:

TargetingParams.addContextData("globalContextDataKey1", "globalContextDataValue1");

OpenRTB request:

"app": {
	"ext": {
		"data": {
			"globalContextDataKey1": [
				"globalContextDataValue1"]
		}
	}
}
  1. adunit context data

AdUnit API:

void addContextData(String key, String value)
void updateContextData(String key, Set<String> value)
void removeContextData(String key)
void clearContextData()

Example:

adUnit.addContextData("adunitContextDataKey1", "adunitContextDataValue1");

OpenRTB request:

"imp": [{
	"ext": {
		"context": {
			"data": {
				"adunitContextDataKey1": [
					"adunitContextDataValue1"]
			}
		}
	}
}]
  1. global context keywords

TargetingParams API:

void addContextKeyword(String keyword)
void addContextKeywords(Set<String> keywords)
void removeContextKeyword(String keyword)
void clearContextKeywords()

Example:

TargetingParams.addContextKeyword("globalContextKeywordValue1");
TargetingParams.addContextKeyword("globalContextKeywordValue2");
TargetingParams.addContextKeyword("globalContextKeywordValue3");

OpenRTB request:

"app": {
    "keywords": "globalContextKeywordValue1,globalContextKeywordValue2,globalContextKeywordValue3"
}
  1. global user keywords

TargetingParams API:

void addUserKeyword(String keyword)
void addUserKeywords(Set<String> keywords)
void removeUserKeyword(String keyword)
void clearUserKeywords()

Example:

TargetingParams.addUserKeyword("globalUserKeywordValue1");
TargetingParams.addUserKeyword("globalUserKeywordValue2");
TargetingParams.addUserKeyword("globalUserKeywordValue3");

OpenRTB request:

"user": {
    "keywords": "globalUserKeywordValue1,globalUserKeywordValue2,globalUserKeywordValue3"
}
  1. adunit context keywords

AdUnit API:

void addContextKeyword(String keyword)
void addContextKeywords(Set<String> keywords)
void removeContextKeyword(String keyword)
void clearContextKeywords()

Example:

adUnit.addContextKeyword("adunitContextKeywordValue1");
adUnit.addContextKeyword("adunitContextKeywordValue2");
adUnit.addContextKeyword("adunitContextKeywordValue3");

OpenRTB request:

"imp": [{
    "ext": {
        "context": {
            "keywords": "adunitContextKeywordValue1,adunitContextKeywordValue2,adunitContextKeywordValue3"
        }
    }
}]

Deprecated API
AdUnit. userKeywords was marked as deprecated, because this parameter creates user.keywords object.
Since global user keywords API has been added in this PR and it brings the functionality to work with userKeywords on global level hence I have added a compatibility function to create user.keywords object.
AdUnit.UserKeyword uses TargetingParams.UserKeyword inside. The parameter key will be omitted

android_all_cahnges.zip

@yoalex5 yoalex5 requested a review from avohraa August 6, 2019 17:13
@yoalex5 yoalex5 added this to the Prebid SDK 1.2 milestone Aug 6, 2019
Copy link
Collaborator

@avohraa avohraa left a comment

Choose a reason for hiding this comment

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

I have added a few comments/questions/suggestions. Kindly have a look at it.

@yoalex5
Copy link
Collaborator Author

yoalex5 commented Aug 13, 2019

@avohraa, I have added changes with you proposals.
Could you please check them?

@anwzhang
Copy link
Contributor

@yoalex5

  • Prebid Server only pass these data through right, it's up to the bidders how they consume it?
  • If a publisher calls TargetingParams.addUserData("bidders", "randomdata") it would corrupt the data from addBidderToAccessControlList?

@yoalex5
Copy link
Collaborator Author

yoalex5 commented Aug 16, 2019

@anwzhang

Prebid Server only pass these data through right, it's up to the bidders how they consume it?

If take a look at a request from PS to a bidder you will see that PS sends data to the bidder from Access Control List. @bszekely1 knows more about it

If a publisher calls TargetingParams.addUserData("bidders", "randomdata") it would corrupt the data from addBidderToAccessControlList?

TargetingParams.addUserData("bidders", "randomdata"); will create:

"user": {
    "ext": {
        "data": {
            "bidders": ["randomdata"]
        }
    }
}

TargetingParams.addBidderToAccessControlList("rubicon"); will create:

"ext": {
    "prebid": {
        "data": {
            "bidders": ["rubicon"]
        }
    }
}

@bszekely1
Copy link
Contributor

Prebid Server only pass these data through right, it's up to the bidders how they consume it?

This solution for First Party Data is a common method of passing FPD to all adapters, by way of the ACL. To answer your question yes, each adapter will need to read from an internal data structure to consume it.

As a goal of Prebid in general, we are working towards having an externally (publisher facing) method to pass common features for each bidder. This iteration we are integrating FPD and will attempt to follow OpenRTB like attributes wherever possible.

If a publisher calls TargetingParams.addUserData("bidders", "randomdata") it would corrupt the data from addBidderToAccessControlList?

As Oleksandr has commented, you cannot corrupt the data by passing the ACL bidder list. If you do so, the solution as shown above will just treat it like first party data and pass it for adapters to consume.

anwzhang
anwzhang previously approved these changes Aug 20, 2019
@anwzhang
Copy link
Contributor

@yoalex5 Can you resolve the merge conflict ?

…ty_data

# Conflicts:
#	PrebidMobile/API1.0/src/test/java/org/prebid/mobile/PrebidServerAdapterTest.java
@yoalex5
Copy link
Collaborator Author

yoalex5 commented Aug 27, 2019

@anwzhang I have resolved the merge conflicts

@yoalex5
Copy link
Collaborator Author

yoalex5 commented Aug 28, 2019

@anwzhang, could you please review it ?

@@ -469,24 +469,39 @@ private JSONObject getPostData() throws NoContextException {
if (ext != null && ext.length() > 0) {
postData.put("ext", ext);
}

JSONObject objectWithoutEmptyValues = Util.getObjectWithoutEmptyValues(postData);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see necessary for this part of code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This part of code allows us to write an elegant code like:

user.put("keywords", globalUserKeywordString);
ext.put("consent", TargetingParams.getGDPRConsentString());

instead of:

if (!TextUtils.isEmpty(finalKeywords)) {
    user.put("keywords", finalKeywords);
}
if (TargetingParams.isSubjectToGDPR() != null) {
    ext.put("consent", TargetingParams.getGDPRConsentString());
}

Step by step (during refactoring) I am going to remove redundant if (!TextUtils.isEmpty()) checks

@yoalex5 yoalex5 merged commit 1158839 into prebid:master Aug 29, 2019
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