diff --git a/packages/hub/src/hub.ts b/packages/hub/src/hub.ts index 9a2d306603c9..dc5e6ccefd21 100644 --- a/packages/hub/src/hub.ts +++ b/packages/hub/src/hub.ts @@ -439,6 +439,16 @@ export class Hub implements HubInterface { return session; } + /** + * Returns if default PII should be sent to Sentry and propagated in ourgoing requests + * when Tracing is used. + */ + public shouldSendDefaultPii(): boolean { + const client = this.getClient(); + const options = client && client.getOptions(); + return Boolean(options && options.sendDefaultPii); + } + /** * Sends the current Session on the scope */ diff --git a/packages/hub/test/hub.test.ts b/packages/hub/test/hub.test.ts index 443f56b19e11..4513c92aaa94 100644 --- a/packages/hub/test/hub.test.ts +++ b/packages/hub/test/hub.test.ts @@ -431,4 +431,23 @@ describe('Hub', () => { }); }); }); + + describe('shouldSendDefaultPii()', () => { + test('return false if sendDefaultPii is not set', () => { + const testClient = makeClient(); + const hub = new Hub(testClient); + expect(hub.shouldSendDefaultPii()).toBe(false); + }); + + test('return true if sendDefaultPii is set in the client options', () => { + const testClient = makeClient(); + testClient.getOptions = () => { + return { + sendDefaultPii: true, + } as unknown as any; + }; + const hub = new Hub(testClient); + expect(hub.shouldSendDefaultPii()).toBe(true); + }); + }); }); diff --git a/packages/types/src/options.ts b/packages/types/src/options.ts index b8d346f2973e..5b7bde201cd9 100644 --- a/packages/types/src/options.ts +++ b/packages/types/src/options.ts @@ -152,6 +152,21 @@ export interface ClientOptions