-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(error-notifications): workspace-level configuration of slack, email, webhook notifications for workflow execution #2157
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
126a42c
feat(notification): slack, email, webhook notifications from logs
icecrasher321 5928b92
retain search params for filters to link in notification
icecrasher321 8e6c509
add alerting rules
icecrasher321 5d4bcdc
update selector
icecrasher321 3b8fad2
fix lint
icecrasher321 ed82ded
add limits on num of emails and notification triggers per workspace
icecrasher321 222bd4e
address greptile comments
icecrasher321 d0fdb86
add search to combobox
icecrasher321 4e14862
move notifications to react query
icecrasher321 0e58fae
fix lint
icecrasher321 a004934
fix email formatting
icecrasher321 6cd5707
add more alert types
icecrasher321 f0b525f
Merge branch 'staging' into feat/notifications-workflow-execs
icecrasher321 cfc1954
fix imports
icecrasher321 d63bb9e
fix test route
icecrasher321 cc5a165
Merge branch 'staging' into feat/notifications-workflow-execs
icecrasher321 30b0391
use emcn componentfor modal
icecrasher321 6d1ff0c
refactor: consolidate notification config fields into jsonb objects
icecrasher321 6c8019f
regen migration
icecrasher321 f09f2dc
fix delete notif modal ui
icecrasher321 909b349
make them multiselect dropdowns
icecrasher321 e35517f
update tag styling
icecrasher321 747e820
combobox font size with multiselect tags'
icecrasher321 64305ab
Merge staging into feat/notifications-workflow-execs
icecrasher321 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { db } from '@sim/db' | ||
| import { account } from '@sim/db/schema' | ||
| import { and, eq } from 'drizzle-orm' | ||
| import { type NextRequest, NextResponse } from 'next/server' | ||
| import { getSession } from '@/lib/auth' | ||
| import { createLogger } from '@/lib/logs/console/logger' | ||
|
|
||
| const logger = createLogger('AuthAccountsAPI') | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| try { | ||
| const session = await getSession() | ||
| if (!session?.user?.id) { | ||
| return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) | ||
| } | ||
|
|
||
| const { searchParams } = new URL(request.url) | ||
| const provider = searchParams.get('provider') | ||
|
|
||
| const whereConditions = [eq(account.userId, session.user.id)] | ||
|
|
||
| if (provider) { | ||
| whereConditions.push(eq(account.providerId, provider)) | ||
| } | ||
|
|
||
| const accounts = await db | ||
| .select({ | ||
| id: account.id, | ||
| accountId: account.accountId, | ||
| providerId: account.providerId, | ||
| }) | ||
| .from(account) | ||
| .where(and(...whereConditions)) | ||
|
|
||
| return NextResponse.json({ accounts }) | ||
| } catch (error) { | ||
| logger.error('Failed to fetch accounts', { error }) | ||
| return NextResponse.json({ error: 'Internal server error' }, { status: 500 }) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { nanoid } from 'nanoid' | ||
| import { type NextRequest, NextResponse } from 'next/server' | ||
| import { verifyCronAuth } from '@/lib/auth/internal' | ||
| import { acquireLock, releaseLock } from '@/lib/core/config/redis' | ||
| import { createLogger } from '@/lib/logs/console/logger' | ||
| import { pollInactivityAlerts } from '@/lib/notifications/inactivity-polling' | ||
|
|
||
| const logger = createLogger('InactivityAlertPoll') | ||
|
|
||
| export const maxDuration = 120 | ||
|
|
||
| const LOCK_KEY = 'inactivity-alert-polling-lock' | ||
| const LOCK_TTL_SECONDS = 120 | ||
|
|
||
| export async function GET(request: NextRequest) { | ||
| const requestId = nanoid() | ||
| logger.info(`Inactivity alert polling triggered (${requestId})`) | ||
|
|
||
| try { | ||
| const authError = verifyCronAuth(request, 'Inactivity alert polling') | ||
| if (authError) { | ||
| return authError | ||
| } | ||
|
|
||
| const locked = await acquireLock(LOCK_KEY, requestId, LOCK_TTL_SECONDS) | ||
|
|
||
| if (!locked) { | ||
| return NextResponse.json( | ||
| { | ||
| success: true, | ||
| message: 'Polling already in progress – skipped', | ||
| requestId, | ||
| status: 'skip', | ||
| }, | ||
| { status: 202 } | ||
| ) | ||
| } | ||
|
|
||
| const results = await pollInactivityAlerts() | ||
|
|
||
| return NextResponse.json({ | ||
| success: true, | ||
| message: 'Inactivity alert polling completed', | ||
| requestId, | ||
| status: 'completed', | ||
| ...results, | ||
| }) | ||
| } catch (error) { | ||
| logger.error(`Error during inactivity alert polling (${requestId}):`, error) | ||
| return NextResponse.json( | ||
| { | ||
| success: false, | ||
| message: 'Inactivity alert polling failed', | ||
| error: error instanceof Error ? error.message : 'Unknown error', | ||
| requestId, | ||
| }, | ||
| { status: 500 } | ||
| ) | ||
| } finally { | ||
| await releaseLock(LOCK_KEY).catch(() => {}) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.