Source:
ocean/docs/slack-setup-walkthrough.md| ✏️ Edit on GitHub
Slack Setup Step-by-Step Walkthrough
Follow these steps in order to set up Slack notifications for Ocean.
Part 1: Create Your Slack App (5 minutes)
Step 1: Go to Slack API
- Open your browser and go to: https://api.slack.com/apps
- Make sure you're logged into your Slack workspace
- Click the green "Create New App" button
Step 2: Choose App Creation Method
- Select "From scratch" (not from manifest)
- Fill in:
- App Name:
Ocean Alerts(or whatever you prefer) - Pick a workspace: Select your workspace from dropdown
- App Name:
- Click "Create App"
Step 3: You'll See Your App's Basic Information
- You should now be on the "Basic Information" page
- Keep this tab open, we'll come back to it
Part 2: Set Up Incoming Webhooks (5 minutes)
Step 1: Enable Incoming Webhooks
- In the left sidebar, click "Incoming Webhooks"
- Toggle the switch at the top to ON (it will turn green)
- You'll see new options appear below
Step 2: Create Your First Webhook
- Scroll down and click "Add New Webhook to Workspace"
- A new window will open asking where to post messages
- Select or create a channel called
#alerts-critical- If it doesn't exist, type
#alerts-criticalto create it
- If it doesn't exist, type
- Click "Allow"
Step 3: Copy Your First Webhook URL
-
You'll be redirected back to the webhooks page
-
You'll see your new webhook with a URL like:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXX -
Click "Copy" next to this URL
-
Save it somewhere safe (we'll need it soon)
Step 4: Create Additional Webhooks
Repeat Step 2-3 for these channels:
#alerts-errors- For application errors#alerts-performance- For slow queries, performance issues#alerts-analytics- For user events, signups, etc.
You should now have 4 webhook URLs saved.
Part 3: Create Slack Channels (2 minutes)
In your Slack workspace, create these channels if they don't exist:
- In Slack, click the "+" next to "Channels"
- Click "Create a channel"
- Create these channels:
#alerts-critical- For urgent issues#alerts-errors- For errors that need investigation#alerts-performance- For performance issues#alerts-analytics- For user activity#alerts-security- For security events (optional)
Part 4: Store Webhook URLs Locally (3 minutes)
Step 1: Create Environment File
-
In your Ocean project, create a file called
.env.localif it doesn't exist -
Add your webhook URLs:
# Slack Webhooks (for local testing)
SLACK_WEBHOOK_CRITICAL=https://hooks.slack.com/services/YOUR/CRITICAL/WEBHOOK
SLACK_WEBHOOK_ERRORS=https://hooks.slack.com/services/YOUR/ERRORS/WEBHOOK
SLACK_WEBHOOK_PERFORMANCE=https://hooks.slack.com/services/YOUR/PERFORMANCE/WEBHOOK
SLACK_WEBHOOK_ANALYTICS=https://hooks.slack.com/services/YOUR/ANALYTICS/WEBHOOK -
Replace the URLs with your actual webhook URLs from Part 2
Step 2: Test a Webhook
Let's make sure it works. Run this in your terminal:
curl -X POST -H 'Content-Type: application/json' \
-d '{"text":"🎉 Test message from Ocean setup!"}' \
YOUR_CRITICAL_WEBHOOK_URL
Replace YOUR_CRITICAL_WEBHOOK_URL with your actual webhook URL.
You should see the message appear in #alerts-critical in Slack!
Part 5: Add Webhooks to Supabase (5 minutes)
Step 1: Open Terminal in Your Project
cd /Users/t/Developer/ocean
Step 2: Set Production Secrets
Run these commands one by one, replacing with your actual webhook URLs:
supabase secrets set SLACK_WEBHOOK_CRITICAL="https://hooks.slack.com/services/YOUR/CRITICAL/WEBHOOK"
supabase secrets set SLACK_WEBHOOK_ERRORS="https://hooks.slack.com/services/YOUR/ERRORS/WEBHOOK"
supabase secrets set SLACK_WEBHOOK_PERFORMANCE="https://hooks.slack.com/services/YOUR/PERFORMANCE/WEBHOOK"
supabase secrets set SLACK_WEBHOOK_ANALYTICS="https://hooks.slack.com/services/YOUR/ANALYTICS/WEBHOOK"
Step 3: Deploy the Slack Alert Function
supabase functions deploy send-slack-alert
You should see:
✓ Function deployed successfully
Part 6: Test Your Integration (3 minutes)
Step 1: Test from Your App
Add this temporary code to test (you can put it in any component):
import { sendSlackAlert } from '@/lib/slack-alerts'
// Add this to a button click or useEffect
const testSlack = async () => {
const result = await sendSlackAlert({
type: 'test',
level: 'critical',
message: '🧪 Test alert from Ocean - Setup complete!',
details: {
user: 'Setup Test',
timestamp: new Date().toISOString(),
},
})
console.log('Slack test result:', result)
}
Step 2: Check Slack
You should see the test message in #alerts-critical
Part 7: Connect Sentry to Slack (5 minutes)
Step 1: Log into Sentry
- Go to your Sentry dashboard
- Click Settings (bottom left) → Integrations
Step 2: Install Slack Integration
- Search for "Slack" in the integrations list
- Click "Install" (or "Configure" if already installed)
- Click "Add Workspace"
- You'll be redirected to Slack to authorize
- Click "Allow"
Step 3: Create Your First Alert Rule
- Go to Alerts → Create Alert Rule
- Choose "Issue Alert"
- Configure:
- Alert name: "Critical Production Errors"
- Environment: Production
- When: An event is seen
- If: ALL of the following match:
- Level is Error or Fatal
- Environment equals production
- Then: Send a Slack notification to
#alerts-critical
- Click "Save Rule"
Step 4: Test Sentry Integration
Add this to your app to test:
Sentry.captureMessage('Test Sentry-Slack integration', {
level: 'error',
tags: { test: true },
})
Part 8: Connect PostHog to Slack (5 minutes)
Step 1: Log into PostHog
- Go to your PostHog dashboard
- Click Apps in the sidebar
Step 2: Install Slack App
- Search for "Slack"
- Click "Install"
- Configure:
- Webhook URL: Use your analytics webhook URL
- Click "Save"
Step 3: Create a User Signup Action
- Go to Data Management → Actions
- Click "New Action"
- Configure:
- Name: "New User Signup"
- Match event: Select "Match event name"
- Event name:
user_signed_up
- Click "Save"
- In the action settings, add:
- Post to webhook: Select your Slack webhook
- Message:
🎉 New user signed up: {person.email}
Part 9: Test Everything Together (5 minutes)
Test 1: Database Monitoring (pg_net)
-- Run this in Supabase SQL editor to trigger an alert
INSERT INTO monitoring.pg_net_health (
queue_size, response_size, status
) VALUES (
15000, 60000, 'critical'
);
Test 2: Application Error
// Add to your app temporarily
try {
throw new Error('Test critical error for Slack')
} catch (error) {
Sentry.captureException(error)
}
Test 3: Analytics Event
// Trigger a test signup event
posthog.capture('user_signed_up', {
email: 'test@example.com',
plan: 'test',
})
Part 10: Clean Up and Next Steps
Remove Test Code
Remove any test code you added to your app
Set Channel Settings
For each alert channel in Slack:
- Click the channel name → Settings → Edit
- Set topic: "Automated alerts - Do not post here manually"
- Pin a message with links to:
- This setup guide
- Sentry dashboard
- PostHog dashboard
- Supabase dashboard
Configure More Alerts
Now that basic setup is complete, you can:
- Add more Sentry alert rules
- Create more PostHog actions
- Set up custom alerts using the
sendSlackAlertfunction
Troubleshooting
"Invalid webhook URL"
- Make sure the URL starts with
https://hooks.slack.com/services/ - Check for extra spaces or quotes around the URL
"No messages in Slack"
-
Check Edge Function logs:
supabase functions logs send-slack-alert -
Verify secrets are set:
supabase secrets list
"Sentry not sending to Slack"
- Go to Sentry → Settings → Integrations → Slack
- Click "Test Configuration"
- Make sure your workspace is connected
Quick Reference Card
Save this for easy access:
// Send critical alert
import { sendCriticalAlert } from '@/lib/slack-alerts'
await sendCriticalAlert('Payment Failed', 'Stripe error', {
error_code: 'card_declined',
})
// Send performance alert
import { sendPerformanceAlert } from '@/lib/slack-alerts'
await sendPerformanceAlert('Slow query detected', {
metric: 'query_time',
value: 5000,
threshold: 1000,
})
// Send custom alert
import { sendSlackAlert } from '@/lib/slack-alerts'
await sendSlackAlert({
type: 'custom_event',
level: 'info',
message: 'Something happened',
channel: 'analytics',
})
You're Done! 🎉
Your Slack integration is now complete. You should be receiving:
- 🚨 Critical alerts for major issues
- ❌ Error notifications from Sentry
- 📊 Analytics events from PostHog
- 🐌 Performance alerts for slow queries
- 🗄️ Database monitoring alerts (pg_net)