Skip to content

feat: Allow to add webhooks from Create Alert modal #767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ernestii
Copy link
Contributor

Screenshot 2025-04-19 at 11 34 19 AM

@ernestii ernestii requested a review from Copilot April 19, 2025 17:34
Copy link

changeset-bot bot commented Apr 19, 2025

⚠️ No Changeset found

Latest commit: 5a3b5a1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hyperdx-v2-oss-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 30, 2025 4:33pm

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to create and add webhooks directly from the Create Alert modal. The key changes include:

  • Integrating a modal in Alerts.tsx to host the CreateWebhookForm.
  • Refetching the list of webhooks upon successful webhook creation and updating the form field.
  • Exporting and updating the CreateWebhookForm component in TeamPage.tsx, including a change in its onSuccess signature to receive a webhook ID.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/app/src/components/Alerts.tsx Adds modal logic and uses a new webhook creation form to update webhook state.
packages/app/src/TeamPage.tsx Exports and adjusts CreateWebhookForm to pass the generated webhook ID on success.

@@ -711,7 +711,7 @@ function CreateWebhookForm({
color: 'green',
message: `Webhook created successfully`,
});
onSuccess();
onSuccess(response.data?._id);
Copy link
Preview

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

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

Potential issue: If response.data is undefined, onSuccess will be called with undefined. Consider adding an explicit null check or a fallback to ensure that a valid webhook ID is passed.

Suggested change
onSuccess(response.data?._id);
if (response.data && response.data._id) {
onSuccess(response.data._id);
} else {
console.warn('Webhook creation succeeded, but no ID was returned.');
notifications.show({
color: 'yellow',
message: 'Webhook created, but no ID was returned by the server.',
});
}

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ernestii what happens when response.data is empty in the upstream onSuccess event? Depending on that, this may be a valid suggestion (except for the notification).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

technically api should never return 200 with empty data, it'll return 500 after catching the error

      await webhook.save();
      res.json({
        data: webhook,
      });
    } catch (err) {
      next(err);
    }

onSuccess ultimately is used for selecting the newly created webhook in the dropdown, so I made the webhookId optional upstream

@ernestii ernestii force-pushed the ernest/hdx-1487-would-be-nice-if-add-new-incoming-webhook-opened-a-modal branch from eb18f94 to a1d4a36 Compare April 30, 2025 01:34
@ernestii ernestii requested a review from teeohhem April 30, 2025 01:34
@kodiakhq kodiakhq bot merged commit d77cb2d into v2 Apr 30, 2025
5 of 6 checks passed
@kodiakhq kodiakhq bot deleted the ernest/hdx-1487-would-be-nice-if-add-new-incoming-webhook-opened-a-modal branch April 30, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants