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

Rubicon Analytics: Convert Key Values to strings #6160

Merged
merged 1 commit into from
Jan 5, 2021
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
8 changes: 6 additions & 2 deletions modules/rubiconAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,12 @@ function getUtmParams() {
function getFpkvs() {
rubiConf.fpkvs = Object.assign((rubiConf.fpkvs || {}), getUtmParams());

const isValid = rubiConf.fpkvs && typeof rubiConf.fpkvs === 'object' && Object.keys(rubiConf.fpkvs).every(key => typeof rubiConf.fpkvs[key] === 'string');
return isValid ? rubiConf.fpkvs : {};
// convert all values to strings
Object.keys(rubiConf.fpkvs).forEach(key => {
rubiConf.fpkvs[key] = rubiConf.fpkvs[key] + '';
});

return rubiConf.fpkvs;
}

let samplingFactor = 1;
Expand Down
28 changes: 28 additions & 0 deletions test/spec/modules/rubiconAnalyticsAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,34 @@ describe('rubicon analytics adapter', function () {
expect(message).to.deep.equal(expectedMessage);
});

it('should convert kvs to strings before sending', function () {
config.setConfig({rubicon: {
fpkvs: {
number: 24,
boolean: false,
string: 'hello',
array: ['one', 2, 'three'],
object: {one: 'two'}
}
}});
performStandardAuction();
expect(server.requests.length).to.equal(1);
let request = server.requests[0];
let message = JSON.parse(request.requestBody);
validate(message);

let expectedMessage = utils.deepClone(ANALYTICS_MESSAGE);
expectedMessage.session.pvid = STUBBED_UUID.slice(0, 8);
expectedMessage.fpkvs = [
{key: 'number', value: '24'},
{key: 'boolean', value: 'false'},
{key: 'string', value: 'hello'},
{key: 'array', value: 'one,2,three'},
{key: 'object', value: '[object Object]'}
]
expect(message).to.deep.equal(expectedMessage);
});

it('should use the query utm param rubicon kv value and pass updated kv and pvid when defined', function () {
sandbox.stub(utils, 'getWindowLocation').returns({'search': '?utm_source=other', 'pbjs_debug': 'true'});

Expand Down