Skip to content

Commit

Permalink
fix: Set mapped consent name from server to lowercase (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmi22186 authored Apr 12, 2024
1 parent 4805500 commit 985ef14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ ConsentHandler.prototype.generateConsentStatePayloadFromMappings = function (

for (var i = 0; i <= mappings.length - 1; i++) {
var mappingEntry = mappings[i];
var mpMappedConsentName = mappingEntry.map;
// Although consent purposes can be inputted into the UI in any casing
// the SDK will automatically lowercase them to prevent pseudo-duplicate
// consent purposes, so we call `toLowerCase` on the consentMapping purposes here
var mpMappedConsentName = mappingEntry.map.toLowerCase();
var googleMappedConsentName = mappingEntry.value;

if (
Expand Down
10 changes: 5 additions & 5 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,25 +508,25 @@ describe('DoubleClick', function () {
var consentMap = [
{
jsmap: null,
map: 'some_consent',
map: 'Some_consent',
maptype: 'ConsentPurposes',
value: 'ad_user_data',
},
{
jsmap: null,
map: 'storage_consent',
map: 'Storage_consent',
maptype: 'ConsentPurposes',
value: 'analytics_storage',
},
{
jsmap: null,
map: 'other_test_consent',
map: 'Other_test_consent',
maptype: 'ConsentPurposes',
value: 'ad_storage',
},
{
jsmap: null,
map: 'test_consent',
map: 'Test_consent',
maptype: 'ConsentPurposes',
value: 'ad_personalization',
},
Expand All @@ -541,7 +541,7 @@ describe('DoubleClick', function () {
{
conversionId: 'AW-123123123',
consentMappingWeb:
'[{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;some_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;ad_user_data&quot;},{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;storage_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;analytics_storage&quot;},{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;other_test_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;ad_storage&quot;},{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;test_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;ad_personalization&quot;}]',
'[{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;Some_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;ad_user_data&quot;},{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;Storage_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;analytics_storage&quot;},{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;Other_test_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;ad_storage&quot;},{&quot;jsmap&quot;:null,&quot;map&quot;:&quot;Test_consent&quot;,&quot;maptype&quot;:&quot;ConsentPurposes&quot;,&quot;value&quot;:&quot;ad_personalization&quot;}]',
eventMapping: '[]',
customVariables: '[]',
},
Expand Down

0 comments on commit 985ef14

Please sign in to comment.