@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.
@@ -2024,19 +2024,37 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
2024
2024
  res: summarizeResponse(res, extras),
2025
2025
  });
2026
2026
  // Construct normalized path for reporting and metrics
2027
- let path = (req.baseUrl || "") + (req.url || "");
2028
- if (!path.startsWith("/")) {
2029
- path = "/" + path;
2027
+ let pathWithQuery = (req.baseUrl || "") + (req.url || "");
2028
+ if (!pathWithQuery.startsWith("/")) {
2029
+ pathWithQuery = "/" + pathWithQuery;
2030
2030
  }
2031
+ const queryIndex = pathWithQuery.indexOf("?");
2032
+ let path = queryIndex >= 0 ? pathWithQuery.slice(0, queryIndex) : pathWithQuery;
2033
+ const rawQuery = queryIndex >= 0 ? pathWithQuery.slice(queryIndex + 1) : "";
2031
2034
  if (path.length > 1 && path.endsWith("/")) {
2032
2035
  path = path.slice(0, -1);
2033
2036
  }
2034
2037
  // Replace UUIDs with :id for better aggregation
2035
2038
  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");
2039
+ // Normalize query params (sort alphabetically for stable aggregation)
2040
+ let query = "";
2041
+ if (rawQuery) {
2042
+ const params = new URLSearchParams(rawQuery);
2043
+ params.sort();
2044
+ query = params.toString();
2045
+ }
2046
+ // Capture request content metadata
2047
+ const headers = req.headers || {};
2048
+ const contentType = String(headers["content-type"] || "");
2049
+ const contentLengthHeader = headers["content-length"];
2050
+ const contentLength = contentLengthHeader ? Number(contentLengthHeader) : 0;
2036
2051
  // Add request data to session report
2037
2052
  logger$1.report({
2038
2053
  method: req.method,
2039
2054
  path,
2055
+ query,
2056
+ contentType,
2057
+ contentLength,
2040
2058
  status: String(res.statusCode),
2041
2059
  });
2042
2060
  // Submit metric if Datadog is configured