@jaypie/express 1.2.22 → 1.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +21 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +21 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2022,19 +2022,37 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
2022
2022
|
res: summarizeResponse(res, extras),
|
|
2023
2023
|
});
|
|
2024
2024
|
// Construct normalized path for reporting and metrics
|
|
2025
|
-
let
|
|
2026
|
-
if (!
|
|
2027
|
-
|
|
2025
|
+
let pathWithQuery = (req.baseUrl || "") + (req.url || "");
|
|
2026
|
+
if (!pathWithQuery.startsWith("/")) {
|
|
2027
|
+
pathWithQuery = "/" + pathWithQuery;
|
|
2028
2028
|
}
|
|
2029
|
+
const queryIndex = pathWithQuery.indexOf("?");
|
|
2030
|
+
let path = queryIndex >= 0 ? pathWithQuery.slice(0, queryIndex) : pathWithQuery;
|
|
2031
|
+
const rawQuery = queryIndex >= 0 ? pathWithQuery.slice(queryIndex + 1) : "";
|
|
2029
2032
|
if (path.length > 1 && path.endsWith("/")) {
|
|
2030
2033
|
path = path.slice(0, -1);
|
|
2031
2034
|
}
|
|
2032
2035
|
// Replace UUIDs with :id for better aggregation
|
|
2033
2036
|
path = path.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ":id");
|
|
2037
|
+
// Normalize query params (sort alphabetically for stable aggregation)
|
|
2038
|
+
let query = "";
|
|
2039
|
+
if (rawQuery) {
|
|
2040
|
+
const params = new URLSearchParams(rawQuery);
|
|
2041
|
+
params.sort();
|
|
2042
|
+
query = params.toString();
|
|
2043
|
+
}
|
|
2044
|
+
// Capture request content metadata
|
|
2045
|
+
const headers = req.headers || {};
|
|
2046
|
+
const contentType = String(headers["content-type"] || "");
|
|
2047
|
+
const contentLengthHeader = headers["content-length"];
|
|
2048
|
+
const contentLength = contentLengthHeader ? Number(contentLengthHeader) : 0;
|
|
2034
2049
|
// Add request data to session report
|
|
2035
2050
|
logger$1.report({
|
|
2036
2051
|
method: req.method,
|
|
2037
2052
|
path,
|
|
2053
|
+
query,
|
|
2054
|
+
contentType,
|
|
2055
|
+
contentLength,
|
|
2038
2056
|
status: String(res.statusCode),
|
|
2039
2057
|
});
|
|
2040
2058
|
// Submit metric if Datadog is configured
|