forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthetics] Measure overview page performance (elastic#191703)
## Summary Measure overview page performance !! also introduced the usePageReady hook in ebt-tooling !! --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
6a25a50
commit b9072e3
Showing
5 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
packages/kbn-ebt-tools/src/performance_metrics/context/use_page_ready.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { CustomMetrics } from './performance_context'; | ||
import { usePerformanceContext } from '../../..'; | ||
|
||
export const usePageReady = (state: { customMetrics?: CustomMetrics; isReady: boolean }) => { | ||
const { onPageReady } = usePerformanceContext(); | ||
|
||
const [isReported, setIsReported] = useState(false); | ||
|
||
useEffect(() => { | ||
if (state.isReady && !isReported) { | ||
onPageReady(state.customMetrics); | ||
setIsReported(true); | ||
} | ||
}, [isReported, onPageReady, state.customMetrics, state.isReady]); | ||
}; |
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
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
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
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