Created
December 3, 2024 19:07
-
-
Save johndavidsimmons/fd83f54ce1093496dd3bd80c0b652a34 to your computer and use it in GitHub Desktop.
Adobe Assurance function for finding broken data elements in props and evars
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
function(events, params) { | |
const processedHits = events.filter(e => e.vendor === "com.adobe.analytics.hitdebugger") | |
const allEvarValues = processedHits.map(item => Object.values(item.payload.evars)).flat() | |
const allPropValues = processedHits.map(item => Object.values(item.payload.props)).flat() | |
const dataElementSyntaxRE = '^\%.+\%$' | |
const brokenDataElements = [ | |
...allEvarValues, | |
...allPropValues | |
] | |
.filter(val => val.match(dataElementSyntaxRE)) | |
return { | |
message: brokenDataElements.length ? | |
`Broken Data Element: ${JSON.stringify(brokenDataElements)}` : | |
'No Broken Data Elements!', | |
events: [], | |
links: [], | |
result: brokenDataElements.length ? | |
'not matched' : | |
'matched' | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment