heymegabyte/agent-skills / 13-observability-and-growth
observability-and-growth
VerifiedFull instrumentation from day one. PostHog consolidates product analytics + feature flags + error tracking (one platform, one bill). GA4 via GTM (14-step automation, custom dimensions over events, server-side tagging). Sentry (deep error tracking + performance). Stripe (webhook-first with idempotent processing). Listmonk on Coolify (newsletters via Amazon SES SMTP relay). PLG 7-layer framework. Programmatic SEO (5 page types). Incident auto-remediation via Sentry→Inngest pipeline. AI search (GEO) awareness. Local business conversions (phone_click, direction_click, form_submit, booking_click) with CRO patterns for both SaaS and local.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.8 KB |
| activation-funnel.md | markdown | 11.0 KB |
| analytics-configuration.md | markdown | 7.2 KB |
| conversion-optimization.md | markdown | 4.9 KB |
| email-marketing-and-listmonk.md | markdown | 8.1 KB |
| feature-flags-and-experiments.md | markdown | 6.6 KB |
| mcp-server-registry.md | markdown | 15.0 KB |
| sentry-alert-rules.md | markdown | 8.7 KB |
| square-payments.md | markdown | 13.3 KB |
| stripe-billing.md | markdown | 9.8 KB |
| user-feedback-collection.md | markdown | 8.9 KB |
| workers-tracing-otlp.md | markdown | 3.0 KB |
sentry-alert-rules.md
View on GitHub---
name: "Sentry Alert Rules"
description: "Auto-configure Sentry alert rules at first deploy. Error spike detection, new issue alerts, unhandled rejection tracking, P95 latency monitoring, Slack integration, per-project rules, and deploy silence windows. All via Sentry API."
updated: "2026-04-23"
---
# Sentry Alert Rules
Four alert rules auto-created at first deploy, per-project (not global). All alerts route to Slack `#emdash-alerts`.
## Alert Rule Set
### 1. Error Spike (Critical)
Fires when error rate exceeds 5x baseline within a 5-minute window.
```json
{
"name": "[{project}] Error Spike",
"actionMatch": "all",
"filterMatch": "all",
"frequency": 300,
"conditions": [{
"id": "sentry.rules.conditions.event_frequency.EventFrequencyPercentCondition",
"interval": "5m",
"value": 500,
"comparisonType": "percent",
"comparisonInterval": "1h"
}],
"actions": [{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"workspace": "{slack_workspace_id}",
"channel": "#emdash-alerts",
"tags": "environment,release,url"
}],
"environment": "production"
}
```
### 2. New Issue (Low Priority)
First occurrence of any new error; grouped so repeat triggers don't spam.
```json
{
"name": "[{project}] New Issue",
"actionMatch": "all",
"filterMatch": "all",
"frequency": 1800,
"conditions": [{
"id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition"
}],
"filters": [{
"id": "sentry.rules.filters.level.LevelFilter",
"match": "gte",
"level": "warning"
}],
"actions": [{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"workspace": "{slack_workspace_id}",
"channel": "#emdash-alerts",
"tags": "environment,browser,os"
}],
"environment": "production"
}
```
### 3. Unhandled Rejection (High Priority)
Any unhandled promise rejection or uncaught exception.
```json
{
"name": "[{project}] Unhandled Rejection",
"actionMatch": "all",
"filterMatch": "all",
"frequency": 60,
"conditions": [{
"id": "sentry.rules.conditions.every_event.EveryEventCondition"
}],
"filters": [{
"id": "sentry.rules.filters.tagged_event.TaggedEventFilter",
"key": "mechanism",
"match": "eq",
"value": "unhandledrejection"
}],
"actions": [{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"workspace": "{slack_workspace_id}",
"channel": "#emdash-alerts",
"tags": "environment,url,release"
}],
"environment": "production"
}
```
### 4. P95 Latency (Warning)
P95 response time exceeds 500ms for 10 consecutive minutes.
```json
{
"name": "[{project}] P95 Latency",
"dataset": "transactions",
"aggregate": "p95(transaction.duration)",
"query": "",
"timeWindow": 10,
"triggers": [{
"label": "critical",
"alertThreshold": 500,
"actions": [{
"type": "slack",
"targetIdentifier": "#emdash-alerts",
"integrationId": "{slack_integration_id}"
}]
}, {
"label": "resolved",
"alertThreshold": 300,
"actions": [{
"type": "slack",
"targetIdentifier": "#emdash-alerts",
"integrationId": "{slack_integration_id}"
}]
}],
"environment": "production"
}
```
## API Configuration
All rules created via Sentry API. Base URL: `https://sentry.megabyte.space` (self-hosted).
### Create Issue Alert
```bash
curl -X POST "https://sentry.megabyte.space/api/0/projects/{org}/{project}/rules/" \
-H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{...rule JSON...}'
```
### Create Metric Alert (P95 Latency)
```bash
curl -X POST "https://sentry.megabyte.space/api/0/projects/{org}/{project}/alert-rules/" \
-H "Authorization: Bearer $SENTRY_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{...metric alert JSON...}'
```
Issue alerts → `/rules/`. Metric alerts → `/alert-rules/`. Different endpoints.
## Slack Integration Setup
```bash
# 1. Get integration ID (one-time, reuse across projects)
curl "https://sentry.megabyte.space/api/0/organizations/{org}/integrations/?provider_key=slack" \
-H "Authorization: Bearer $SENTRY_AUTH_TOKEN"
# 2. Extract integrationId and workspace ID from response
# 3. Use in alert rule actions
```
Slack app must be installed in workspace first via **Sentry Settings → Integrations → Slack**.
## Orchestration Function
```typescript
async function configureSentryAlerts(project: string, org: string = 'emdash'): Promise<void> {
const baseUrl = 'https://sentry.megabyte.space/api/0';
const headers = {
'Authorization': `Bearer ${env.SENTRY_AUTH_TOKEN}`,
'Content-Type': 'application/json',
};
// Get Slack integration ID (cached after first call)
const integrations = await fetch(`${baseUrl}/organizations/${org}/integrations/?provider_key=slack`, { headers });
const slackIntegration = (await integrations.json())[0];
const slackId = slackIntegration.id;
const workspaceId = slackIntegration.externalId;
// Create all 4 rules in parallel
const issueRulesUrl = `${baseUrl}/projects/${org}/${project}/rules/`;
const metricRulesUrl = `${baseUrl}/projects/${org}/${project}/alert-rules/`;
await Promise.all([
fetch(issueRulesUrl, { method: 'POST', headers, body: JSON.stringify(errorSpikeRule(project, workspaceId)) }),
fetch(issueRulesUrl, { method: 'POST', headers, body: JSON.stringify(newIssueRule(project, workspaceId)) }),
fetch(issueRulesUrl, { method: 'POST', headers, body: JSON.stringify(unhandledRejectionRule(project, workspaceId)) }),
fetch(metricRulesUrl, { method: 'POST', headers, body: JSON.stringify(p95LatencyRule(project, slackId)) }),
]);
}
```
## Deploy Silence Windows
Suppress alerts during deploys to avoid false positives from cold starts and transient errors:
```typescript
async function silenceDuringDeploy(project: string, durationMinutes: number = 10): Promise<string> {
const baseUrl = 'https://sentry.megabyte.space/api/0';
const now = new Date();
const until = new Date(now.getTime() + durationMinutes * 60000);
// Mute all alert rules for the project during deploy window
const rules = await fetch(`${baseUrl}/projects/emdash/${project}/rules/`, {
headers: { 'Authorization': `Bearer ${env.SENTRY_AUTH_TOKEN}` },
});
const ruleList = await rules.json();
for (const rule of ruleList) {
await fetch(`${baseUrl}/projects/emdash/${project}/rules/${rule.id}/snooze/`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${env.SENTRY_AUTH_TOKEN}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ target: 'everyone', until: until.toISOString() }),
});
}
return until.toISOString();
}
```
### Deploy flow integration
1. `silenceDuringDeploy(project, 10)` — mute alerts
2. `wrangler deploy` — deploy Worker
3. Purge CDN cache — clear stale responses
4. E2E tests on prod — verify
5. Alerts auto-unmute after window — resume monitoring
## Per-Project Isolation
Every project gets its own alert rule set. Never use organization-wide rules — they cause noise from unrelated projects.
**Naming convention** — `[{project}] {Alert Name}` — square brackets enable easy filtering in Slack.
When a project is decommissioned, delete its alert rules:
```bash
# List and delete all rules for a project
curl "https://sentry.megabyte.space/api/0/projects/{org}/{project}/rules/" \
-H "Authorization: Bearer $SENTRY_AUTH_TOKEN" | \
jq '.[].id' | xargs -I{} curl -X DELETE \
"https://sentry.megabyte.space/api/0/projects/{org}/{project}/rules/{}/" \
-H "Authorization: Bearer $SENTRY_AUTH_TOKEN"
```
## Sentry SDK Setup (v10.50+ — Hono + Bun)
```typescript
// src/instrument.ts — dedicated @sentry/hono/bun entry point (Apr 2026)
import * as Sentry from '@sentry/hono/bun';
Sentry.init({
dsn: 'https://KEY@sentry.megabyte.space/ID',
environment: 'production',
tracesSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
release: env.VERSION,
integrations: [
Sentry.viewHierarchyIntegration(), // v10.50: DOM capture on error
],
});
// Apply to Hono app
import { sentryMiddleware } from '@sentry/hono';
app.use('*', sentryMiddleware());
```
### DO Alarm Tracing (v10.49)
```typescript
// Durable Object alarms auto-traced by Sentry v10.49+
// No extra config — alarm() calls get spans + error capture
```
### WorkerEntrypoint Support (v10.48)
```typescript
// Service bindings auto-instrumented via WorkerEntrypoint class
// import { WorkerEntrypoint } from 'cloudflare:workers';
// Sentry traces cross-worker calls automatically
```
Minimum version: `@sentry/hono@10.50.0` + `@sentry/bun@10.50.0`. Replaces `toucan-js` for new projects.
## Integration with 08-deploy Skill
After every first deploy, auto-run `configureSentryAlerts(projectSlug)`. Deploy skill creates rules if missing; subsequent deploys only trigger silence windows.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |