From 6be12bc9a7dfd5d6a3a6a8865fe3131a2e348d98 Mon Sep 17 00:00:00 2001 From: Kostiantyn Horozhanov Date: Wed, 13 Mar 2024 16:46:09 +0100 Subject: [PATCH 1/2] Fix falsy customer identifiers --- template.js | 21 ++++++++++++--------- template.tpl | 21 ++++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/template.js b/template.js index 367e667..3b271ed 100644 --- a/template.js +++ b/template.js @@ -375,7 +375,7 @@ function addUserIdentifiers(eventData, mappedData) { let mobileId; let thirdPartyUserId; let addressInfo; - let userIdentifiersMapped; + let userIdentifiersMapped = []; let userEventData = {}; let usedIdentifiers = []; @@ -388,13 +388,16 @@ function addUserIdentifiers(eventData, mappedData) { let userIdentifiers = []; data.userDataList.forEach((d) => { - let identifier = {}; - - identifier[d.name] = hashData(d.name, d.value); - identifier['userIdentifierSource'] = d.userIdentifierSource; - - userIdentifiers.push(identifier); - usedIdentifiers.push(d.name); + const valueType = getType(d.value); + const isValidValue = ['undefined', 'null'].indexOf(valueType) === -1 && d.value !== ''; + if(isValidValue) { + let identifier = {}; + identifier[d.name] = hashData(d.name, d.value); + identifier['userIdentifierSource'] = d.userIdentifierSource; + + userIdentifiers.push(identifier); + usedIdentifiers.push(d.name); + } }); userIdentifiersMapped = userIdentifiers; @@ -455,7 +458,7 @@ function addUserIdentifiers(eventData, mappedData) { }); } - if (userIdentifiersMapped) { + if (userIdentifiersMapped.length) { mappedData.userIdentifiers = userIdentifiersMapped; } diff --git a/template.tpl b/template.tpl index 1ebe289..f531046 100644 --- a/template.tpl +++ b/template.tpl @@ -954,7 +954,7 @@ function addUserIdentifiers(eventData, mappedData) { let mobileId; let thirdPartyUserId; let addressInfo; - let userIdentifiersMapped; + let userIdentifiersMapped = []; let userEventData = {}; let usedIdentifiers = []; @@ -967,13 +967,16 @@ function addUserIdentifiers(eventData, mappedData) { let userIdentifiers = []; data.userDataList.forEach((d) => { - let identifier = {}; - - identifier[d.name] = hashData(d.name, d.value); - identifier['userIdentifierSource'] = d.userIdentifierSource; - - userIdentifiers.push(identifier); - usedIdentifiers.push(d.name); + const valueType = getType(d.value); + const isValidValue = ['undefined', 'null'].indexOf(valueType) === -1 && d.value !== ''; + if(isValidValue) { + let identifier = {}; + identifier[d.name] = hashData(d.name, d.value); + identifier['userIdentifierSource'] = d.userIdentifierSource; + + userIdentifiers.push(identifier); + usedIdentifiers.push(d.name); + } }); userIdentifiersMapped = userIdentifiers; @@ -1034,7 +1037,7 @@ function addUserIdentifiers(eventData, mappedData) { }); } - if (userIdentifiersMapped) { + if (userIdentifiersMapped.length) { mappedData.userIdentifiers = userIdentifiersMapped; } From 10738b230ae1e7657e69edc849cc3364a30a4a6d Mon Sep 17 00:00:00 2001 From: Kostiantyn Horozhanov Date: Wed, 13 Mar 2024 16:48:02 +0100 Subject: [PATCH 2/2] Meta update --- metadata.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metadata.yaml b/metadata.yaml index 02f0584..9e26ed2 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -1,5 +1,7 @@ homepage: "https://stape.io/" versions: + - sha: 6be12bc9a7dfd5d6a3a6a8865fe3131a2e348d98 + changeNotes: Fix falsy customer identifiers. - sha: 6955b64a199a667d6af5112fd2d4f1e6b4d15b90 changeNotes: Added support for external_attribution_data. - sha: 896519ddfb566753a546dcc7fe4d105155b4ee21