From e7568c5d7ce21df706f3e367e3024b6be6a5ead9 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 30 Jun 2022 14:11:19 +0200 Subject: [PATCH 1/3] feat(sdk): Add sendDefaultPii option to the JS SDKs So far, just the option and a method to query it, similarly to how the Python SDK does it --- packages/hub/src/hub.ts | 10 ++++++++++ packages/types/src/options.ts | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/hub/src/hub.ts b/packages/hub/src/hub.ts index 9a2d306603c9..e26de29537b9 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.getStackTop(); + const options = client && client.getOptions(); + return Boolean(options && options.sendDefaultPii); + } + /** * Sends the current Session on the scope */ 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 Date: Thu, 30 Jun 2022 15:02:21 +0200 Subject: [PATCH 2/3] add tests --- packages/hub/test/hub.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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); + }); + }); }); From 53d059b46fe6ab9e3418c4b90948f64e67118669 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 1 Jul 2022 08:56:10 +0200 Subject: [PATCH 3/3] Change client retrieval Co-authored-by: Abhijeet Prasad --- packages/hub/src/hub.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hub/src/hub.ts b/packages/hub/src/hub.ts index e26de29537b9..dc5e6ccefd21 100644 --- a/packages/hub/src/hub.ts +++ b/packages/hub/src/hub.ts @@ -444,7 +444,7 @@ export class Hub implements HubInterface { * when Tracing is used. */ public shouldSendDefaultPii(): boolean { - const { client } = this.getStackTop(); + const client = this.getClient(); const options = client && client.getOptions(); return Boolean(options && options.sendDefaultPii); }