Skip to content

Instantly share code, notes, and snippets.

@johndavidsimmons
Created September 9, 2020 21:50
Show Gist options
  • Select an option

  • Save johndavidsimmons/ed604fdd851e5c7293a604f9f9a83f72 to your computer and use it in GitHub Desktop.

Select an option

Save johndavidsimmons/ed604fdd851e5c7293a604f9f9a83f72 to your computer and use it in GitHub Desktop.
Griffon validation script test lowercase actions
/**
* Returns true, false, or an object { status: false, events: [uuids] }
* @param {Object[]} events All of the events for the session
* @returns {(boolean|Object)} true, false, or an object that contains a status property
* and optionally an events property that is an array of eventUuids
*/
function (events) {
const analyticsTrackEvents = events.filter(event => event.type === 'AnalyticsTrack');
let valid = true;
let invalidEvents = [];
analyticsTrackEvents.forEach(ev => {
let action = ev.payload.ACPExtensionEventData.action;
if (action && action !== action.toLowerCase()) {
invalidEvents.push(ev.uuid);
valid = false;
}
});
return { status: valid, events: invalidEvents };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment