Files
speckle-server/packages/frontend-2/plugins/030-healthMetrics.server.ts
T
Kristaps Fabians Geikins a6a4ceee86 feat: true-myth result structures & other auth policy improvements (#4262)
* fixing up typing

* better dynamic loader mechanism

* buildReqLoaders cleanup

* added caching to loaders

* ensuring all loaders are async

* fe2 plugins error handling fix

* feat(shared): true-myth result structures & other auth policy improvements

* moving workspaceCore loaders to correct place
2025-03-25 17:49:02 +01:00

36 lines
757 B
TypeScript

/**
* Sending SSR request health metrics to the logger
*/
export default defineNuxtPlugin((ctx) => {
const router = useRouter()
const logger = useLogger()
const path = router.currentRoute.value?.matched?.[0]?.path || 'empty'
const name = router.currentRoute.value?.name || 'empty'
const state = {
start: Date.now(),
path: `${String(name)}: ${path}`
}
logger.debug(
{
routeName: name,
routePath: path
},
'{routePath} SSR render started...'
)
ctx.hook('app:rendered', () => {
const endTime = Date.now() - state.start
logger.info(
{
responseTime: endTime,
routeName: name,
routePath: path
},
'{routePath} SSR rendered in {responseTime} ms'
)
})
})