diff --git a/docs/platforms/javascript/common/configuration/filtering.mdx b/docs/platforms/javascript/common/configuration/filtering.mdx index e5413a51bfaf6..a0bc6c5719728 100644 --- a/docs/platforms/javascript/common/configuration/filtering.mdx +++ b/docs/platforms/javascript/common/configuration/filtering.mdx @@ -111,3 +111,9 @@ Learn more about configuring the sam ### Using + +## Filtering Spans + +To prevent certain spans from being reported to Sentry, use the configuration option, which allows you to provide a function to evaluate the current span and drop it if it's not one you want. + + diff --git a/docs/platforms/javascript/common/configuration/options.mdx b/docs/platforms/javascript/common/configuration/options.mdx index c82c876d504ae..a4357d349cd66 100644 --- a/docs/platforms/javascript/common/configuration/options.mdx +++ b/docs/platforms/javascript/common/configuration/options.mdx @@ -300,6 +300,12 @@ The callback typically gets a second argument (called a "hint") which contains t + + +This function is called with an SDK-specific span object, and can return a modified span object, or `null` to skip reporting the span. One way this might be used is for manual PII stripping before sending. + + + ## Transport Options diff --git a/platform-includes/configuration/before-send-span/javascript.mdx b/platform-includes/configuration/before-send-span/javascript.mdx new file mode 100644 index 0000000000000..7b60a0d7fb4b0 --- /dev/null +++ b/platform-includes/configuration/before-send-span/javascript.mdx @@ -0,0 +1,17 @@ + + +```javascript +Sentry.init({ + dsn: "___PUBLIC_DSN___", + + // Called for spans + beforeSendSpan(span) { + // Modify or drop the span here + if (span.description === 'unimportant span') { + // Don't send the span to Sentry + return null; + } + return span; + }, +}); +```