File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -439,6 +439,16 @@ export class Hub implements HubInterface {
439439 return session ;
440440 }
441441
442+ /**
443+ * Returns if default PII should be sent to Sentry and propagated in ourgoing requests
444+ * when Tracing is used.
445+ */
446+ public shouldSendDefaultPii ( ) : boolean {
447+ const client = this . getClient ( ) ;
448+ const options = client && client . getOptions ( ) ;
449+ return Boolean ( options && options . sendDefaultPii ) ;
450+ }
451+
442452 /**
443453 * Sends the current Session on the scope
444454 */
Original file line number Diff line number Diff line change @@ -431,4 +431,23 @@ describe('Hub', () => {
431431 } ) ;
432432 } ) ;
433433 } ) ;
434+
435+ describe ( 'shouldSendDefaultPii()' , ( ) => {
436+ test ( 'return false if sendDefaultPii is not set' , ( ) => {
437+ const testClient = makeClient ( ) ;
438+ const hub = new Hub ( testClient ) ;
439+ expect ( hub . shouldSendDefaultPii ( ) ) . toBe ( false ) ;
440+ } ) ;
441+
442+ test ( 'return true if sendDefaultPii is set in the client options' , ( ) => {
443+ const testClient = makeClient ( ) ;
444+ testClient . getOptions = ( ) => {
445+ return {
446+ sendDefaultPii : true ,
447+ } as unknown as any ;
448+ } ;
449+ const hub = new Hub ( testClient ) ;
450+ expect ( hub . shouldSendDefaultPii ( ) ) . toBe ( true ) ;
451+ } ) ;
452+ } ) ;
434453} ) ;
Original file line number Diff line number Diff line change @@ -152,6 +152,21 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
152152 */
153153 tunnel ?: string ;
154154
155+ /**
156+ * Currently controls if the user id (e.g. set by `Sentry.setUser`) should
157+ * be used for dynamic sampling. Only if this flag is set to `true`, the user id
158+ * will be propagated to outgoing requests in the `baggage` Http header.
159+ *
160+ * Note that in the next major version of this SDK, this option will not only
161+ * control dynamic sampling data: As long as this flag is not set to `true`,
162+ * the SDK will not send sensitive data by default.
163+ *
164+ * Defaults to `false`.
165+ *
166+ * @experimental (will be fully introduced in the next major version)
167+ */
168+ sendDefaultPii ?: boolean ;
169+
155170 /**
156171 * Set of metadata about the SDK that can be internally used to enhance envelopes and events,
157172 * and provide additional data about every request.
You can’t perform that action at this time.
0 commit comments