Skip to content

Commit ee6a1e8

Browse files
fix(uptime): Include headers and body in detector form payload (#105686)
The uptime detector form was collecting headers and body fields but not sending them to the backend. Updated uptimeFormDataToEndpointPayload to include these fields in the dataSources payload. Also added test coverage to verify headers and body are properly included in the API request. Fixed [NEW-671](https://linear.app/getsentry/issue/NEW-671)
1 parent ca3887d commit ee6a1e8

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

static/app/types/workflowEngine/detectors.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ interface UpdateUptimeDataSourcePayload {
190190
timeoutMs: number;
191191
traceSampling: boolean;
192192
url: string;
193+
body?: string | null;
194+
headers?: Array<[string, string]>;
193195
}
194196

195197
export interface BaseDetectorUpdatePayload {

static/app/views/detectors/components/forms/uptime/fields.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export function uptimeFormDataToEndpointPayload(
4343
timeoutMs: data.timeoutMs,
4444
traceSampling: data.traceSampling,
4545
url: data.url,
46+
headers: data.headers,
47+
body: data.body || null,
4648
},
4749
],
4850
config: {

static/app/views/detectors/new-setting.spec.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,20 @@ describe('DetectorEdit', () => {
775775
'https://uptime.example.com'
776776
);
777777

778+
// Change method to POST
779+
await selectEvent.select(screen.getByRole('textbox', {name: 'Method'}), 'POST');
780+
781+
// Add headers
782+
const headerNameInput = screen.getByRole('textbox', {name: 'Name of header 1'});
783+
await userEvent.type(headerNameInput, 'X-API-Key');
784+
const headerValueInput = screen.getByRole('textbox', {name: 'Value of X-API-Key'});
785+
await userEvent.type(headerValueInput, 'secret-key-123');
786+
787+
// Add body
788+
const bodyInput = screen.getByRole('textbox', {name: 'Body'});
789+
await userEvent.click(bodyInput);
790+
await userEvent.paste('{"test": "data"}');
791+
778792
await selectEvent.select(screen.getByLabelText('Select Environment'), 'production');
779793

780794
await userEvent.click(screen.getByRole('button', {name: 'Create Monitor'}));
@@ -796,10 +810,12 @@ describe('DetectorEdit', () => {
796810
dataSources: [
797811
{
798812
intervalSeconds: 60,
799-
method: 'GET',
813+
method: 'POST',
800814
timeoutMs: 5000,
801815
traceSampling: undefined,
802816
url: 'https://uptime.example.com',
817+
headers: [['X-API-Key', 'secret-key-123']],
818+
body: '{"test": "data"}',
803819
},
804820
],
805821
name: 'Uptime Monitor',
@@ -865,6 +881,8 @@ describe('DetectorEdit', () => {
865881
timeoutMs: 5000,
866882
traceSampling: undefined,
867883
url: 'https://uptime-custom.example.com',
884+
headers: [],
885+
body: null,
868886
},
869887
],
870888
name: 'Uptime check for uptime-custom.example.com',

0 commit comments

Comments
 (0)