Skip to content

Commit

Permalink
feat(insight): add runtime field of frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorin committed Aug 16, 2023
1 parent bfec4ac commit a5f88c2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion models/insight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ export interface Insight {
requestId: string,
apiResponseTime: string
}
frontend: string,
frontend: {
runtime: string
},
}
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
});

module.exports = withBundleAnalyzer({
serverRuntimeConfig: {
runtime: process.version
},
trailingSlash: true,
sassOptions: {
includePaths: [path.join(__dirname, 'styles')]
Expand Down
7 changes: 6 additions & 1 deletion utils/converters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import getConfig from "next/config";
import { Insight } from "../models/insight";

const { serverRuntimeConfig } = getConfig();

export function asInsight(response: Response): Insight {
const reqId = response.headers.get("x-request-id")
const resTime = response.headers.get("x-response-time")
Expand All @@ -9,7 +12,9 @@ export function asInsight(response: Response): Insight {
requestId: reqId ? reqId : "N/A",
apiResponseTime: resTime ? `${resTime} ms` : "N/A"
},
frontend: "Unavailable"
frontend: {
runtime: serverRuntimeConfig.runtime ? `Node.js ${serverRuntimeConfig.runtime}` : "N/A"
}
} as Insight
}

0 comments on commit a5f88c2

Please sign in to comment.