{"id":42898348,"url":"https://github.com/overtrue/sentry-wework-bot","last_synced_at":"2026-01-30T15:17:06.479Z","repository":{"id":310600859,"uuid":"1040484615","full_name":"overtrue/sentry-wework-bot","owner":"overtrue","description":"Sentry 企业微信机器人 webhook 通知服务","archived":false,"fork":false,"pushed_at":"2025-09-13T15:20:15.000Z","size":48,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-19T12:37:02.387Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/overtrue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-19T03:56:36.000Z","updated_at":"2025-10-17T09:43:26.000Z","dependencies_parsed_at":"2025-08-19T06:17:31.749Z","dependency_job_id":"00307dce-2d2c-4cfa-a602-85677b77ed9c","html_url":"https://github.com/overtrue/sentry-wework-bot","commit_stats":null,"previous_names":["overtrue/sentry-wework-bot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/overtrue/sentry-wework-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fsentry-wework-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fsentry-wework-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fsentry-wework-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fsentry-wework-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/overtrue","download_url":"https://codeload.github.com/overtrue/sentry-wework-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/overtrue%2Fsentry-wework-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28914902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-30T15:17:05.636Z","updated_at":"2026-01-30T15:17:06.474Z","avatar_url":"https://github.com/overtrue.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sentry 到企业微信机器人 Webhook\n\n这是一个将 Sentry 通知转发到企业微信机器人的 webhook 服务，使用 Node.js 实现。\n\n## 功能特性\n\n- 接收 Sentry webhook 通知\n- 支持所有 Sentry webhook 类型：\n  - [**Issue Alerts** (`event_alert`) - 事件告警](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/event-alerts/)\n  - [**Metric Alerts** (`metric_alert`) - 指标告警](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/metric-alerts/)\n  - [**Issues** (`issue`) - 问题事件](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/issues/)\n  - [**Comments** (`comment`) - 评论](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/comments/)\n  - [**Errors** (`error`) - 错误](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/errors/)\n  - [**Installation** (`installation`) - 安装](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/installation/)\n- 自动格式化消息为企业微信机器人支持的卡片格式（template_card）\n- 模块化模板系统，易于维护和扩展\n- 支持签名验证\n- 支持指定群聊 ID\n- 健康检查端点\n\n## 安装和配置\n\n### 1. 安装依赖\n\n```bash\nnpm install\n```\n\n### 2. 配置环境变量\n\n复制 `env.example` 为 `.env` 并填写配置：\n\n```bash\ncp env.example .env\n```\n\n编辑 `.env` 文件：\n\n```env\n# 企业微信机器人配置\nWEWORK_WEBHOOK_URL=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_WEBHOOK_KEY\nWEWORK_CHAT_ID=your_chat_id\n\n# Sentry 配置\nSENTRY_WEBHOOK_SECRET=your_sentry_webhook_secret\nSENTRY_BASE_URL=https://sentry.io\n\n# 应用配置\nPORT=3000\nDEBUG=false\n\n# 模板配置\nSENTRY_ICON_URL=https://sentry.io/static/favicon-46f8676a36982f8eb852ac6860387755.ico\n```\n\n### 3. 获取企业微信机器人 webhook URL\n\n1. 在企业微信群中添加机器人\n2. 获取机器人的 webhook URL\n3. 将 URL 填入 `WEWORK_WEBHOOK_URL` 环境变量\n\n### 4. 获取群 ID（可选）\n\n如果需要发送到特定群聊，可以设置 `WEWORK_CHAT_ID`。\n\n## 运行服务\n\n```bash\n# 生产环境\nnpm start\n\n# 开发环境（自动重启）\nnpm run dev\n```\n\n服务将在 `http://localhost:3000` 启动（默认端口 3000，如果被占用会自动使用其他端口）。\n\n## 测试\n\n运行测试脚本来验证 webhook 功能：\n\n```bash\n# 基础测试（issue 类型）\nnpm test\n\n# 事件告警测试\nnpm run test:event-alert\n\n# 所有类型测试\nnpm run test:all\n```\n\n测试脚本会：\n1. 检查服务健康状态\n2. 发送模拟的 Sentry 数据到 webhook\n3. 验证响应\n4. 显示测试结果摘要\n\n## API 端点\n\n### POST /webhook\n\n接收 Sentry webhook 通知。\n\n**请求头要求：**\n- `Content-Type: application/json`\n- `Sentry-Hook-Signature`: 签名（如果配置了密钥）\n- `Sentry-Hook-Resource`: 资源类型\n- `Request-ID`: 请求 ID\n\n### GET /health\n\n健康检查端点。\n\n## Sentry 配置\n\n在 Sentry 中配置 webhook：\n\n1. 进入 Sentry 组织设置\n2. 选择 \"Integrations\" \u003e \"Integration Platform\"\n3. 创建新的 webhook 集成\n4. 设置 webhook URL 为：`http://your-domain.com/webhook`\n5. 配置需要的事件类型（issue、event_alert、metric_alert 等）\n\n## 模板系统\n\n项目使用模块化的模板系统，所有模板文件位于 `templates/` 目录中：\n\n- `templates/index.js` - 模板索引文件\n- `templates/issue.js` - 问题通知模板\n- `templates/event-alert.js` - 事件告警模板\n- `templates/metric-alert.js` - 指标告警模板\n- `templates/comment.js` - 评论通知模板\n- `templates/error.js` - 错误通知模板\n- `templates/installation.js` - 集成安装模板\n- `templates/generic.js` - 通用通知模板\n\n### 企业微信卡片格式\n\n所有通知都使用企业微信的 `template_card` 消息类型，提供：\n\n- 清晰的信息层次结构\n- 丰富的元数据显示\n- 可点击的链接和动作\n- 统一的视觉风格\n\n详细说明请参考：[templates/README.md](templates/README.md)\n\n## 消息格式示例\n\n### Issue Alert (事件告警) 示例\n\n企业微信卡片格式，包含：\n- 告警级别和触发规则\n- 事件ID和错误位置\n- 环境信息（浏览器、操作系统）\n- 可点击的详情链接\n\n### Metric Alert (指标告警) 示例\n\n企业微信卡片格式，包含：\n- 告警状态和操作类型\n- 规则名称和聚合方式\n- 查询条件和描述信息\n- 可点击的告警链接\n\n### Issue (问题) 示例\n\n企业微信卡片格式，包含：\n- 问题级别和操作类型\n- 项目名称和问题详情\n- 首次/最后出现时间和次数\n- 可点击的问题链接\n\n### Comment (评论) 示例\n\n企业微信卡片格式，包含：\n- 项目名称和操作类型\n- 评论者和问题标题\n- 评论内容预览\n- 可点击的问题链接\n\n### Error (错误) 示例\n\n企业微信卡片格式，包含：\n- 错误级别和操作类型\n- 事件ID和错误位置\n- 环境信息（浏览器、操作系统）\n- 可点击的错误链接\n\n## 部署\n\n### Docker 部署\n\n项目已包含 `Dockerfile`，构建和运行：\n\n```bash\ndocker build -t sentry-wework-bot .\ndocker run -p 5000:5000 --env-file .env sentry-wework-bot\n```\n\n### 使用 ngrok 进行本地测试\n\n```bash\n# 安装 ngrok\n# 启动服务\nnpm start\n\n# 在另一个终端启动 ngrok\nngrok http 3000\n\n# 使用 ngrok 提供的 URL 配置 Sentry webhook\n```\n\n## 故障排除\n\n### 常见问题\n\n1. **消息发送失败**\n   - 检查企业微信机器人 webhook URL 是否正确\n   - 确认机器人有发送消息的权限\n\n2. **签名验证失败**\n   - 检查 `SENTRY_WEBHOOK_SECRET` 是否与 Sentry 配置一致\n   - 如果不使用签名验证，可以留空\n\n3. **服务无法启动**\n   - 检查端口是否被占用\n   - 确认 Node.js 版本 \u003e= 22.0.0\n   - 确认所有依赖已正确安装：`npm install`\n\n### 日志\n\n服务会输出详细的日志信息，包括：\n- 接收到的 webhook 请求\n- 消息发送状态\n- 错误信息\n\n## 许可证\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Fsentry-wework-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovertrue%2Fsentry-wework-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovertrue%2Fsentry-wework-bot/lists"}