Monitoring & Health
How to monitor the Client Portal platform and respond to common operational issues.
System Health Check
The check-data-readiness edge function provides a quick health check across core system components:
curl -X POST \
https://<supabase-url>/functions/v1/check-data-readiness \
-H "Authorization: Bearer <service-role-key>"
This checks:
- Database connectivity
- Key table row counts
- Edge function availability
- Integration token validity
Monitoring Dashboards
Supabase Dashboard
Access at https://supabase.com/dashboard/project/<project-id>.
Key sections to monitor:
| Section | What to Check |
|---|---|
| Database > Tables | Row counts for core tables (attorneys, sales_prospects, calls, sales_calls) |
| Database > Query Performance | Slow queries, missing indexes |
| Edge Functions > Logs | Function invocations, errors, response times |
| Auth > Users | Active user count, failed login attempts |
| Storage > Buckets | call-recordings bucket size and usage |
Edge Function Logs
Navigate to Supabase Dashboard > Edge Functions > select function > Logs.
Filter by:
- Status code -- Look for 4xx/5xx errors
- Duration -- Identify slow-running functions
- Timestamp -- Correlate with reported issues
Key Metrics to Watch
Webhook Success Rate
Monitor the ratio of successful webhook processing to total incoming webhooks.
Where to check: Query webhook_debug_log for recent entries:
-- Webhook success rate (last 24 hours)
SELECT
count(*) FILTER (WHERE status = 'success') AS successes,
count(*) FILTER (WHERE status = 'error') AS errors,
count(*) AS total
FROM webhook_debug_log
WHERE created_at > now() - interval '24 hours';
Healthy: >95% success rate. If errors spike, check edge function logs for the specific webhook handler.
AI Summarization Queue
Calls with transcripts >100 chars should have ai_summary populated within minutes.
-- Calls awaiting summarization (should be near zero)
SELECT count(*)
FROM sales_calls
WHERE transcript IS NOT NULL
AND length(transcript) > 100
AND ai_summary IS NULL
AND created_at > now() - interval '1 hour';
If this number is growing, check:
ANTHROPIC_API_KEYis still valid as a Supabase secretsummarize-sales-calledge function logs for errors- Anthropic API status page for outages
Calendar Token Expiration
OAuth tokens expire and need refreshing. Monitor for upcoming expirations:
-- Client calendar tokens expiring within 24 hours
SELECT client_id, provider, token_expires_at
FROM calendar_connections
WHERE token_expires_at < now() + interval '24 hours'
AND is_active = true;
-- Internal user calendar tokens expiring within 24 hours
SELECT user_id, provider, token_expires_at
FROM user_calendar_connections
WHERE token_expires_at < now() + interval '24 hours'
AND is_active = true;
Tokens are refreshed automatically during calendar operations, but if a client has not used the system in a while, their token may have expired without being refreshed.
Enrichment Credit Balance
Check remaining Blitz API credits:
curl -H "x-api-key: $BLITZ_API_KEY" https://api.blitz-api.ai/api/blitz/key-info
Healthy: Sufficient credits for planned enrichment runs. Budget 2--7 credits per attorney.
Common Alerts and Responses
Failed Webhooks
Symptom: Calls made in GHL are not appearing in Client Portal.
Diagnose:
- Check
webhook_debug_logfor recent entries with errors - Check edge function logs for
ghl-call-webhookandghl-sales-webhook - Verify GHL workflow is still active and pointing to the correct URL
Fix: Usually caused by edge function deployment issues or GHL API token expiry. Redeploy the function or update the token in ghl_integrations.
OAuth Token Expiry
Symptom: Calendar availability checks return errors. Booking pages show "unavailable."
Diagnose:
SELECT * FROM calendar_connections WHERE token_expires_at < now();
SELECT * FROM user_calendar_connections WHERE token_expires_at < now();
Fix: The client or user needs to re-authorize their calendar connection. Navigate to account settings and click the reconnect button. The OAuth callback will store fresh tokens.
Blitz API Rate Limiting
Symptom: Enrichment script returns 429 errors or empty responses.
Diagnose: Check the script output for rate limit warnings. Also check remaining credits via the key-info endpoint.
Fix:
- Wait 5--10 minutes for rate limits to reset
- Increase delay between requests if needed (current: 700ms between attorneys, 3s between firms)
- If credits are exhausted, contact Blitz API support or upgrade the plan
Edge Function Timeout
Symptom: Edge function returns 504 or function logs show timeout.
Diagnose: Check function logs for the specific function. Edge functions have a default timeout of 60 seconds.
Fix:
- For long-running operations, break them into smaller batches
- Check if the function is waiting on an unresponsive external API
- Verify the function is not caught in an infinite loop
Health Check Schedule
| Check | Frequency | How |
|---|---|---|
| Webhook success rate | Daily | Query webhook_debug_log |
| AI summarization queue | Daily | Query sales_calls for unsummarized calls |
| Calendar token expiry | Weekly | Query both calendar connection tables |
| Enrichment credit balance | Before each enrichment run | Blitz API key-info endpoint |
| Edge function error rate | Weekly | Supabase dashboard edge function logs |
| Database size | Monthly | Supabase dashboard database metrics |