Skip to content

Add webhooks feature to Insight dashboard #6929

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AmineAfia
Copy link
Contributor

@AmineAfia AmineAfia commented May 2, 2025

Add Webhooks Feature to Insight Dashboard

This PR adds a new webhooks feature to the Insight dashboard, allowing users to create, test, and manage webhooks for blockchain events and transactions. The implementation includes:

  • New API client for webhook operations (create, get, delete, test)
  • Dedicated webhooks page with a table to display and manage existing webhooks
  • Multi-step modal for creating new webhooks with:
    • Basic information configuration
    • Filter options for events or transactions
    • ABI fetching and processing for smart contracts
    • Test functionality to verify webhook endpoints

The PR also includes several UI improvements:

  • Added a key to sidebar separator to fix a React warning
  • Fixed props spreading in multi-select component to avoid DOM validation errors
  • Created a reusable layout for the Insight section with proper navigation tabs

The webhooks feature enables users to receive real-time notifications about on-chain events through their own endpoints, supporting both event and transaction monitoring with customizable filters.


PR-Codex overview

This PR focuses on enhancing the webhooks feature in the dashboard by improving the layout, adding new components, and refining existing functionality for better user experience and performance.

Detailed summary

  • Added Layout component for insights with project and team data retrieval.
  • Implemented StepIndicator for webhook creation steps.
  • Created BasicInfoStep, FilterDetailsStep, and ReviewStep components for structured webhook setup.
  • Enhanced webhook testing functionality with improved error handling.
  • Updated API interactions for creating and managing webhooks.
  • Refined UI elements and added loading states for better user feedback.

The following files were skipped due to too many changes: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/insight/webhooks/components/_components/FilterDetailsStep.tsx

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Demo

CleanShot 2025-05-07 at 18.55.41.mp4 (uploaded via Graphite)

Copy link

changeset-bot bot commented May 2, 2025

⚠️ No Changeset found

Latest commit: 527f82a

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 May 2, 2025

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

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2025 5:00pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) May 7, 2025 5:00pm
login ⬜️ Skipped (Inspect) May 7, 2025 5:00pm
thirdweb_playground ⬜️ Skipped (Inspect) May 7, 2025 5:00pm
wallet-ui ⬜️ Skipped (Inspect) May 7, 2025 5:00pm

@vercel vercel bot temporarily deployed to Preview – login May 2, 2025 19:15 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 2, 2025 19:15 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 2, 2025 19:15 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 2, 2025 19:15 Inactive
@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label May 2, 2025
Copy link
Contributor Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@AmineAfia AmineAfia marked this pull request as ready for review May 2, 2025 19:15
@AmineAfia AmineAfia requested review from a team as code owners May 2, 2025 19:15
Copy link

codecov bot commented May 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.02%. Comparing base (1e82083) to head (527f82a).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6929      +/-   ##
==========================================
- Coverage   55.03%   55.02%   -0.01%     
==========================================
  Files         897      898       +1     
  Lines       57296    57352      +56     
  Branches     3959     3969      +10     
==========================================
+ Hits        31530    31560      +30     
- Misses      25670    25692      +22     
- Partials       96      100       +4     
Flag Coverage Δ
packages 55.02% <ø> (-0.01%) ⬇️

see 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

github-actions bot commented May 2, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 51.01 KB (0%) 1.1 s (0%) 198 ms (+213.02% 🔺) 1.3 s
thirdweb (cjs) 143.18 KB (0%) 2.9 s (0%) 312 ms (+92.18% 🔺) 3.2 s
thirdweb (minimal + tree-shaking) 5.67 KB (0%) 114 ms (0%) 114 ms (+2132.64% 🔺) 228 ms
thirdweb/chains (tree-shaking) 514 B (0%) 11 ms (0%) 33 ms (+1792.61% 🔺) 43 ms
thirdweb/react (minimal + tree-shaking) 19.47 KB (0%) 390 ms (0%) 87 ms (+646.58% 🔺) 476 ms

@AmineAfia AmineAfia force-pushed the Add_webhooks_feature_to_Insight_dashboard branch from 8887def to 4b39e26 Compare May 2, 2025 19:20
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 2, 2025 19:20 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 2, 2025 19:20 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 2, 2025 19:20 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 2, 2025 19:20 Inactive
@AmineAfia AmineAfia force-pushed the Add_webhooks_feature_to_Insight_dashboard branch from 4b39e26 to b083bcc Compare May 2, 2025 21:29
@vercel vercel bot temporarily deployed to Preview – login May 2, 2025 21:29 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 2, 2025 21:29 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 2, 2025 21:29 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 2, 2025 21:30 Inactive
@AmineAfia AmineAfia force-pushed the Add_webhooks_feature_to_Insight_dashboard branch from b083bcc to 36fcc86 Compare May 3, 2025 12:50
@AmineAfia AmineAfia force-pushed the Add_webhooks_feature_to_Insight_dashboard branch from 8f744ae to d9a7521 Compare May 7, 2025 15:01
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 7, 2025 15:01 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 7, 2025 15:01 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 7, 2025 15:01 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 7, 2025 15:01 Inactive
@AmineAfia AmineAfia marked this pull request as ready for review May 7, 2025 15:05
@AmineAfia AmineAfia requested a review from jnsdls May 7, 2025 15:05
@AmineAfia AmineAfia force-pushed the Add_webhooks_feature_to_Insight_dashboard branch from d9a7521 to 40f5370 Compare May 7, 2025 15:30
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 7, 2025 15:30 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 7, 2025 15:30 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 7, 2025 15:30 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 7, 2025 15:30 Inactive
@AmineAfia AmineAfia force-pushed the Add_webhooks_feature_to_Insight_dashboard branch from 40f5370 to 7f83945 Compare May 7, 2025 16:47
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 7, 2025 16:47 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 7, 2025 16:47 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 7, 2025 16:47 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 7, 2025 16:47 Inactive
Copy link
Contributor Author

@jnsdls would love to get your help get this through the door. Im sure I didn't reuse enough components/helpers from dashboard and the structure of the implementation might be different from the rest (I tried to keep it encapsulated for future iterations by the professionals). I also touched the multichainselector and the sidebar due to typing warnings

@AmineAfia AmineAfia force-pushed the Add_webhooks_feature_to_Insight_dashboard branch from 7f83945 to 527f82a Compare May 7, 2025 16:53
@vercel vercel bot temporarily deployed to Preview – login May 7, 2025 16:53 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 7, 2025 16:53 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 7, 2025 16:53 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 7, 2025 16:53 Inactive
Copy link
Member

@jnsdls jnsdls left a comment

Choose a reason for hiding this comment

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

partial review

Comment on lines +68 to +75
const response = await fetch(`${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-client-id": clientId,
},
body: JSON.stringify(payload),
});
Copy link
Member

Choose a reason for hiding this comment

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

I hope this doesn't actually work - clientId cannot be enough to actually authenticate this request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes it works

Comment on lines +107 to +116
const response = await fetch(
`${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks/${webhookId}`,
{
method: "DELETE",
headers: {
"x-client-id": clientId,
},
},
);

Copy link
Member

Choose a reason for hiding this comment

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

same

Comment on lines +88 to +93
const response = await fetch(`${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks`, {
method: "GET",
headers: {
"x-client-id": clientId,
},
});
Copy link
Member

Choose a reason for hiding this comment

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

same

Comment on lines +129 to +137
const response = await fetch(
`${THIRDWEB_INSIGHT_API_DOMAIN}/v1/webhooks/test`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-client-id": clientId,
},
body: JSON.stringify(payload),
Copy link
Member

Choose a reason for hiding this comment

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

same

Comment on lines 165 to +173
{props.customTrigger || (
<Button
ref={ref}
{...props}
{...(() => {
// Extract customTrigger from props to avoid passing it to the DOM
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { customTrigger, ...restProps } = props;
return restProps;
})()}
Copy link
Member

Choose a reason for hiding this comment

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

this sure is a fancy way of doing {customTrigger, ...props} above

const isTesting = isTestingMap[webhookUrl || ""];
// Get test result if available
const testResult = testResults[webhookUrl || ""];
const isRecent = isRecentResult(webhookUrl || "");
Copy link
Member

Choose a reason for hiding this comment

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

why does recency matter?

}

export function useAbiProcessing({
form,
Copy link
Member

Choose a reason for hiding this comment

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

tbh passing this form around everywhere makes me feel weird, why not just pass the values we need into the hook?


try {
// For each address, try to fetch ABI
for (const address of addresses) {
Copy link
Member

Choose a reason for hiding this comment

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

can we do this in a Promise.all instead? depending on how many contract this is this is going to make N network requests sequentially, could take significant amounts of time...

Comment on lines +85 to +86
const { data: fetchedEventAbiData, isFetching: isFetchingEventAbi } =
useQuery<AbiResponse | null, Error>({
Copy link
Member

Choose a reason for hiding this comment

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

what you want here is useQueries - because that will let you create one query per chain+contract pair which means once you've fetched it once it can be cached even if you then add a second chain+contract pair, as it is now you are invalidating the query and refetching everything every time you add or remove a contract+chain pair

Comment on lines +179 to +184
const invalidAddresses = addresses.filter(
(addr) => !isValidAddress(addr),
);
if (invalidAddresses.length > 0) {
return null;
}
Copy link
Member

Choose a reason for hiding this comment

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

this silent filter feels weird, we should probably surface that something entered is not a valid contract address?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants