Created
September 9, 2020 21:50
-
-
Save johndavidsimmons/ed604fdd851e5c7293a604f9f9a83f72 to your computer and use it in GitHub Desktop.
Griffon validation script test lowercase actions
This file contains hidden or 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
| /** | |
| * 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