-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat!: Only collect ip addresses with sendDefaultPii: true
#15084
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { Client } from '../client'; | ||
import { defineIntegration } from '../integration'; | ||
import type { Event, IntegrationFn, RequestEventData } from '../types-hoist'; | ||
import { parseCookie } from '../utils/cookie'; | ||
|
@@ -38,12 +39,12 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) = | |
|
||
return { | ||
name: INTEGRATION_NAME, | ||
processEvent(event) { | ||
processEvent(event, _hint, client) { | ||
const { sdkProcessingMetadata = {} } = event; | ||
const { normalizedRequest, ipAddress } = sdkProcessingMetadata; | ||
|
||
if (normalizedRequest) { | ||
addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, include); | ||
addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, include, client); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l: This is also fine, but what if we mutated addNormalizedRequestDataToEvent(event, normalizedRequest, { ipAddress }, { ip: client.getOptions().sendDefaultPii, ...include }); or something like this? (not quite, as ip is set by default, but logic wise something like this...) But I'm also OK with leaving it as it is here! |
||
} | ||
|
||
return event; | ||
|
@@ -67,13 +68,14 @@ function addNormalizedRequestDataToEvent( | |
// Data that should not go into `event.request` but is somehow related to requests | ||
additionalData: { ipAddress?: string }, | ||
include: RequestDataIncludeOptions, | ||
client: Client, | ||
): void { | ||
event.request = { | ||
...event.request, | ||
...extractNormalizedRequestData(req, include), | ||
}; | ||
|
||
if (include.ip) { | ||
if (include.ip || client.getOptions().sendDefaultPii) { | ||
const ip = (req.headers && getClientIPAddress(req.headers)) || additionalData.ipAddress; | ||
if (ip) { | ||
event.user = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I wonder if we can just conditionally not add both of these hooks at all here if this is not on? 🤔 a bit simpler, you loose the ability to flip this option later, but is this something we want to/need to support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh totally. Mutating options is kinda not something we intentionally support. Whenever it works it is usually by accident.