Skip to content

feat(sdk): Add sendDefaultPii option to the JS SDKs #5341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/hub/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
19 changes: 19 additions & 0 deletions packages/hub/test/hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
15 changes: 15 additions & 0 deletions packages/types/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ export interface ClientOptions<TO extends BaseTransportOptions = BaseTransportOp
*/
tunnel?: string;

/**
* Currently controls if the user id (e.g. set by `Sentry.setUser`) should
* be used for dynamic sampling. Only if this flag is set to `true`, the user id
* will be propagated to outgoing requests in the `baggage` Http header.
*
* Note that in the next major version of this SDK, this option will not only
* control dynamic sampling data: As long as this flag is not set to `true`,
* the SDK will not send sensitive data by default.
*
* Defaults to `false`.
*
* @experimental (will be fully introduced in the next major version)
*/
sendDefaultPii?: boolean;

/**
* Set of metadata about the SDK that can be internally used to enhance envelopes and events,
* and provide additional data about every request.
Expand Down