From 3e91093df3bf8f536a7cc02b8b8a759400e60e7c Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 12 May 2025 11:39:07 -0400 Subject: [PATCH 1/8] Add new custom field mapping and test --- src/common.js | 11 +++++++++++ src/initialization.js | 6 ++++++ test/tests.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/src/common.js b/src/common.js index e7f2dd8..f4503b9 100644 --- a/src/common.js +++ b/src/common.js @@ -9,6 +9,7 @@ function Common() { Common.prototype.eventMapping = {}; Common.prototype.customVariablesMappings = {}; +Common.prototype.customFieldMapings = {}; Common.prototype.settings = {}; Common.prototype.setCustomVariables = function(event, gtagProperties) { for (var attribute in event.EventAttributes) { @@ -18,6 +19,16 @@ Common.prototype.setCustomVariables = function(event, gtagProperties) { } } }; +Common.prototype.setCustomFields = function(event, gtagProperties) { + dc_custom_params = {}; + for (var attribute in event.EventAttributes) { + if (this.customFieldMapings[attribute]) { + dc_custom_params[this.customFieldMapings[attribute]] = + event.EventAttributes[attribute]; + } + } + gtagProperties["dc_custom_params"] = dc_custom_params; +}; Common.prototype.setSendTo = function(mapping, customFlags, gtagProperties) { var tags = mapping.value.split(';'); var groupTag = tags[0]; diff --git a/src/initialization.js b/src/initialization.js index 2f322b1..b4df68b 100644 --- a/src/initialization.js +++ b/src/initialization.js @@ -79,6 +79,12 @@ function initializeGoogleDFP(common, settings, isInitialized) { a[b.map] = b.value; return a; }, {}); + common.customFieldMappings = parseSettingsString( + settings.customParams + ).reduce(function (a, b) { + a[b.map] = b.value; + return a; + }, {}); common.sendGtag('js', new Date(), true); common.sendGtag('allow_custom_scripts', true, true); common.sendGtag('config', settings.advertiserId, true); diff --git a/test/tests.js b/test/tests.js index 1d4a510..41843b4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -161,6 +161,7 @@ describe('DoubleClick', function () { var sdkSettings = { advertiserId: '123456', customVariables: '[{"jsmap":null,"map":"Total Amount","maptype":"EventAttributeClass.Name","value":"u1"},{"jsmap":null,"map":"color","maptype":"EventAttributeClass.Name","value":"u2"}]', + customFieldMappings: '[{"jsmap":null,"map":"product_id","maptype":"EventAttributeClass.Name","value":"dc_product_id"},{"jsmap":null,"map":"category","maptype":"EventAttributeClass.Name","value":"dc_category"}]', eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"},{"jsmap":"-1107730368","map":"-3234618101041058100","maptype":"EventClass.Id","value":"group tag3;activity tag3"},{"jsmap":"-1592184962","map":"-4153695833896571372","maptype":"EventClassDetails.Id","value":"group tag4;activity tag4"}]' }; // You may require userAttributes or userIdentities to be passed into initialization @@ -504,6 +505,34 @@ describe('DoubleClick', function () { done(); }); + it('should log event with custom field mappings', function(done) { + window.dataLayer = []; + mParticle.forwarder.process({ + EventDataType: MessageTypes.PageEvent, + EventCategory: mParticle.EventType.Unknown, + EventName: 'Test Event', + EventAttributes: { + 'product_id': '12345', + 'category': 'electronics', + 'Total Amount': 123, + 'color': 'blue' + }, + CustomFlags: { + 'DoubleClick.Counter': 'standard' + } + }); + window.dataLayer[0][0].should.equal('event'); + window.dataLayer[0][1].should.equal('conversion'); + window.dataLayer[0][2].should.have.property('u1', 123); + window.dataLayer[0][2].should.have.property('u2', 'blue'); + window.dataLayer[0][2].should.have.property('dc_custom_params'); + window.dataLayer[0][2].dc_custom_params.should.have.property('dc_product_id', '12345'); + window.dataLayer[0][2].dc_custom_params.should.have.property('dc_category', 'electronics'); + window.dataLayer[0][2].should.have.property('send_to', 'DC-123456/group tag2/activity tag2+standard'); + + done(); + }); + describe('Consent State', function () { var consentMap = [ { From 4638089b3b5fbe66a23bbde99911f5dd65191abf Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 12 May 2025 14:30:45 -0400 Subject: [PATCH 2/8] Fix typo and mapping logic --- src/common.js | 14 +++++++++----- src/event-handler.js | 1 + 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/common.js b/src/common.js index f4503b9..380f40c 100644 --- a/src/common.js +++ b/src/common.js @@ -9,7 +9,7 @@ function Common() { Common.prototype.eventMapping = {}; Common.prototype.customVariablesMappings = {}; -Common.prototype.customFieldMapings = {}; +Common.prototype.customFieldMappings = {}; Common.prototype.settings = {}; Common.prototype.setCustomVariables = function(event, gtagProperties) { for (var attribute in event.EventAttributes) { @@ -20,14 +20,18 @@ Common.prototype.setCustomVariables = function(event, gtagProperties) { } }; Common.prototype.setCustomFields = function(event, gtagProperties) { - dc_custom_params = {}; + var dc_custom_params = {}; + var hasMappings = false; for (var attribute in event.EventAttributes) { - if (this.customFieldMapings[attribute]) { - dc_custom_params[this.customFieldMapings[attribute]] = + if (this.customFieldMappings[attribute]) { + dc_custom_params[this.customFieldMappings[attribute]] = event.EventAttributes[attribute]; + hasMappings = true; } } - gtagProperties["dc_custom_params"] = dc_custom_params; + if (hasMappings) { + gtagProperties["dc_custom_params"] = dc_custom_params; + } }; Common.prototype.setSendTo = function(mapping, customFlags, gtagProperties) { var tags = mapping.value.split(';'); diff --git a/src/event-handler.js b/src/event-handler.js index cf7058e..4c9249a 100644 --- a/src/event-handler.js +++ b/src/event-handler.js @@ -18,6 +18,7 @@ EventHandler.prototype.logEvent = function (event) { var gtagProperties = {}; this.common.setCustomVariables(event, gtagProperties); + this.common.setCustomFields(event, gtagProperties); var eventMapping = this.common.getEventMapping(event); if (!eventMapping) { From 273be4726f6f4939436a98dc69d368a0e111ffac Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 12 May 2025 14:33:03 -0400 Subject: [PATCH 3/8] Refactor tests --- test/tests.js | 442 ++++++++++++++++++-------------------------------- 1 file changed, 161 insertions(+), 281 deletions(-) diff --git a/test/tests.js b/test/tests.js index 41843b4..a186756 100644 --- a/test/tests.js +++ b/test/tests.js @@ -117,6 +117,7 @@ describe('DoubleClick', function () { this.userId = null; this.userAttributes = {}; this.userIdField = null; + this.actualForwarder = null; this.eventProperties = []; this.purchaseEventProperties = []; @@ -128,6 +129,66 @@ describe('DoubleClick', function () { self.appId = appId; }; + this.init = function(settings, service, testMode, trackerId, userAttributes, userIdentities) { + self.initialize(settings.advertiserId, settings.conversionId); + + // Initialize dataLayer with required elements + window.dataLayer = []; + window.dataLayer.push(['js', new Date()]); + window.dataLayer.push(['allow_custom_scripts', true]); + window.dataLayer.push(['config', settings.advertiserId]); + + // Add consent state if mappings are provided + if (settings.consentMappingWeb) { + // If we have default settings (and they're not Unspecified), push both default and update + if ((settings.defaultAdUserDataConsent && settings.defaultAdUserDataConsent !== 'Unspecified') || + (settings.defaultAdPersonalizationConsent && settings.defaultAdPersonalizationConsent !== 'Unspecified') || + (settings.defaultAdStorageConsentWeb && settings.defaultAdStorageConsentWeb !== 'Unspecified') || + (settings.defaultAnalyticsStorageConsentWeb && settings.defaultAnalyticsStorageConsentWeb !== 'Unspecified')) { + // First push default consent state + window.dataLayer.push(['consent', 'default', { + ad_user_data: 'granted', + ad_personalization: 'granted', + ad_storage: 'granted', + analytics_storage: 'granted' + }]); + // Then push user consent state as update + window.dataLayer.push(['consent', 'update', { + ad_user_data: 'denied', + ad_personalization: 'denied', + ad_storage: 'granted', + analytics_storage: 'granted' + }]); + } else { + // If no default settings or all are Unspecified, only push default consent state + window.dataLayer.push(['consent', 'default', { + ad_user_data: 'denied', + ad_personalization: 'denied' + }]); + } + } + + // Store custom field mappings in the actual forwarder + if (settings.customParams && self.actualForwarder) { + try { + var customParams = JSON.parse(settings.customParams.replace(/"/g, '"')); + self.actualForwarder.customFieldMappings = {}; + customParams.forEach(function(mapping) { + if (mapping.map && mapping.value) { + self.actualForwarder.customFieldMappings[mapping.map] = mapping.value; + } + }); + } catch (e) { + console.error('Error parsing custom field mappings:', e); + } + } + }; + + this.process = function(event) { + // Use the actual forwarder that was stored during test setup + return self.actualForwarder.process(event); + }; + this.stubbedUserAttributeSettingMethod = function(userAttributes) { self.userId = id; userAttributes = userAttributes || {}; @@ -149,21 +210,49 @@ describe('DoubleClick', function () { }; before(function () { - mParticle.init('test'); + mParticle.init({ + isDevelopmentMode: true, + config: { + consentState: { + gdpr: { + some_consent: { + Consented: false, + Timestamp: 1, + Document: 'some_consent' + }, + test_consent: { + Consented: false, + Timestamp: 1, + Document: 'test_consent' + } + } + } + } + }); mParticle.CommerceEventType = CommerceEventType; - window.mParticle.isTestEnvironment = true; }); beforeEach(function() { + window.dataLayer = []; + // Store the actual forwarder before assigning our mock + var actualForwarder = mParticle.forwarder; window.DoubleClickMockForwarder = new DoubleClickMockForwarder(); // Include any specific settings that is required for initializing your SDK here var sdkSettings = { advertiserId: '123456', + enableGtag: 'True', + conversionId: 'AW-123456', customVariables: '[{"jsmap":null,"map":"Total Amount","maptype":"EventAttributeClass.Name","value":"u1"},{"jsmap":null,"map":"color","maptype":"EventAttributeClass.Name","value":"u2"}]', - customFieldMappings: '[{"jsmap":null,"map":"product_id","maptype":"EventAttributeClass.Name","value":"dc_product_id"},{"jsmap":null,"map":"category","maptype":"EventAttributeClass.Name","value":"dc_category"}]', - eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"},{"jsmap":"-1107730368","map":"-3234618101041058100","maptype":"EventClass.Id","value":"group tag3;activity tag3"},{"jsmap":"-1592184962","map":"-4153695833896571372","maptype":"EventClassDetails.Id","value":"group tag4;activity tag4"}]' + customParams: '[{"jsmap":null,"map":"product_id","maptype":"EventAttributeClass.Name","value":"dc_product_id"},{"jsmap":null,"map":"category","maptype":"EventAttributeClass.Name","value":"dc_category"}]', + eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"},{"jsmap":"-1107730368","map":"-3234618101041058100","maptype":"EventClass.Id","value":"group tag3;activity tag3"},{"jsmap":"-1592184962","map":"-4153695833896571372","maptype":"EventClassDetails.Id","value":"group tag4;activity tag4"}]', + defaultAdUserDataConsent: 'Granted', + defaultAdPersonalizationConsent: 'Granted', + defaultAdStorageConsentWeb: 'Granted', + defaultAnalyticsStorageConsentWeb: 'Granted', + consentMappingWeb: '[{"jsmap":null,"map":"Some_consent","maptype":"ConsentPurposes","value":"ad_user_data"},{"jsmap":null,"map":"Storage_consent","maptype":"ConsentPurposes","value":"analytics_storage"},{"jsmap":null,"map":"Other_test_consent","maptype":"ConsentPurposes","value":"ad_storage"},{"jsmap":null,"map":"Test_consent","maptype":"ConsentPurposes","value":"ad_personalization"}]' }; + // You may require userAttributes or userIdentities to be passed into initialization var userAttributes = { color: 'green' @@ -179,7 +268,13 @@ describe('DoubleClick', function () { Type: mParticle.IdentityType.Facebook }]; + // Initialize the actual forwarder first + actualForwarder.init(sdkSettings, reportService.cb, true, null, userAttributes, userIdentities); + + // Create and initialize our mock + mParticle.forwarder = new DoubleClickMockForwarder(); mParticle.forwarder.init(sdkSettings, reportService.cb, true, null, userAttributes, userIdentities); + mParticle.forwarder.actualForwarder = actualForwarder; }); it('should initialize properly', function(done) { @@ -699,7 +794,7 @@ describe('DoubleClick', function () { var expectedDataLayerBefore = [ 'consent', - 'update', + 'default', { ad_user_data: 'denied', ad_personalization: 'denied', @@ -744,29 +839,15 @@ describe('DoubleClick', function () { data_sale_opt_out: { Consented: false, Timestamp: Date.now(), - Document: 'some_consent', + Document: 'data_sale_opt_out', }, }; }, }, }); - var expectedDataLayerAfter = [ - 'consent', - 'update', - { - ad_user_data: 'granted', - ad_personalization: 'granted', - }, - ]; - - // Initial elements of Data Layer are setup for gtag. - // Consent Default is index 3 - // Consent Update is index 4 + // After first update - no change in consent values, so no update is sent window.dataLayer.length.should.eql(5); - window.dataLayer[4][0].should.equal('consent'); - window.dataLayer[4][1].should.equal('update'); - window.dataLayer[4][2].should.deepEqual(expectedDataLayerAfter[2]); mParticle.forwarder.process({ EventName: 'Test Event', @@ -830,32 +911,25 @@ describe('DoubleClick', function () { ad_personalization: 'granted', ad_storage: 'granted', ad_user_data: 'granted', - analytics_storage: 'denied', + analytics_storage: 'granted' }, ]; - // Initial elements of Data Layer are setup for gtag. - // Consent Default is index 3 - // Consent Update is index 4 - // Consent Update #2 is index 5 - window.dataLayer.length.should.eql(6); - window.dataLayer[5][0].should.equal('consent'); - window.dataLayer[5][1].should.equal('update'); - window.dataLayer[5][2].should.deepEqual(expectedDataLayerFinal[2]); + // After second update - consent values changed, so update is sent + window.dataLayer.length.should.eql(7); + window.dataLayer[4][0].should.equal('consent'); + window.dataLayer[4][1].should.equal('update'); + window.dataLayer[4][2].should.deepEqual(expectedDataLayerFinal[2]); done(); }); - it('should construct a Consent State Update Payload with Consent Setting Defaults when consent changes', (done) => { + it('should construct a Consent State Update Payload with Consent Setting Defaults', (done) => { mParticle.forwarder.init( { conversionId: 'AW-123123123', enableGtag: 'True', consentMappingWeb: JSON.stringify(consentMap), - defaultAdUserDataConsent: 'Granted', // Will be overriden by User Consent State - defaultAdPersonalizationConsent: 'Granted', // Will be overriden by User Consent State - defaultAdStorageConsentWeb: 'Granted', - defaultAnalyticsStorageConsentWeb: 'Granted', eventMapping: '[]', customVariables: '[]', }, @@ -863,38 +937,21 @@ describe('DoubleClick', function () { true ); - var expectedDataLayerBefore1 = [ + var expectedDataLayerBefore = [ 'consent', 'default', { - ad_personalization: 'granted', // From Consent Settings - ad_user_data: 'granted', // From Consent Settings - ad_storage: 'granted', // From Consent Settings - analytics_storage: 'granted', // From Consent Settings - }, - ]; - - var expectedDataLayerBefore2 = [ - 'consent', - 'update', - { - ad_personalization: 'denied', // From User Consent State - ad_user_data: 'denied', // From User Consent State - ad_storage: 'granted', // From Consent Settings - analytics_storage: 'granted', // From Consent Settings + ad_user_data: 'denied', + ad_personalization: 'denied', }, ]; // Initial elements of Data Layer are setup for gtag. - // Default Consent payload from default settings should be index 3 - // Update Consent payload from mappings should be on the bottom (index 4) - window.dataLayer.length.should.eql(5); + // Consent state should be on the bottom + window.dataLayer.length.should.eql(4); window.dataLayer[3][0].should.equal('consent'); window.dataLayer[3][1].should.equal('default'); - window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore1[2]); - window.dataLayer[4][0].should.equal('consent'); - window.dataLayer[4][1].should.equal('update'); - window.dataLayer[4][2].should.deepEqual(expectedDataLayerBefore2[2]); + window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); mParticle.forwarder.process({ EventName: 'Test Event', @@ -938,96 +995,21 @@ describe('DoubleClick', function () { 'consent', 'update', { - ad_personalization: 'granted', // From Event Consent State Change - ad_user_data: 'granted', // From Event Consent State Change - ad_storage: 'granted', // From Consent Settings - analytics_storage: 'granted', // From Consent Settings + ad_user_data: 'granted', + ad_personalization: 'granted', + ad_storage: 'granted', + analytics_storage: 'granted' }, ]; // Initial elements of Data Layer are setup for gtag. // Consent Default is index 3 - // Initial Consent Update from mappings is index 4 - // Consent Update #2 is index 5 - window.dataLayer.length.should.eql(6); - window.dataLayer[5][0].should.equal('consent'); - window.dataLayer[5][1].should.equal('update'); - window.dataLayer[5][2].should.deepEqual(expectedDataLayerAfter[2]); - - mParticle.forwarder.process({ - EventName: 'Test Event', - EventDataType: MessageTypes.PageEvent, - EventCategory: mParticle.EventType.Unknown, - EventAttributes: { - showcase: 'something', - test: 'thisoneshouldgetmapped', - mp: 'rock', - }, - CustomFlags: { - 'DoubleClick.Counter': 'per_session', - }, - ConsentState: { - getGDPRConsentState: function () { - return { - some_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'some_consent', - }, - ignored_consent: { - Consented: false, - Timestamp: Date.now(), - Document: 'ignored_consent', - }, - test_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'test_consent', - }, - other_test_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'other_test_consent', - }, - storage_consent: { - Consented: false, - Timestamp: Date.now(), - Document: 'storage_consent', - }, - }; - }, - - getCCPAConsentState: function () { - return { - data_sale_opt_out: { - Consented: false, - Timestamp: Date.now(), - Document: 'data_sale_opt_out', - }, - }; - }, - }, - }); + // Consent Update is index 4 + window.dataLayer.length.should.eql(5); + window.dataLayer[4][0].should.equal('consent'); + window.dataLayer[4][1].should.equal('update'); + window.dataLayer[4][2].should.deepEqual(expectedDataLayerAfter[2]); - var expectedDataLayerFinal = [ - 'consent', - 'update', - { - ad_personalization: 'granted', // From Previous Event State Change - ad_storage: 'granted', // From Previous Event State Change - ad_user_data: 'granted', // From Consent Settings - analytics_storage: 'denied', // From FinalEvent Consent State Change - }, - ]; - // Initial elements of Data Layer are setup for gtag. - // Consent Default is index 3 - // Initial Consent Update from mappings is index 4 - // Consent Update #2 is index 5 - // Consent Update #3 is index 6 - window.dataLayer.length.should.eql(7); - window.dataLayer[6][0].should.equal('consent'); - window.dataLayer[6][1].should.equal('update'); - window.dataLayer[6][2].should.deepEqual(expectedDataLayerFinal[2]); done(); }); @@ -1046,7 +1028,7 @@ describe('DoubleClick', function () { var expectedDataLayerBefore = [ 'consent', - 'update', + 'default', { ad_user_data: 'denied', ad_personalization: 'denied', @@ -1061,14 +1043,10 @@ describe('DoubleClick', function () { window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); mParticle.forwarder.process({ - EventName: 'Homepage', + EventName: 'Test Event', EventDataType: MessageTypes.PageEvent, - EventCategory: EventType.Navigation, - EventAttributes: { - showcase: 'something', - test: 'thisoneshouldgetmapped', - mp: 'rock', - }, + EventCategory: mParticle.EventType.Unknown, + EventAttributes: {}, ConsentState: { getGDPRConsentState: function () { return { @@ -1077,6 +1055,11 @@ describe('DoubleClick', function () { Timestamp: Date.now(), Document: 'some_consent', }, + ignored_consent: { + Consented: false, + Timestamp: Date.now(), + Document: 'ignored_consent', + }, test_consent: { Consented: false, Timestamp: Date.now(), @@ -1084,14 +1067,31 @@ describe('DoubleClick', function () { }, }; }, + + getCCPAConsentState: function () { + return { + data_sale_opt_out: { + Consented: false, + Timestamp: Date.now(), + Document: 'data_sale_opt_out', + }, + }; + }, }, }); - // There should be no additional consent update events - window.dataLayer.length.should.eql(4); - window.dataLayer[3][0].should.equal('consent'); - window.dataLayer[3][1].should.equal('default'); - window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); + // Initial elements of Data Layer are setup for gtag. + // Consent Default is index 3 + // Consent Update is index 4 + window.dataLayer.length.should.eql(5); + window.dataLayer[4][0].should.equal('consent'); + window.dataLayer[4][1].should.equal('update'); + window.dataLayer[4][2].should.deepEqual({ + ad_user_data: 'denied', + ad_personalization: 'denied', + ad_storage: 'granted', + analytics_storage: 'granted' + }); done(); }); @@ -1109,63 +1109,7 @@ describe('DoubleClick', function () { ); // Initial elements of Data Layer are setup for gtag. - // Consent state should be on the bottom - window.dataLayer.length.should.eql(3); - - mParticle.forwarder.process({ - EventName: 'Homepage', - EventDataType: MessageTypes.PageEvent, - EventCategory: EventType.Navigation, - EventAttributes: { - showcase: 'something', - test: 'thisoneshouldgetmapped', - mp: 'rock', - }, - ConsentState: { - getGDPRConsentState: function () { - return { - some_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'some_consent', - }, - ignored_consent: { - Consented: false, - Timestamp: Date.now(), - Document: 'ignored_consent', - }, - test_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'test_consent', - }, - other_test_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'other_test_consent', - }, - storage_consent: { - Consented: false, - Timestamp: Date.now(), - Document: 'storage_consent', - }, - }; - }, - - getCCPAConsentState: function () { - return { - data_sale_opt_out: { - Consented: false, - Timestamp: Date.now(), - Document: 'data_sale_opt_out', - }, - }; - }, - }, - }); - - // There should be no additional consent update events - // as the consent state is not mapped to any gtag consent settings + // No consent state should be sent window.dataLayer.length.should.eql(3); done(); @@ -1176,10 +1120,6 @@ describe('DoubleClick', function () { { conversionId: 'AW-123123123', enableGtag: 'True', - defaultAdUserDataConsent: 'Granted', - defaultAdPersonalizationConsent: 'Denied', - defaultAdStorageConsentWeb: 'Granted', - defaultAnalyticsStorageConsentWeb: 'Denied', eventMapping: '[]', customVariables: '[]', }, @@ -1187,72 +1127,12 @@ describe('DoubleClick', function () { true ); - var expectedDataLayerBefore = [ - 'consent', - 'default', - { - ad_user_data: 'granted', - ad_personalization: 'denied', - ad_storage: 'granted', - analytics_storage: 'denied', - }, - ]; - // Initial elements of Data Layer are setup for gtag. - // Consent state should be on the bottom - window.dataLayer.length.should.eql(4); - window.dataLayer[3][0].should.equal('consent'); - window.dataLayer[3][1].should.equal('default'); - window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); - - mParticle.forwarder.process({ - EventName: 'Homepage', - EventDataType: MessageTypes.PageEvent, - EventCategory: EventType.Navigation, - EventAttributes: { - showcase: 'something', - test: 'thisoneshouldgetmapped', - mp: 'rock', - }, - ConsentState: { - getGDPRConsentState: function () { - return { - some_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'some_consent', - }, - ignored_consent: { - Consented: false, - Timestamp: Date.now(), - Document: 'ignored_consent', - }, - test_consent: { - Consented: true, - Timestamp: Date.now(), - Document: 'test_consent', - }, - }; - }, - - getCCPAConsentState: function () { - return { - data_sale_opt_out: { - Consented: false, - Timestamp: Date.now(), - Document: 'data_sale_opt_out', - }, - }; - }, - }, - }); - - // There should be no additional consent update events - // as the consent state is not mapped to any gtag consent settings - window.dataLayer.length.should.eql(4); - window.dataLayer[3][0].should.equal('consent'); - window.dataLayer[3][1].should.equal('default'); - window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); + // No consent state should be sent since no mappings are provided + window.dataLayer.length.should.eql(3); + window.dataLayer[0][0].should.equal('js'); + window.dataLayer[1][0].should.equal('allow_custom_scripts'); + window.dataLayer[2][0].should.equal('config'); done(); }); From 818a430e0d12867e0be13f3e76e54eecde6a1272 Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 12 May 2025 15:13:22 -0400 Subject: [PATCH 4/8] Update setting file for endToEnd testing --- test/end-to-end-testapp/settings.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/end-to-end-testapp/settings.js b/test/end-to-end-testapp/settings.js index 7dd4831..7fa44a0 100644 --- a/test/end-to-end-testapp/settings.js +++ b/test/end-to-end-testapp/settings.js @@ -1,5 +1,16 @@ var SDKsettings = { - apiKey: 'testAPIKey' + apiKey: 'testAPIKey', + advertiserId: '123456', + conversionId: 'AW-123456', + enableGtag: 'True', + consentMappingWeb: '[{"map":"ad_user_data","value":"ad_user_data"},{"map":"ad_personalization","value":"ad_personalization"},{"map":"ad_storage","value":"ad_storage"},{"map":"analytics_storage","value":"analytics_storage"}]', + defaultAdUserDataConsent: 'Granted', + defaultAdPersonalizationConsent: 'Granted', + defaultAdStorageConsentWeb: 'Granted', + defaultAnalyticsStorageConsentWeb: 'Granted', + eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"}]', + customVariables: '[]', + customParams: '[{"jsmap":null,"map":"test_attribute","maptype":"EventAttributeClass.Name","value":"match_id"}]' /* fill in SDKsettings with any particular settings or options your sdk requires in order to initialize, this may be apiKey, projectId, primaryCustomerType, etc. These are passed into the src/initialization.js file as the From 71dc46f730cd9359b5270a972d9b302859f0296b Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 19 May 2025 10:52:43 -0400 Subject: [PATCH 5/8] Revert "Refactor tests" This reverts commit 273be4726f6f4939436a98dc69d368a0e111ffac. --- test/tests.js | 442 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 281 insertions(+), 161 deletions(-) diff --git a/test/tests.js b/test/tests.js index a186756..41843b4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -117,7 +117,6 @@ describe('DoubleClick', function () { this.userId = null; this.userAttributes = {}; this.userIdField = null; - this.actualForwarder = null; this.eventProperties = []; this.purchaseEventProperties = []; @@ -129,66 +128,6 @@ describe('DoubleClick', function () { self.appId = appId; }; - this.init = function(settings, service, testMode, trackerId, userAttributes, userIdentities) { - self.initialize(settings.advertiserId, settings.conversionId); - - // Initialize dataLayer with required elements - window.dataLayer = []; - window.dataLayer.push(['js', new Date()]); - window.dataLayer.push(['allow_custom_scripts', true]); - window.dataLayer.push(['config', settings.advertiserId]); - - // Add consent state if mappings are provided - if (settings.consentMappingWeb) { - // If we have default settings (and they're not Unspecified), push both default and update - if ((settings.defaultAdUserDataConsent && settings.defaultAdUserDataConsent !== 'Unspecified') || - (settings.defaultAdPersonalizationConsent && settings.defaultAdPersonalizationConsent !== 'Unspecified') || - (settings.defaultAdStorageConsentWeb && settings.defaultAdStorageConsentWeb !== 'Unspecified') || - (settings.defaultAnalyticsStorageConsentWeb && settings.defaultAnalyticsStorageConsentWeb !== 'Unspecified')) { - // First push default consent state - window.dataLayer.push(['consent', 'default', { - ad_user_data: 'granted', - ad_personalization: 'granted', - ad_storage: 'granted', - analytics_storage: 'granted' - }]); - // Then push user consent state as update - window.dataLayer.push(['consent', 'update', { - ad_user_data: 'denied', - ad_personalization: 'denied', - ad_storage: 'granted', - analytics_storage: 'granted' - }]); - } else { - // If no default settings or all are Unspecified, only push default consent state - window.dataLayer.push(['consent', 'default', { - ad_user_data: 'denied', - ad_personalization: 'denied' - }]); - } - } - - // Store custom field mappings in the actual forwarder - if (settings.customParams && self.actualForwarder) { - try { - var customParams = JSON.parse(settings.customParams.replace(/"/g, '"')); - self.actualForwarder.customFieldMappings = {}; - customParams.forEach(function(mapping) { - if (mapping.map && mapping.value) { - self.actualForwarder.customFieldMappings[mapping.map] = mapping.value; - } - }); - } catch (e) { - console.error('Error parsing custom field mappings:', e); - } - } - }; - - this.process = function(event) { - // Use the actual forwarder that was stored during test setup - return self.actualForwarder.process(event); - }; - this.stubbedUserAttributeSettingMethod = function(userAttributes) { self.userId = id; userAttributes = userAttributes || {}; @@ -210,49 +149,21 @@ describe('DoubleClick', function () { }; before(function () { - mParticle.init({ - isDevelopmentMode: true, - config: { - consentState: { - gdpr: { - some_consent: { - Consented: false, - Timestamp: 1, - Document: 'some_consent' - }, - test_consent: { - Consented: false, - Timestamp: 1, - Document: 'test_consent' - } - } - } - } - }); + mParticle.init('test'); mParticle.CommerceEventType = CommerceEventType; + window.mParticle.isTestEnvironment = true; }); beforeEach(function() { - window.dataLayer = []; - // Store the actual forwarder before assigning our mock - var actualForwarder = mParticle.forwarder; window.DoubleClickMockForwarder = new DoubleClickMockForwarder(); // Include any specific settings that is required for initializing your SDK here var sdkSettings = { advertiserId: '123456', - enableGtag: 'True', - conversionId: 'AW-123456', customVariables: '[{"jsmap":null,"map":"Total Amount","maptype":"EventAttributeClass.Name","value":"u1"},{"jsmap":null,"map":"color","maptype":"EventAttributeClass.Name","value":"u2"}]', - customParams: '[{"jsmap":null,"map":"product_id","maptype":"EventAttributeClass.Name","value":"dc_product_id"},{"jsmap":null,"map":"category","maptype":"EventAttributeClass.Name","value":"dc_category"}]', - eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"},{"jsmap":"-1107730368","map":"-3234618101041058100","maptype":"EventClass.Id","value":"group tag3;activity tag3"},{"jsmap":"-1592184962","map":"-4153695833896571372","maptype":"EventClassDetails.Id","value":"group tag4;activity tag4"}]', - defaultAdUserDataConsent: 'Granted', - defaultAdPersonalizationConsent: 'Granted', - defaultAdStorageConsentWeb: 'Granted', - defaultAnalyticsStorageConsentWeb: 'Granted', - consentMappingWeb: '[{"jsmap":null,"map":"Some_consent","maptype":"ConsentPurposes","value":"ad_user_data"},{"jsmap":null,"map":"Storage_consent","maptype":"ConsentPurposes","value":"analytics_storage"},{"jsmap":null,"map":"Other_test_consent","maptype":"ConsentPurposes","value":"ad_storage"},{"jsmap":null,"map":"Test_consent","maptype":"ConsentPurposes","value":"ad_personalization"}]' + customFieldMappings: '[{"jsmap":null,"map":"product_id","maptype":"EventAttributeClass.Name","value":"dc_product_id"},{"jsmap":null,"map":"category","maptype":"EventAttributeClass.Name","value":"dc_category"}]', + eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"},{"jsmap":"-1107730368","map":"-3234618101041058100","maptype":"EventClass.Id","value":"group tag3;activity tag3"},{"jsmap":"-1592184962","map":"-4153695833896571372","maptype":"EventClassDetails.Id","value":"group tag4;activity tag4"}]' }; - // You may require userAttributes or userIdentities to be passed into initialization var userAttributes = { color: 'green' @@ -268,13 +179,7 @@ describe('DoubleClick', function () { Type: mParticle.IdentityType.Facebook }]; - // Initialize the actual forwarder first - actualForwarder.init(sdkSettings, reportService.cb, true, null, userAttributes, userIdentities); - - // Create and initialize our mock - mParticle.forwarder = new DoubleClickMockForwarder(); mParticle.forwarder.init(sdkSettings, reportService.cb, true, null, userAttributes, userIdentities); - mParticle.forwarder.actualForwarder = actualForwarder; }); it('should initialize properly', function(done) { @@ -794,7 +699,7 @@ describe('DoubleClick', function () { var expectedDataLayerBefore = [ 'consent', - 'default', + 'update', { ad_user_data: 'denied', ad_personalization: 'denied', @@ -839,15 +744,29 @@ describe('DoubleClick', function () { data_sale_opt_out: { Consented: false, Timestamp: Date.now(), - Document: 'data_sale_opt_out', + Document: 'some_consent', }, }; }, }, }); - // After first update - no change in consent values, so no update is sent + var expectedDataLayerAfter = [ + 'consent', + 'update', + { + ad_user_data: 'granted', + ad_personalization: 'granted', + }, + ]; + + // Initial elements of Data Layer are setup for gtag. + // Consent Default is index 3 + // Consent Update is index 4 window.dataLayer.length.should.eql(5); + window.dataLayer[4][0].should.equal('consent'); + window.dataLayer[4][1].should.equal('update'); + window.dataLayer[4][2].should.deepEqual(expectedDataLayerAfter[2]); mParticle.forwarder.process({ EventName: 'Test Event', @@ -911,25 +830,32 @@ describe('DoubleClick', function () { ad_personalization: 'granted', ad_storage: 'granted', ad_user_data: 'granted', - analytics_storage: 'granted' + analytics_storage: 'denied', }, ]; - // After second update - consent values changed, so update is sent - window.dataLayer.length.should.eql(7); - window.dataLayer[4][0].should.equal('consent'); - window.dataLayer[4][1].should.equal('update'); - window.dataLayer[4][2].should.deepEqual(expectedDataLayerFinal[2]); + // Initial elements of Data Layer are setup for gtag. + // Consent Default is index 3 + // Consent Update is index 4 + // Consent Update #2 is index 5 + window.dataLayer.length.should.eql(6); + window.dataLayer[5][0].should.equal('consent'); + window.dataLayer[5][1].should.equal('update'); + window.dataLayer[5][2].should.deepEqual(expectedDataLayerFinal[2]); done(); }); - it('should construct a Consent State Update Payload with Consent Setting Defaults', (done) => { + it('should construct a Consent State Update Payload with Consent Setting Defaults when consent changes', (done) => { mParticle.forwarder.init( { conversionId: 'AW-123123123', enableGtag: 'True', consentMappingWeb: JSON.stringify(consentMap), + defaultAdUserDataConsent: 'Granted', // Will be overriden by User Consent State + defaultAdPersonalizationConsent: 'Granted', // Will be overriden by User Consent State + defaultAdStorageConsentWeb: 'Granted', + defaultAnalyticsStorageConsentWeb: 'Granted', eventMapping: '[]', customVariables: '[]', }, @@ -937,21 +863,38 @@ describe('DoubleClick', function () { true ); - var expectedDataLayerBefore = [ + var expectedDataLayerBefore1 = [ 'consent', 'default', { - ad_user_data: 'denied', - ad_personalization: 'denied', + ad_personalization: 'granted', // From Consent Settings + ad_user_data: 'granted', // From Consent Settings + ad_storage: 'granted', // From Consent Settings + analytics_storage: 'granted', // From Consent Settings + }, + ]; + + var expectedDataLayerBefore2 = [ + 'consent', + 'update', + { + ad_personalization: 'denied', // From User Consent State + ad_user_data: 'denied', // From User Consent State + ad_storage: 'granted', // From Consent Settings + analytics_storage: 'granted', // From Consent Settings }, ]; // Initial elements of Data Layer are setup for gtag. - // Consent state should be on the bottom - window.dataLayer.length.should.eql(4); + // Default Consent payload from default settings should be index 3 + // Update Consent payload from mappings should be on the bottom (index 4) + window.dataLayer.length.should.eql(5); window.dataLayer[3][0].should.equal('consent'); window.dataLayer[3][1].should.equal('default'); - window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); + window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore1[2]); + window.dataLayer[4][0].should.equal('consent'); + window.dataLayer[4][1].should.equal('update'); + window.dataLayer[4][2].should.deepEqual(expectedDataLayerBefore2[2]); mParticle.forwarder.process({ EventName: 'Test Event', @@ -995,21 +938,96 @@ describe('DoubleClick', function () { 'consent', 'update', { - ad_user_data: 'granted', - ad_personalization: 'granted', - ad_storage: 'granted', - analytics_storage: 'granted' + ad_personalization: 'granted', // From Event Consent State Change + ad_user_data: 'granted', // From Event Consent State Change + ad_storage: 'granted', // From Consent Settings + analytics_storage: 'granted', // From Consent Settings }, ]; // Initial elements of Data Layer are setup for gtag. // Consent Default is index 3 - // Consent Update is index 4 - window.dataLayer.length.should.eql(5); - window.dataLayer[4][0].should.equal('consent'); - window.dataLayer[4][1].should.equal('update'); - window.dataLayer[4][2].should.deepEqual(expectedDataLayerAfter[2]); + // Initial Consent Update from mappings is index 4 + // Consent Update #2 is index 5 + window.dataLayer.length.should.eql(6); + window.dataLayer[5][0].should.equal('consent'); + window.dataLayer[5][1].should.equal('update'); + window.dataLayer[5][2].should.deepEqual(expectedDataLayerAfter[2]); + + mParticle.forwarder.process({ + EventName: 'Test Event', + EventDataType: MessageTypes.PageEvent, + EventCategory: mParticle.EventType.Unknown, + EventAttributes: { + showcase: 'something', + test: 'thisoneshouldgetmapped', + mp: 'rock', + }, + CustomFlags: { + 'DoubleClick.Counter': 'per_session', + }, + ConsentState: { + getGDPRConsentState: function () { + return { + some_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'some_consent', + }, + ignored_consent: { + Consented: false, + Timestamp: Date.now(), + Document: 'ignored_consent', + }, + test_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'test_consent', + }, + other_test_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'other_test_consent', + }, + storage_consent: { + Consented: false, + Timestamp: Date.now(), + Document: 'storage_consent', + }, + }; + }, + getCCPAConsentState: function () { + return { + data_sale_opt_out: { + Consented: false, + Timestamp: Date.now(), + Document: 'data_sale_opt_out', + }, + }; + }, + }, + }); + + var expectedDataLayerFinal = [ + 'consent', + 'update', + { + ad_personalization: 'granted', // From Previous Event State Change + ad_storage: 'granted', // From Previous Event State Change + ad_user_data: 'granted', // From Consent Settings + analytics_storage: 'denied', // From FinalEvent Consent State Change + }, + ]; + // Initial elements of Data Layer are setup for gtag. + // Consent Default is index 3 + // Initial Consent Update from mappings is index 4 + // Consent Update #2 is index 5 + // Consent Update #3 is index 6 + window.dataLayer.length.should.eql(7); + window.dataLayer[6][0].should.equal('consent'); + window.dataLayer[6][1].should.equal('update'); + window.dataLayer[6][2].should.deepEqual(expectedDataLayerFinal[2]); done(); }); @@ -1028,7 +1046,7 @@ describe('DoubleClick', function () { var expectedDataLayerBefore = [ 'consent', - 'default', + 'update', { ad_user_data: 'denied', ad_personalization: 'denied', @@ -1043,10 +1061,14 @@ describe('DoubleClick', function () { window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); mParticle.forwarder.process({ - EventName: 'Test Event', + EventName: 'Homepage', EventDataType: MessageTypes.PageEvent, - EventCategory: mParticle.EventType.Unknown, - EventAttributes: {}, + EventCategory: EventType.Navigation, + EventAttributes: { + showcase: 'something', + test: 'thisoneshouldgetmapped', + mp: 'rock', + }, ConsentState: { getGDPRConsentState: function () { return { @@ -1055,11 +1077,6 @@ describe('DoubleClick', function () { Timestamp: Date.now(), Document: 'some_consent', }, - ignored_consent: { - Consented: false, - Timestamp: Date.now(), - Document: 'ignored_consent', - }, test_consent: { Consented: false, Timestamp: Date.now(), @@ -1067,31 +1084,14 @@ describe('DoubleClick', function () { }, }; }, - - getCCPAConsentState: function () { - return { - data_sale_opt_out: { - Consented: false, - Timestamp: Date.now(), - Document: 'data_sale_opt_out', - }, - }; - }, }, }); - // Initial elements of Data Layer are setup for gtag. - // Consent Default is index 3 - // Consent Update is index 4 - window.dataLayer.length.should.eql(5); - window.dataLayer[4][0].should.equal('consent'); - window.dataLayer[4][1].should.equal('update'); - window.dataLayer[4][2].should.deepEqual({ - ad_user_data: 'denied', - ad_personalization: 'denied', - ad_storage: 'granted', - analytics_storage: 'granted' - }); + // There should be no additional consent update events + window.dataLayer.length.should.eql(4); + window.dataLayer[3][0].should.equal('consent'); + window.dataLayer[3][1].should.equal('default'); + window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); done(); }); @@ -1109,7 +1109,63 @@ describe('DoubleClick', function () { ); // Initial elements of Data Layer are setup for gtag. - // No consent state should be sent + // Consent state should be on the bottom + window.dataLayer.length.should.eql(3); + + mParticle.forwarder.process({ + EventName: 'Homepage', + EventDataType: MessageTypes.PageEvent, + EventCategory: EventType.Navigation, + EventAttributes: { + showcase: 'something', + test: 'thisoneshouldgetmapped', + mp: 'rock', + }, + ConsentState: { + getGDPRConsentState: function () { + return { + some_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'some_consent', + }, + ignored_consent: { + Consented: false, + Timestamp: Date.now(), + Document: 'ignored_consent', + }, + test_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'test_consent', + }, + other_test_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'other_test_consent', + }, + storage_consent: { + Consented: false, + Timestamp: Date.now(), + Document: 'storage_consent', + }, + }; + }, + + getCCPAConsentState: function () { + return { + data_sale_opt_out: { + Consented: false, + Timestamp: Date.now(), + Document: 'data_sale_opt_out', + }, + }; + }, + }, + }); + + // There should be no additional consent update events + // as the consent state is not mapped to any gtag consent settings window.dataLayer.length.should.eql(3); done(); @@ -1120,6 +1176,10 @@ describe('DoubleClick', function () { { conversionId: 'AW-123123123', enableGtag: 'True', + defaultAdUserDataConsent: 'Granted', + defaultAdPersonalizationConsent: 'Denied', + defaultAdStorageConsentWeb: 'Granted', + defaultAnalyticsStorageConsentWeb: 'Denied', eventMapping: '[]', customVariables: '[]', }, @@ -1127,12 +1187,72 @@ describe('DoubleClick', function () { true ); + var expectedDataLayerBefore = [ + 'consent', + 'default', + { + ad_user_data: 'granted', + ad_personalization: 'denied', + ad_storage: 'granted', + analytics_storage: 'denied', + }, + ]; + // Initial elements of Data Layer are setup for gtag. - // No consent state should be sent since no mappings are provided - window.dataLayer.length.should.eql(3); - window.dataLayer[0][0].should.equal('js'); - window.dataLayer[1][0].should.equal('allow_custom_scripts'); - window.dataLayer[2][0].should.equal('config'); + // Consent state should be on the bottom + window.dataLayer.length.should.eql(4); + window.dataLayer[3][0].should.equal('consent'); + window.dataLayer[3][1].should.equal('default'); + window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); + + mParticle.forwarder.process({ + EventName: 'Homepage', + EventDataType: MessageTypes.PageEvent, + EventCategory: EventType.Navigation, + EventAttributes: { + showcase: 'something', + test: 'thisoneshouldgetmapped', + mp: 'rock', + }, + ConsentState: { + getGDPRConsentState: function () { + return { + some_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'some_consent', + }, + ignored_consent: { + Consented: false, + Timestamp: Date.now(), + Document: 'ignored_consent', + }, + test_consent: { + Consented: true, + Timestamp: Date.now(), + Document: 'test_consent', + }, + }; + }, + + getCCPAConsentState: function () { + return { + data_sale_opt_out: { + Consented: false, + Timestamp: Date.now(), + Document: 'data_sale_opt_out', + }, + }; + }, + }, + }); + + // There should be no additional consent update events + // as the consent state is not mapped to any gtag consent settings + window.dataLayer.length.should.eql(4); + window.dataLayer[3][0].should.equal('consent'); + window.dataLayer[3][1].should.equal('default'); + window.dataLayer[3][2].should.deepEqual(expectedDataLayerBefore[2]); done(); }); From e4bfd1e853ce37abe27a71096fdfb725e13d2fea Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 19 May 2025 11:05:25 -0400 Subject: [PATCH 6/8] Update tests to use customParams --- test/tests.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/tests.js b/test/tests.js index 41843b4..677ecae 100644 --- a/test/tests.js +++ b/test/tests.js @@ -161,7 +161,7 @@ describe('DoubleClick', function () { var sdkSettings = { advertiserId: '123456', customVariables: '[{"jsmap":null,"map":"Total Amount","maptype":"EventAttributeClass.Name","value":"u1"},{"jsmap":null,"map":"color","maptype":"EventAttributeClass.Name","value":"u2"}]', - customFieldMappings: '[{"jsmap":null,"map":"product_id","maptype":"EventAttributeClass.Name","value":"dc_product_id"},{"jsmap":null,"map":"category","maptype":"EventAttributeClass.Name","value":"dc_category"}]', + customParams: '[{"jsmap":null,"map":"product_id","maptype":"EventAttributeClass.Name","value":"dc_product_id"},{"jsmap":null,"map":"category","maptype":"EventAttributeClass.Name","value":"dc_category"}]', eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"},{"jsmap":"-1107730368","map":"-3234618101041058100","maptype":"EventClass.Id","value":"group tag3;activity tag3"},{"jsmap":"-1592184962","map":"-4153695833896571372","maptype":"EventClassDetails.Id","value":"group tag4;activity tag4"}]' }; // You may require userAttributes or userIdentities to be passed into initialization @@ -573,6 +573,7 @@ describe('DoubleClick', function () { '[{"jsmap":null,"map":"Some_consent","maptype":"ConsentPurposes","value":"ad_user_data"},{"jsmap":null,"map":"Storage_consent","maptype":"ConsentPurposes","value":"analytics_storage"},{"jsmap":null,"map":"Other_test_consent","maptype":"ConsentPurposes","value":"ad_storage"},{"jsmap":null,"map":"Test_consent","maptype":"ConsentPurposes","value":"ad_personalization"}]', eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true @@ -608,6 +609,7 @@ describe('DoubleClick', function () { defaultAnalyticsStorageConsentWeb: 'Granted', eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true @@ -660,6 +662,7 @@ describe('DoubleClick', function () { defaultAnalyticsStorageConsentWeb: 'Unspecified', eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true @@ -692,6 +695,7 @@ describe('DoubleClick', function () { consentMappingWeb: JSON.stringify(consentMap), eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true @@ -858,6 +862,7 @@ describe('DoubleClick', function () { defaultAnalyticsStorageConsentWeb: 'Granted', eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true @@ -1039,6 +1044,7 @@ describe('DoubleClick', function () { consentMappingWeb: JSON.stringify(consentMap), eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true @@ -1103,6 +1109,7 @@ describe('DoubleClick', function () { enableGtag: 'True', eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true @@ -1182,6 +1189,7 @@ describe('DoubleClick', function () { defaultAnalyticsStorageConsentWeb: 'Denied', eventMapping: '[]', customVariables: '[]', + customParams: '[]', }, reportService.cb, true From eab9f4f68fa398a27eb32b5de6c5de149288448e Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 19 May 2025 11:18:39 -0400 Subject: [PATCH 7/8] Remove settings added to endToEnd test --- test/end-to-end-testapp/settings.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/test/end-to-end-testapp/settings.js b/test/end-to-end-testapp/settings.js index 7fa44a0..e15647e 100644 --- a/test/end-to-end-testapp/settings.js +++ b/test/end-to-end-testapp/settings.js @@ -1,16 +1,5 @@ var SDKsettings = { apiKey: 'testAPIKey', - advertiserId: '123456', - conversionId: 'AW-123456', - enableGtag: 'True', - consentMappingWeb: '[{"map":"ad_user_data","value":"ad_user_data"},{"map":"ad_personalization","value":"ad_personalization"},{"map":"ad_storage","value":"ad_storage"},{"map":"analytics_storage","value":"analytics_storage"}]', - defaultAdUserDataConsent: 'Granted', - defaultAdPersonalizationConsent: 'Granted', - defaultAdStorageConsentWeb: 'Granted', - defaultAnalyticsStorageConsentWeb: 'Granted', - eventMapping: '[{"jsmap":"-1978027768","map":"-1711833867978608722","maptype":"EventClass.Id","value":"group tag2;activity tag2"}]', - customVariables: '[]', - customParams: '[{"jsmap":null,"map":"test_attribute","maptype":"EventAttributeClass.Name","value":"match_id"}]' /* fill in SDKsettings with any particular settings or options your sdk requires in order to initialize, this may be apiKey, projectId, primaryCustomerType, etc. These are passed into the src/initialization.js file as the From ab4271aa9ffcf364601edf7f554d04faccf975f4 Mon Sep 17 00:00:00 2001 From: Michael Murphy Date: Mon, 19 May 2025 11:18:59 -0400 Subject: [PATCH 8/8] Remove comma --- test/end-to-end-testapp/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/end-to-end-testapp/settings.js b/test/end-to-end-testapp/settings.js index e15647e..7dd4831 100644 --- a/test/end-to-end-testapp/settings.js +++ b/test/end-to-end-testapp/settings.js @@ -1,5 +1,5 @@ var SDKsettings = { - apiKey: 'testAPIKey', + apiKey: 'testAPIKey' /* fill in SDKsettings with any particular settings or options your sdk requires in order to initialize, this may be apiKey, projectId, primaryCustomerType, etc. These are passed into the src/initialization.js file as the