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

OFF-876 [Prebid Adapter] Check userKey for empty string #6

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions modules/flippBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ export function getUserKey(options = {}) {
}

// If the partner provides the user key use it, otherwise fallback to cookies
if (options.userKey && isValidUserKey(options.userKey)) {
userKey = options.userKey;
return options.userKey;
if ('userKey' in options && options.userKey) {
if (isValidUserKey(options.userKey)) {
userKey = options.userKey;
return options.userKey;
}
}

// Grab from Cookie
const foundUserKey = storage.cookiesAreEnabled() && storage.getCookie(FLIPP_USER_KEY);
if (foundUserKey) {
const foundUserKey = storage.cookiesAreEnabled(null) && storage.getCookie(FLIPP_USER_KEY, null);
if (foundUserKey && isValidUserKey(foundUserKey)) {
return foundUserKey;
}

Expand All @@ -47,7 +50,7 @@ export function getUserKey(options = {}) {
}

function isValidUserKey(userKey) {
return !userKey.startsWith('#');
return typeof userKey === 'string' && !userKey.startsWith('#') && userKey.length > 0;
}

const generateUUID = () => {
Expand Down
5 changes: 3 additions & 2 deletions modules/flippBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ var adUnits = [
publisherNameIdentifier: 'wishabi-test-publisher', // Required
siteId: 1192075, // Required
zoneIds: [260678], // Optional
userKey: "", // Optional
userKey: `4188d8a3-22d1-49cb-8624-8838a22562bd`, // Optional, in UUID format
options: {
startCompact: true // Optional, default to true
startCompact: true, // Optional. Height of the experience will be reduced. Default to true
dwellExpand: true // Optional. Auto expand the experience after a certain time passes. Default to true
}
}
}
Expand Down