As can be seen in this request body, when variables have an undefined value this is cast to a String as the literal word "undefined" by the makeString API.
It would be good to have a check to ensure that undefined remains undefined and is not cast to a String, e.g.:
function parseType (type, value) {
switch (type) {
case 'text':
// Modified line to prevent 'undefined' being
// sent as a String to Intercom:
return value ? makeString(value) : undefined;
case 'number':
return makeNumber(value);
case 'boolean':
case 'bool':
const lowerCaseValue = value.toLowerCase();
return lowerCaseValue === "true" || lowerCaseValue === "yes" || lowerCaseValue === "1";
}
return value;
}
Happy to provide a PR if you like.