Skip to content

Commit f372d84

Browse files
authored
ref(tracing): Remove transaction name and user_id from DSC (#5363)
This patch temporarily removes the `user_id` and `transaction` (name) fields from the dynamic sampling context, meaning they will no longer propagated with outgoing requests via the baggage Http header or sent to sentry via the `trace` envelope header. We're taking this temporary measure to ensure that for the moment PII is not sent to third parties.
1 parent 815801a commit f372d84

File tree

15 files changed

+66
-44
lines changed

15 files changed

+66
-44
lines changed

packages/core/test/lib/envelope.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ describe('createEventEnvelope', () => {
4444
{
4545
environment: 'prod',
4646
release: '1.0.0',
47-
transaction: 'TX',
48-
user_id: 'bob',
47+
// transaction: 'TX',
48+
// user_id: 'bob',
4949
user_segment: 'segmentA',
5050
sample_rate: '0.95',
5151
public_key: 'pubKey123',
@@ -59,8 +59,8 @@ describe('createEventEnvelope', () => {
5959
{
6060
environment: 'prod',
6161
release: '1.0.0',
62-
transaction: 'TX',
63-
user_id: 'bob',
62+
// transaction: 'TX',
63+
// user_id: 'bob',
6464
user_segment: 'segmentA',
6565
sample_rate: '0.95',
6666
public_key: 'pubKey123',

packages/integration-tests/suites/tracing/envelope-header-no-pii/test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { sentryTest } from '../../../utils/fixtures';
55
import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers';
66

77
sentryTest(
8-
'should not send user_id in DSC data in trace envelope header if sendDefaultPii option is not set',
8+
'should not send user_id and transaction in DSC data in trace envelope header (for now)',
99
async ({ getLocalTestPath, page }) => {
1010
const url = await getLocalTestPath({ testDir: __dirname });
1111

@@ -14,7 +14,6 @@ sentryTest(
1414
expect(envHeader.trace).toBeDefined();
1515
expect(envHeader.trace).toEqual({
1616
environment: 'production',
17-
transaction: expect.stringContaining('index.html'),
1817
user_segment: 'segmentB',
1918
sample_rate: '1',
2019
trace_id: expect.any(String),

packages/integration-tests/suites/tracing/envelope-header/init.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Sentry.init({
88
integrations: [new Integrations.BrowserTracing({ tracingOrigins: [/.*/] })],
99
environment: 'production',
1010
tracesSampleRate: 1,
11-
sendDefaultPii: true,
11+
// TODO: We're rethinking the mechanism for including Pii data in DSC, hence commenting out sendDefaultPii for now
12+
// sendDefaultPii: true,
1213
debug: true,
1314
});
1415

packages/integration-tests/suites/tracing/envelope-header/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ sentryTest(
1414
expect(envHeader.trace).toBeDefined();
1515
expect(envHeader.trace).toEqual({
1616
environment: 'production',
17-
transaction: expect.stringContaining('index.html'),
18-
user_id: 'user123',
17+
// transaction: expect.stringContaining('index.html'),
18+
// user_id: 'user123',
1919
user_segment: 'segmentB',
2020
sample_rate: '1',
2121
trace_id: expect.any(String),

packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ test('Should populate and propagate sentry baggage if sentry-trace header does n
7979
test_data: {
8080
host: 'somewhere.not.sentry',
8181
baggage: expect.stringContaining(
82-
'sentry-environment=prod,sentry-release=1.0,sentry-transaction=GET%20%2Ftest%2Fexpress,' +
83-
'sentry-public_key=public,sentry-trace_id=',
82+
// Commented out as long as transaction and user_id are not part of DSC
83+
// 'sentry-environment=prod,sentry-release=1.0,sentry-transaction=GET%20%2Ftest%2Fexpress,' +
84+
// 'sentry-public_key=public,sentry-trace_id=',
85+
'sentry-environment=prod,sentry-release=1.0,sentry-public_key=public,sentry-trace_id=',
8486
),
8587
},
8688
});
@@ -99,8 +101,10 @@ test('Should populate Sentry and ignore 3rd party content if sentry-trace header
99101
host: 'somewhere.not.sentry',
100102
// TraceId changes, hence we only expect that the string contains the traceid key
101103
baggage: expect.stringContaining(
102-
'sentry-environment=prod,sentry-release=1.0,sentry-transaction=GET%20%2Ftest%2Fexpress,' +
103-
'sentry-public_key=public,sentry-trace_id=',
104+
// Commented out as long as transaction and user_id are not part of DSC
105+
// 'sentry-environment=prod,sentry-release=1.0,sentry-transaction=GET%20%2Ftest%2Fexpress,' +
106+
// 'sentry-public_key=public,sentry-trace_id=',
107+
'sentry-environment=prod,sentry-release=1.0,sentry-public_key=public,sentry-trace_id=',
104108
),
105109
},
106110
});

packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,26 @@ test('should attach a `baggage` header to an outgoing request.', async () => {
1313
test_data: {
1414
host: 'somewhere.not.sentry',
1515
baggage:
16-
'sentry-environment=prod,sentry-release=1.0,sentry-transaction=GET%20%2Ftest%2Fexpress,sentry-user_segment=SegmentA' +
16+
// Commented out as long as transaction and user_id are not part of DSC
17+
// 'sentry-environment=prod,sentry-release=1.0,sentry-transaction=GET%20%2Ftest%2Fexpress,sentry-user_segment=SegmentA' +
18+
'sentry-environment=prod,sentry-release=1.0,sentry-user_segment=SegmentA' +
1719
',sentry-public_key=public,sentry-trace_id=86f39e84263a4de99c326acab3bfe3bd,sentry-sample_rate=1',
1820
},
1921
});
2022
});
2123

22-
test('Does not include user_id in baggage if sendDefaultPii is not set', async () => {
24+
test('Does not include user_id and transaction name (for now)', async () => {
2325
const url = await runServer(__dirname, `${path.resolve(__dirname, '.')}/server.ts`);
2426

2527
const response = (await getAPIResponse(new URL(`${url}/express`))) as TestAPIResponse;
28+
const baggageString = response.test_data.baggage;
2629

2730
expect(response).toBeDefined();
2831
expect(response).toMatchObject({
2932
test_data: {
3033
host: 'somewhere.not.sentry',
31-
baggage: expect.not.stringContaining('sentry-user_id'),
3234
},
3335
});
36+
expect(baggageString).not.toContain('sentry-user_id=');
37+
expect(baggageString).not.toContain('sentry-transaction=');
3438
});

packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ test('should ignore sentry-values in `baggage` header of a third party vendor an
3030
test_data: {
3131
host: 'somewhere.not.sentry',
3232
baggage: expect.stringContaining(
33-
'other=vendor,foo=bar,third=party,last=item,sentry-environment=prod,sentry-release=1.0,' +
34-
'sentry-transaction=GET%20%2Ftest%2Fexpress,sentry-public_key=public',
33+
// Commented out as long as transaction and user_id are not part of DSC
34+
// 'other=vendor,foo=bar,third=party,last=item,sentry-environment=prod,sentry-release=1.0,' +
35+
// 'sentry-transaction=GET%20%2Ftest%2Fexpress,sentry-public_key=public',
36+
'other=vendor,foo=bar,third=party,last=item,sentry-environment=prod,sentry-release=1.0,sentry-public_key=public',
3537
),
3638
},
3739
});

packages/node-integration-tests/suites/express/sentry-trace/baggage-user-id/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Sentry.init({
1414
environment: 'prod',
1515
integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })],
1616
tracesSampleRate: 1.0,
17-
sendDefaultPii: true,
17+
// TODO: We're rethinking the mechanism for including Pii data in DSC, hence commenting out sendDefaultPii for now
18+
// sendDefaultPii: true,
1819
});
1920

2021
Sentry.setUser({ id: 'user123', segment: 'SegmentA' });

packages/node-integration-tests/suites/express/sentry-trace/baggage-user-id/test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import * as path from 'path';
33
import { getAPIResponse, runServer } from '../../../../utils/index';
44
import { TestAPIResponse } from '../server';
55

6-
test('Includes user_id in baggage if sendDefaultPii is set to true', async () => {
6+
// TODO: Skipping this test because right now we're rethinking the mechanism for including such data
7+
test.skip('Includes user_id in baggage if <optionTBA> is set to true', async () => {
78
const url = await runServer(__dirname, `${path.resolve(__dirname, '.')}/server.ts`);
89

910
const response = (await getAPIResponse(new URL(`${url}/express`))) as TestAPIResponse;

packages/node/test/integrations/http.test.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ describe('tracing', () => {
2424
integrations: [new HttpIntegration({ tracing: true })],
2525
release: '1.0.0',
2626
environment: 'production',
27-
sendDefaultPii: true,
2827
...customOptions,
2928
});
3029
const hub = new Hub(new NodeClient(options));
@@ -113,7 +112,9 @@ describe('tracing', () => {
113112
expect(baggageHeader).toBeDefined();
114113
expect(typeof baggageHeader).toEqual('string');
115114
expect(baggageHeader).toEqual(
116-
'sentry-environment=production,sentry-release=1.0.0,sentry-transaction=dogpark,sentry-user_id=uid123,' +
115+
// Commented out as long as transaction and user_id are not part of DSC
116+
// 'sentry-environment=production,sentry-release=1.0.0,sentry-transaction=dogpark,sentry-user_id=uid123,' +
117+
'sentry-environment=production,sentry-release=1.0.0,' +
117118
'sentry-user_segment=segmentA,sentry-public_key=dogsarebadatkeepingsecrets,' +
118119
'sentry-trace_id=12312012123120121231201212312012,sentry-sample_rate=1',
119120
);
@@ -130,24 +131,31 @@ describe('tracing', () => {
130131
expect(baggageHeader).toBeDefined();
131132
expect(typeof baggageHeader).toEqual('string');
132133
expect(baggageHeader).toEqual(
133-
'dog=great,sentry-environment=production,sentry-release=1.0.0,sentry-transaction=dogpark,' +
134-
'sentry-user_id=uid123,sentry-user_segment=segmentA,sentry-public_key=dogsarebadatkeepingsecrets,' +
134+
// Commented out as long as transaction and user_id are not part of DSC
135+
// 'dog=great,sentry-environment=production,sentry-release=1.0.0,sentry-transaction=dogpark,' +
136+
// 'sentry-user_id=uid123,sentry-user_segment=segmentA,sentry-public_key=dogsarebadatkeepingsecrets,' +
137+
// 'sentry-trace_id=12312012123120121231201212312012,sentry-sample_rate=1',
138+
'dog=great,sentry-environment=production,sentry-release=1.0.0,' +
139+
'sentry-user_segment=segmentA,sentry-public_key=dogsarebadatkeepingsecrets,' +
135140
'sentry-trace_id=12312012123120121231201212312012,sentry-sample_rate=1',
136141
);
137142
});
138143

139-
it('does not add the user_id to the baggage header if sendDefaultPii is set to false', async () => {
144+
// TODO: Skipping this test because right now we're rethinking the mechanism for including such data
145+
it.skip('does not add the user_id to the baggage header if <optionTBA> is set to false', async () => {
140146
nock('http://dogs.are.great').get('/').reply(200);
141147

142-
createTransactionOnScope({ sendDefaultPii: false });
148+
createTransactionOnScope();
143149

144150
const request = http.get({ host: 'http://dogs.are.great/', headers: { baggage: 'dog=great' } });
145151
const baggageHeader = request.getHeader('baggage') as string;
146152

147153
expect(baggageHeader).toBeDefined();
148154
expect(typeof baggageHeader).toEqual('string');
149155
expect(baggageHeader).toEqual(
150-
'dog=great,sentry-environment=production,sentry-release=1.0.0,sentry-transaction=dogpark,' +
156+
// Commented out as long as transaction and user_id are not part of DSC
157+
// 'dog=great,sentry-environment=production,sentry-release=1.0.0,sentry-transaction=dogpark,' +
158+
'dog=great,sentry-environment=production,sentry-release=1.0.0,' +
151159
'sentry-user_segment=segmentA,sentry-public_key=dogsarebadatkeepingsecrets,' +
152160
'sentry-trace_id=12312012123120121231201212312012,sentry-sample_rate=1',
153161
);

0 commit comments

Comments
 (0)