Skip to content

Commit b55d70e

Browse files
ntindallkamilogorek
authored andcommitted
feat: getRequestheaders should handle legacy DSNs
1 parent b8cb9e0 commit b55d70e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/core/src/api.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export class API {
5656
header.push(`sentry_timestamp=${new Date().getTime()}`);
5757
header.push(`sentry_client=${clientName}/${clientVersion}`);
5858
header.push(`sentry_key=${dsn.user}`);
59+
if (dsn.pass) {
60+
header.push(`sentry_secret=${dsn.pass}`);
61+
}
5962
return {
6063
'Content-Type': 'application/json',
6164
'X-Sentry-Auth': header.join(', '),

packages/core/test/lib/api.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { API } from '../../src/api';
22
import { Dsn } from '../../src/dsn';
33

44
const dsnPublic = 'https://[email protected]:1234/subpath/123';
5+
const legacyDsn = 'https://abc:[email protected]:1234/subpath/123';
56

67
describe('API', () => {
78
test('getStoreEndpoint', () => {
@@ -18,7 +19,15 @@ describe('API', () => {
1819
/^Sentry sentry_version=\d, sentry_timestamp=\d+, sentry_client=a\/1\.0, sentry_key=abc$/,
1920
),
2021
});
22+
23+
expect(new API(legacyDsn).getRequestHeaders('a', '1.0')).toMatchObject({
24+
'Content-Type': 'application/json',
25+
'X-Sentry-Auth': expect.stringMatching(
26+
/^Sentry sentry_version=\d, sentry_timestamp=\d+, sentry_client=a\/1\.0, sentry_key=abc, sentry_secret=123$/,
27+
),
28+
});
2129
});
30+
2231
test('getReportDialogEndpoint', () => {
2332
expect(new API(dsnPublic).getReportDialogEndpoint({})).toEqual(
2433
'https://sentry.io:1234/subpath/api/embed/error-page/?dsn=https://[email protected]:1234/subpath/123',

0 commit comments

Comments
 (0)