From 3a1b52310eac8491c993474a99811d38a5eff76b Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:43:17 -0700 Subject: [PATCH 1/2] Update logId5Id to save id as an integration attribute --- src/common.js | 14 ++++---------- src/initialization.js | 7 ++++--- test/src/tests.js | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/common.js b/src/common.js index a84a4f2..9101c97 100644 --- a/src/common.js +++ b/src/common.js @@ -6,16 +6,10 @@ Common.prototype.exampleMethod = function () { } Common.prototype.logId5Id = function (id5Id) { - //Checks and saves ID5 ID if it is new - if (id5Id !== this.id5Id) { - this.id5Id = id5Id; - this.id5IdSent = false - } - - //Sets user attribute if ID is unsent. - //This function will be updated once the decryption architecture is finalized. - //TO-DO: Log the ID5 ID to correct location - + var integrationAttributes = {}; + integrationAttributes['encryptedId5Id'] = id5Id; + integrationAttributes['id5IdType'] = this.id5IdType; + window.mParticle.setIntegrationAttributes(this.moduleId, integrationAttributes); }; Common.prototype.buildPartnerData = function (mParticleUser) { diff --git a/src/initialization.js b/src/initialization.js index aedb3fc..c82ed42 100644 --- a/src/initialization.js +++ b/src/initialization.js @@ -11,6 +11,9 @@ var initialization = { */ initForwarder: function(forwarderSettings, testMode, userAttributes, userIdentities, processEvent, eventQueue, isInitialized, common) { /* `forwarderSettings` contains your SDK specific settings such as apiKey that your customer needs in order to initialize your SDK properly */ + common.partnerId = forwarderSettings.partnerId; + common.id5IdType = forwarderSettings.id5IdType; + common.moduleId = this.moduleId; if (!testMode) { /* Load your Web SDK here using a variant of your snippet from your readme that your customers would generally put into their tags @@ -21,9 +24,7 @@ var initialization = { id5Script.src = 'https://cdn.id5-sync.com/api/1.0/id5-api.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(id5Script); - common.id5Id = null; - common.id5IdSent = false; - common.partnerId = forwarderSettings.partnerId; + id5Script.onload = function() { isInitialized = true; diff --git a/test/src/tests.js b/test/src/tests.js index fde1021..cee036d 100644 --- a/test/src/tests.js +++ b/test/src/tests.js @@ -23,7 +23,7 @@ describe('ID5 Forwarder', function () { // -------------------START EDITING BELOW:----------------------- // -------------------mParticle stubs - Add any additional stubbing to our methods as needed----------------------- var userAttributes = {}; - + var integrationAttributes = {}; mParticle.Identity = { getCurrentUser: function() { return { @@ -40,6 +40,11 @@ describe('ID5 Forwarder', function () { }; } }; + + mParticle.setIntegrationAttributes = function(id, attributes) { + integrationAttributes[id] = attributes; + } + // -------------------START EDITING BELOW:----------------------- var MockID5 = function() { var self = this; @@ -86,6 +91,7 @@ describe('ID5 Forwarder', function () { // Include any specific settings that is required for initializing your SDK here var sdkSettings = { partnerId: 1234, + id5IdType: "other_5" }; // The third argument here is a boolean to indicate that the integration is in test mode to avoid loading any third party scripts. Do not change this value. @@ -313,5 +319,13 @@ describe('ID5 Forwarder', function () { validated.should.equal(false); done(); }) + + it ('should log an integration attribute when logId5Id is called', function(done) { + mParticle.forwarder.common.logId5Id("testId"); + var attributes = integrationAttributes[248]; + attributes['encryptedId5Id'].should.equal('testId'); + attributes['id5IdType'].should.equal('other_5') + done(); + }) }) }); From c14245f58f57fb67ac9ac4025c923c303ed4fad5 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:24:39 -0700 Subject: [PATCH 2/2] adjust spacing --- src/initialization.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/initialization.js b/src/initialization.js index c82ed42..8f79565 100644 --- a/src/initialization.js +++ b/src/initialization.js @@ -24,8 +24,6 @@ var initialization = { id5Script.src = 'https://cdn.id5-sync.com/api/1.0/id5-api.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(id5Script); - - id5Script.onload = function() { isInitialized = true;