Skip to content

Conversation

@jaydgoss
Copy link
Member

Summary

  • Adds a "Test Monitor" / "Test Rule" button to both the legacy uptime alert form and new detector form
  • Button calls the /uptime-preview-check/ endpoint to validate the monitor configuration
  • Shows success/error messages based on check_result.status from the response
  • Button is placed in the form footer next to Create/Save buttons

Changes

  • Added TestUptimeMonitorButton component with proper TypeScript types for the preview check response
  • Added PreviewCheckStatus and PreviewCheckStatusReasonType enums to types.tsx
  • Integrated button into both legacy UptimeAlertForm and new detector forms (NewUptimeDetectorForm, EditExistingUptimeDetectorForm)
  • Button is gated behind uptime-runtime-assertions feature flag

Test plan

  • Verify "Test Rule" button appears in legacy uptime alert form (create/edit)
  • Verify "Test Monitor" button appears in new detector form (create/edit)
  • Click test button with valid URL - should show success message
  • Click test button with invalid URL - should show error message
  • Click test button without URL - should show "Please enter a URL to test" error
  • Verify button is disabled while request is in progress

Add a "Test Monitor" button that allows users to test their uptime
monitor configuration before saving. The button calls the preview
check endpoint and displays success/error feedback via toast messages.

The button is added to both:
- Legacy uptime alert form (alerts/rules/uptime)
- New detector form (detectors/components/forms/uptime)

Only visible when the uptime-runtime-assertions feature flag is enabled.
Update the uptime test monitor button to use the recommended fetchMutation
pattern instead of the deprecated useApi approach per frontend guidelines.
Convert headers and assertion from potential MobX observable proxies to
plain JavaScript arrays/objects before sending to the API, fixing 400
errors from the backend validator.
Use formModel.getTransformedData() to get properly transformed form data
instead of manually converting MobX observables. This is the correct API
for getting form data that will be sent to API endpoints.
- Move Test Monitor button to form footer next to submit button in both
  legacy and detector forms
- Check check_result.status from uptime-checker response to determine
  success/failure instead of relying on HTTP status code
- Add PreviewCheck* types to types.tsx matching the uptime-checker
  /execute_config response format
- Update tests to use correct response format with check_result.status
Add label prop to TestUptimeMonitorButton allowing customization.
Old form uses "Test Rule" while new detector form defaults to "Test Monitor".
Use Flex with gap instead of Fragment for proper spacing between
delete and test buttons.
@linear
Copy link

linear bot commented Jan 22, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 22, 2026
- Move PreviewCheckPayload type to types.tsx for centralization
- Use DEFAULT_UPTIME_DETECTOR_FORM_DATA_MAP for fallback values instead of duplicating constants
- Remove region from preview check payload (not needed by endpoint)
- Revert unrelated rspack.config.ts changes
- Add tests for custom label prop, MISSED_WINDOW/DISALLOWED_BY_ROBOTS statuses, and assertion data
…ode organization

- Move fallback handling from TestUptimeMonitorButton to its callers,
  allowing each context to provide appropriate defaults
- Extract ConnectedTestUptimeMonitorButton to its own file
- Remove unnecessary Observer wrapper in uptimeAlertForm
- Access form context directly instead of subscribing to individual fields
- Add DEFAULT_TIMEOUT_MS and DEFAULT_METHOD constants in uptimeAlertForm
- Remove IconPlay from TestUptimeMonitorButton
- Add optional size prop to TestUptimeMonitorButton and ConnectedTestUptimeMonitorButton
- Use size="sm" in EditExistingUptimeDetectorForm to match other footer buttons
@jaydgoss
Copy link
Member Author

jaydgoss commented Jan 22, 2026

@klochek uptime-preview-check endpoint 403s with CSRF Failed: Origin checking failed in the context of a vercel preview deploy, I'm assuming that is to be expected. Worked fine for me in local env.

@jaydgoss jaydgoss marked this pull request as ready for review January 22, 2026 23:33
@jaydgoss jaydgoss requested review from a team as code owners January 22, 2026 23:33
@jaydgoss jaydgoss requested a review from Abdkhan14 January 22, 2026 23:33
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

url: data.url || undefined,
method: data.method || DEFAULT_UPTIME_DETECTOR_FORM_DATA_MAP.method,
headers: data.headers ?? DEFAULT_UPTIME_DETECTOR_FORM_DATA_MAP.headers,
body: data.body || null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test button sends body for GET/HEAD/OPTIONS requests

Medium Severity

The getFormData function in the detector form's test button always sends body if present, without checking whether the HTTP method supports request bodies. Methods like GET, HEAD, and OPTIONS shouldn't include bodies. The alert form version correctly checks methodHasBody(formModel) before including body data, but the detector form version doesn't perform this validation.

Fix in Cursor Fix in Web


// Preview Check Types (raw response from uptime-checker /execute_config endpoint)

export enum PreviewCheckStatus {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we already have these types above in the file, I believe the just map to the same response i.e. CheckStatus, CheckStatusReason etc.

We might just need to extend those

Copy link
Member Author

@jaydgoss jaydgoss Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! These are intentionally separate for a few reasons:

  1. Different API sources: The PreviewCheck* types represent the raw response from the uptime-checker's /execute_config endpoint, while CheckStatus/CheckStatusReason represent what's stored and returned from Sentry's backend. They're distinct APIs with legitimately different response shapes.

  2. Different values that are context-specific:

    • CheckStatus has FAILURE_INCIDENT (computed by Sentry after multiple failures constitute an incident - not produced by uptime-checker)
    • PreviewCheckStatus includes values like DISALLOWED_BY_ROBOTS that uptime-checker produces but Sentry filters out of stored/returned data
    • PreviewCheckStatusReasonType includes assertion-specific errors and miss reasons that aren't exposed in Sentry's API responses
  3. TypeScript limitation: Enums can't extend other enums in TypeScript, so consolidation would require switching to const objects with union types, adding complexity without clear benefit.

The duplication of shared values is minimal and keeping them separate provides better type safety for each context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants