(mark: string)
| 9 | } from './navigationSteps'; |
| 10 | |
| 11 | export const measureSteps = (mark: string) => { |
| 12 | if (steps.finalMarkToStepsMap[mark]) { |
| 13 | recordEndMark(mark); |
| 14 | // this is an end mark so we delete the entry |
| 15 | const finalSteps = steps.finalMarkToStepsMap[mark]; |
| 16 | Object.keys(finalSteps).forEach(startMark => { |
| 17 | const possibleSteps = finalSteps[startMark]; |
| 18 | possibleSteps.forEach(removeActiveStep); |
| 19 | // Async processing all possible steps |
| 20 | // needs to be async due to clearing previously measured steps and marks. |
| 21 | // If we run all concurrently, there is a chance for a race condition |
| 22 | // where we are adding and deleteing the entries in WP.Performance which caused the measure to fail. |
| 23 | Promise.all( |
| 24 | possibleSteps.map(async step => { |
| 25 | // measure |
| 26 | await measureStep(step, startMark, mark); |
| 27 | }), |
| 28 | ).catch(() => { |
| 29 | // TODO @zizzamia log error |
| 30 | }); |
| 31 | }); |
| 32 | } else { |
| 33 | recordStartMark(mark); |
| 34 | addActiveSteps(mark); |
| 35 | } |
| 36 | const navigationBasedActiveSteps = getActiveStepsFromNavigationSteps(); |
| 37 | config.onMarkStep?.(mark, Object.keys(navigationBasedActiveSteps)); |
| 38 | }; |
no test coverage detected