Files
speckle-server/packages/frontend-2/plugins/003-healthMetrics.server.ts
T
Kristaps Fabians Geikins dd7409dcb2 feat(fe2): implementing various RUM tools for trialing (#2066)
* basic raygun setup

* testing seq logging

* minor fixes

* more accurate user identification

* logrocket adjustments

* speedcurve seems to work?

* added debugbear

* minor cleanup

* chore(helm chart): adds new web app analytics ids/keys to fe2 env vars
- assumes none are secrets

* Quote all secrets to prevent interpretation as digits

---------

Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
2024-02-22 10:51:13 +02: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'
)
})
})