Skip to content

Commit

Permalink
add util function
Browse files Browse the repository at this point in the history
  • Loading branch information
arajguha committed Jul 26, 2021
1 parent fb67c8d commit 73486ab
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions integrations/Mixpanel/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ class Mixpanel {
return !!(window.mixpanel && window.mixpanel.config);
}

convertToArray(arr) {
if (!arr) {
logger.debug("===Mixpanel: arr is undefined or null===");
return;
}
// eslint-disable-next-line consistent-return
return arr.map(item => item.property);
}

/**
* Identify
* @param {*} rudderElement
Expand Down Expand Up @@ -338,9 +347,7 @@ class Mixpanel {
/**
* groupIdentifierTraits: [ {trait: "<trait_value>"}, ... ]
*/
const identifierTraitsList = this.groupIdentifierTraits.map(
(item) => item.trait
);
const identifierTraitsList = this.convertToArray(this.groupIdentifierTraits);
if (traits && Object.keys(traits).length) {
identifierTraitsList.forEach((trait) => {
window.mixpanel.get_group(trait, groupId).set_once(traits);
Expand Down

0 comments on commit 73486ab

Please sign in to comment.