-
Notifications
You must be signed in to change notification settings - Fork 543
Add webhook API functions for insight dashboard #7171
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
Add webhook API functions for insight dashboard #7171
Conversation
|
WalkthroughA new module, Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant WebhooksModule
participant ThirdwebInsightAPI
Client->>WebhooksModule: createWebhook(payload, clientId)
WebhooksModule->>ThirdwebInsightAPI: POST /webhooks (with auth & payload)
ThirdwebInsightAPI-->>WebhooksModule: WebhookSingleResponse
WebhooksModule-->>Client: WebhookSingleResponse
Client->>WebhooksModule: getWebhooks(clientId)
WebhooksModule->>ThirdwebInsightAPI: GET /webhooks (with auth & clientId)
ThirdwebInsightAPI-->>WebhooksModule: WebhooksListResponse
WebhooksModule-->>Client: WebhooksListResponse
Client->>WebhooksModule: deleteWebhook(webhookId, clientId)
WebhooksModule->>ThirdwebInsightAPI: DELETE /webhooks/{webhookId} (with auth & clientId)
ThirdwebInsightAPI-->>WebhooksModule: WebhookSingleResponse
WebhooksModule-->>Client: WebhookSingleResponse
Client->>WebhooksModule: testWebhook(payload, clientId)
WebhooksModule->>ThirdwebInsightAPI: POST /webhooks/test (with auth & payload)
ThirdwebInsightAPI-->>WebhooksModule: TestWebhookResponse
WebhooksModule-->>Client: TestWebhookResponse
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7171 +/- ##
=======================================
Coverage 55.66% 55.66%
=======================================
Files 904 904
Lines 58400 58400
Branches 4116 4116
=======================================
Hits 32510 32510
Misses 25784 25784
Partials 106 106
🚀 New features to boost your workflow:
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (2)
apps/dashboard/src/@/api/insight/webhooks.ts (2)
43-67
: Consider validating webhook URLs at runtime.The interfaces are well-defined, but consider adding runtime validation for webhook URLs to ensure they're valid HTTPS endpoints for security.
// Add URL validation utility function isValidWebhookUrl(url: string): boolean { try { const parsed = new URL(url); return parsed.protocol === 'https:'; } catch { return false; } }
75-83
: Consider adding request timeout and authentication error handling.All API functions could benefit from enhanced error handling and timeout configuration.
// Add timeout and better error categorization const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), 10000); // 10s timeout const response = await fetch(url, { ...options, signal: controller.signal, }); clearTimeout(timeoutId); // Add specific handling for authentication errors if (response.status === 401) { return { data: null, // or appropriate default error: 'Authentication failed. Please check your credentials.', }; }Also applies to: 107-113, 138-147, 172-183
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/dashboard/src/@/api/insight/webhooks.ts
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/dashboard/src/@/api/insight/webhooks.ts (2)
apps/dashboard/src/app/(app)/api/lib/getAuthToken.ts (1)
getAuthToken
(6-14)apps/dashboard/src/constants/urls.ts (1)
THIRDWEB_INSIGHT_API_DOMAIN
(24-25)
🔇 Additional comments (2)
apps/dashboard/src/@/api/insight/webhooks.ts (2)
1-4
: LGTM! Good server-side setup and imports.The "use server" directive correctly indicates server-side execution, and the imports are appropriate for the functionality.
6-41
: Well-structured interface definitions.The TypeScript interfaces are comprehensive and properly typed. The optional properties in
WebhookFilters
provide good flexibility for different filtering scenarios.
0b15d5e
to
c1575f6
Compare
c1575f6
to
7fe7b9f
Compare
7fe7b9f
to
d189687
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx (1)
1-2
: Consider removing or updating the temporary comment.The comment indicates this is temporary code to suppress linting errors. If this is intended for production, consider removing this comment or updating it to reflect the current implementation status.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/dashboard/src/@/api/insight/webhooks.ts
(1 hunks)apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/dashboard/src/@/api/insight/webhooks.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx (1)
apps/dashboard/src/@/api/insight/webhooks.ts (1)
getWebhooks
(104-132)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Build Packages
- GitHub Check: Size
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx
Show resolved
Hide resolved
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx
Show resolved
Hide resolved
Merge activity
|
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces functionality for managing webhooks in the application. It includes a temporary `WebhooksPage` for displaying webhook data and implements several API functions for creating, retrieving, deleting, and testing webhooks. ### Detailed summary - Added `WebhooksPage` component in `page.tsx` to display webhook data. - Implemented `getWebhooks` function to fetch webhooks from the API. - Created interfaces for webhook responses and payloads. - Added `createWebhook`, `deleteWebhook`, and `testWebhook` functions for managing webhooks. - Handled API errors with appropriate responses. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced the ability to create, view, delete, and test webhooks through the dashboard interface, allowing users to manage webhook integrations more easily. - Added a new dashboard page displaying webhook data for better visibility and management. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
d189687
to
a5d6e76
Compare
PR-Codex overview
This PR introduces a temporary
WebhooksPage
component and expands thewebhooks
API with several interfaces and functions for managing webhooks, including creating, retrieving, deleting, and testing webhooks.Detailed summary
WebhooksPage
inapps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/page.tsx
.apps/dashboard/src/@/api/insight/webhooks.ts
.createWebhook
,getWebhooks
,deleteWebhook
, andtestWebhook
functions for webhook management.Summary by CodeRabbit