Skip to content

Instantly share code, notes, and snippets.

@johndavidsimmons
Created December 3, 2024 19:07
Show Gist options
  • Save johndavidsimmons/fd83f54ce1093496dd3bd80c0b652a34 to your computer and use it in GitHub Desktop.
Save johndavidsimmons/fd83f54ce1093496dd3bd80c0b652a34 to your computer and use it in GitHub Desktop.
Adobe Assurance function for finding broken data elements in props and evars
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