Skip to content

Commit f934cf3

Browse files
committed
feature: update the page view message in app insights
1 parent c76d12b commit f934cf3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/web/astar-dev/src/middleware.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ export const onRequest = defineMiddleware(async (context, next) => {
55
const start = Date.now();
66
const response = await next();
77
const duration = Date.now() - start;
8+
const pageName = context.url.pathname
9+
.replace(/^\/+/, '')
10+
.replace(/\/+/g, '-')
11+
|| 'home';
812

9-
trackTrace('page/view', {
13+
trackTrace(`page-view: ${pageName}`, {
1014
method: context.request.method,
1115
path: context.url.pathname,
1216
status: String(response.status),
1317
durationMs: String(duration),
1418
});
1519

20+
1621
return response;
1722
});

0 commit comments

Comments
 (0)