@sentry/utils
Advanced tools
Comparing version
@@ -9,2 +9,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
const url = require('./url.js'); | ||
const getIpAddress = require('./vendor/getIpAddress.js'); | ||
@@ -72,3 +73,2 @@ const DEFAULT_INCLUDES = { | ||
/** JSDoc */ | ||
function extractTransaction(req, type) { | ||
@@ -91,3 +91,2 @@ switch (type) { | ||
/** JSDoc */ | ||
function extractUserData( | ||
@@ -124,6 +123,5 @@ user | ||
, | ||
= {}, | ||
) { | ||
const { include = DEFAULT_REQUEST_INCLUDES } = options || {}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const { include = DEFAULT_REQUEST_INCLUDES } = options; | ||
const requestData = {}; | ||
@@ -167,2 +165,10 @@ | ||
// Remove IP headers in case IP data should not be included in the event | ||
if (!include.includes('ip')) { | ||
getIpAddress.ipHeaderNames.forEach(ipHeaderName => { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete (requestData.headers )[ipHeaderName]; | ||
}); | ||
} | ||
break; | ||
@@ -241,6 +247,9 @@ } | ||
if (include.request) { | ||
const extractedRequestData = Array.isArray(include.request) | ||
? extractRequestData(req, { include: include.request }) | ||
: extractRequestData(req); | ||
const includeRequest = Array.isArray(include.request) ? [...include.request] : [...DEFAULT_REQUEST_INCLUDES]; | ||
if (include.ip) { | ||
includeRequest.push('ip'); | ||
} | ||
const extractedRequestData = extractRequestData(req, { include: includeRequest }); | ||
event.request = { | ||
@@ -266,4 +275,5 @@ ...event.request, | ||
// express, koa: req.ip | ||
// It may also be sent by proxies as specified in X-Forwarded-For or similar headers | ||
if (include.ip) { | ||
const ip = req.ip || (req.socket && req.socket.remoteAddress); | ||
const ip = (req.headers && getIpAddress.getClientIPAddress(req.headers)) || req.ip || (req.socket && req.socket.remoteAddress); | ||
if (ip) { | ||
@@ -270,0 +280,0 @@ event.user = { |
Object.defineProperty(exports, '__esModule', { value: true }); | ||
const SDK_VERSION = '8.24.0'; | ||
const SDK_VERSION = '8.25.0'; | ||
exports.SDK_VERSION = SDK_VERSION; | ||
//# sourceMappingURL=version.js.map |
@@ -7,2 +7,3 @@ import { parseCookie } from './cookie.js'; | ||
import { stripUrlQueryAndFragment } from './url.js'; | ||
import { ipHeaderNames, getClientIPAddress } from './vendor/getIpAddress.js'; | ||
@@ -70,3 +71,2 @@ const DEFAULT_INCLUDES = { | ||
/** JSDoc */ | ||
function extractTransaction(req, type) { | ||
@@ -89,3 +89,2 @@ switch (type) { | ||
/** JSDoc */ | ||
function extractUserData( | ||
@@ -122,6 +121,5 @@ user | ||
, | ||
= {}, | ||
) { | ||
const { include = DEFAULT_REQUEST_INCLUDES } = options || {}; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const { include = DEFAULT_REQUEST_INCLUDES } = options; | ||
const requestData = {}; | ||
@@ -165,2 +163,10 @@ | ||
// Remove IP headers in case IP data should not be included in the event | ||
if (!include.includes('ip')) { | ||
ipHeaderNames.forEach(ipHeaderName => { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete (requestData.headers )[ipHeaderName]; | ||
}); | ||
} | ||
break; | ||
@@ -239,6 +245,9 @@ } | ||
if (include.request) { | ||
const extractedRequestData = Array.isArray(include.request) | ||
? extractRequestData(req, { include: include.request }) | ||
: extractRequestData(req); | ||
const includeRequest = Array.isArray(include.request) ? [...include.request] : [...DEFAULT_REQUEST_INCLUDES]; | ||
if (include.ip) { | ||
includeRequest.push('ip'); | ||
} | ||
const extractedRequestData = extractRequestData(req, { include: includeRequest }); | ||
event.request = { | ||
@@ -264,4 +273,5 @@ ...event.request, | ||
// express, koa: req.ip | ||
// It may also be sent by proxies as specified in X-Forwarded-For or similar headers | ||
if (include.ip) { | ||
const ip = req.ip || (req.socket && req.socket.remoteAddress); | ||
const ip = (req.headers && getClientIPAddress(req.headers)) || req.ip || (req.socket && req.socket.remoteAddress); | ||
if (ip) { | ||
@@ -268,0 +278,0 @@ event.user = { |
@@ -1,4 +0,4 @@ | ||
const SDK_VERSION = '8.24.0'; | ||
const SDK_VERSION = '8.25.0'; | ||
export { SDK_VERSION }; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "8.24.0"; | ||
export declare const SDK_VERSION = "8.25.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export declare const SDK_VERSION = "8.24.0"; | ||
export declare const SDK_VERSION = "8.25.0"; | ||
//# sourceMappingURL=version.d.ts.map |
{ | ||
"name": "@sentry/utils", | ||
"version": "8.24.0", | ||
"version": "8.25.0", | ||
"description": "Utilities for all Sentry JavaScript SDKs", | ||
@@ -42,3 +42,3 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/types": "8.24.0" | ||
"@sentry/types": "8.25.0" | ||
}, | ||
@@ -45,0 +45,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1185239
2.5%393
1.81%13002
2.16%+ Added
- Removed
Updated