Created
January 31, 2020 21:58
-
-
Save hitGovernor/3e142f1e910db1e33dc87f182f63660f to your computer and use it in GitHub Desktop.
Checks for specified Ensighten data definition, ensuring only an expected value is returned. The primary benefit is that "data does not exist" messages are not captured in your data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* checks for specified data definition, ensuring only an expected value is returned. | |
* the primary benefit is that "data does not exist" messages are not captured in your data | |
* @param dataDefId {number} data definition id | |
*/ | |
function getDataDef(dataDefId) { | |
// check the list of data definition ids on the current page before attempting to resolve | |
if (Bootstrapper.dataDefinitionIds.indexOf(dataDefId) > -1) { | |
return Bootstrapper.data.resolve(dataDefId); | |
} else { | |
// try the request anyway to let the "failure" get logged in an e.gif request | |
var dataDefValue = Bootstrapper.data.resolve(dataDefId); | |
return !/data\sdefinition.*does\snot\sexist/i.test(dataDefValue) ? dataDefValue : ""; | |
} | |
} | |
console.log(getDataDef(12345)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment