Skip to content

feat(aci): Add issue preview to uptime monitor form#112224

Open
malwilley wants to merge 3 commits intomasterfrom
malwilley/uptime-detector-preview
Open

feat(aci): Add issue preview to uptime monitor form#112224
malwilley wants to merge 3 commits intomasterfrom
malwilley/uptime-detector-preview

Conversation

@malwilley
Copy link
Copy Markdown
Member

Ref ISWF-2392

CleanShot 2026-04-03 at 12 53 08@2x

@malwilley malwilley requested a review from a team as a code owner April 3, 2026 19:54
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 3, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 3, 2026
Copy link
Copy Markdown
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 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared fixes for both issues found in the latest run.

  • ✅ Fixed: Preview issue title doesn't match actual backend title
    • Updated useUptimeIssueTitle to use the full URL directly (including protocol) to match the backend behavior in grouptype.py which uses uptime_subscription.url.
  • ✅ Fixed: Duplicated URL display parsing logic across functions
    • Extracted the common URL-to-display-name logic into a shared getDisplayUrl() utility function in fields.tsx and updated useSetAutomaticName to use it.

Create PR

Or push these changes by commenting:

@cursor push 1a777f12d3
Preview (1a777f12d3)
diff --git a/static/app/views/detectors/components/forms/uptime/fields.tsx b/static/app/views/detectors/components/forms/uptime/fields.tsx
--- a/static/app/views/detectors/components/forms/uptime/fields.tsx
+++ b/static/app/views/detectors/components/forms/uptime/fields.tsx
@@ -12,6 +12,21 @@
 export const UPTIME_DEFAULT_RECOVERY_THRESHOLD = 1;
 export const UPTIME_DEFAULT_DOWNTIME_THRESHOLD = 3;
 
+/**
+ * Extracts display components from a URL string.
+ * Returns hostname + path (excluding bare "/") with trailing slashes stripped,
+ * or null if the URL is invalid.
+ */
+export function getDisplayUrl(url: string): string | null {
+  const parsedUrl = URL.parse(url);
+  if (!parsedUrl?.hostname) {
+    return null;
+  }
+
+  const path = parsedUrl.pathname === '/' ? '' : parsedUrl.pathname;
+  return `${parsedUrl.hostname}${path}`.replace(/\/$/, '');
+}
+
 interface UptimeDetectorFormData {
   assertion: UptimeAssertion | null;
   body: string;

diff --git a/static/app/views/detectors/components/forms/uptime/index.tsx b/static/app/views/detectors/components/forms/uptime/index.tsx
--- a/static/app/views/detectors/components/forms/uptime/index.tsx
+++ b/static/app/views/detectors/components/forms/uptime/index.tsx
@@ -24,6 +24,7 @@
 import {ConnectedTestUptimeMonitorButton} from 'sentry/views/detectors/components/forms/uptime/connectedTestUptimeMonitorButton';
 import {UptimeDetectorFormDetectSection} from 'sentry/views/detectors/components/forms/uptime/detect';
 import {
+  getDisplayUrl,
   uptimeFormDataToEndpointPayload,
   uptimeSavedDetectorToFormData,
 } from 'sentry/views/detectors/components/forms/uptime/fields';
@@ -50,15 +51,12 @@
       return null;
     }
 
-    const parsedUrl = URL.parse(url);
-    if (!parsedUrl) {
+    const displayUrl = getDisplayUrl(url);
+    if (!displayUrl) {
       return null;
     }
 
-    const path = parsedUrl.pathname === '/' ? '' : parsedUrl.pathname;
-    const urlName = `${parsedUrl.hostname}${path}`.replace(/\/$/, '');
-
-    return t('Uptime check for %s', urlName);
+    return t('Uptime check for %s', displayUrl);
   });
 
   return (

diff --git a/static/app/views/detectors/components/forms/uptime/uptimeIssuePreview.tsx b/static/app/views/detectors/components/forms/uptime/uptimeIssuePreview.tsx
--- a/static/app/views/detectors/components/forms/uptime/uptimeIssuePreview.tsx
+++ b/static/app/views/detectors/components/forms/uptime/uptimeIssuePreview.tsx
@@ -15,15 +15,7 @@
     return FALLBACK_ISSUE_TITLE;
   }
 
-  const parsedUrl = URL.parse(url);
-  if (!parsedUrl?.hostname) {
-    return FALLBACK_ISSUE_TITLE;
-  }
-
-  const path = parsedUrl.pathname === '/' ? '' : parsedUrl.pathname;
-  const displayUrl = `${parsedUrl.hostname}${path}`.replace(/\/$/, '');
-
-  return t('Downtime detected for %s', displayUrl);
+  return t('Downtime detected for %s', url);
 }
 
 export function UptimeIssuePreview({step}: {step?: number}) {

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3f3ab85. Configure here.

}

const path = parsedUrl.pathname === '/' ? '' : parsedUrl.pathname;
const displayUrl = `${parsedUrl.hostname}${path}`.replace(/\/$/, '');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Duplicated URL display parsing logic across functions

Low Severity

The URL-to-display-name logic (URL.parse → extract hostname + pathname → strip trailing slash) is duplicated between useUptimeIssueTitle and the useSetAutomaticName callback in index.tsx. A shared utility function for this conversion would reduce maintenance burden and ensure the formatting stays consistent if it ever needs to change.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3f3ab85. Configure here.

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.

1 participant