feat(ga-agent): Add GA Agent project with decomposed architecture
Create workspace for building Google Analytics Claude Skill with: - 5 independent components (MCP setup, skill, dimension explorer, Slack reporter, realtime watcher) - Comprehensive project plan and documentation - Step-by-step setup guides for each component Components: 1. MCP Setup - GA4 + BigQuery MCP server installation 2. GA Agent Skill - Core Claude Skill for interactive analysis 3. Dimension Explorer - Validate dims/metrics with explanations 4. Slack Reporter - Automated reports to Slack (P2) 5. Realtime Watcher - Real-time monitoring (deferred) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
160
ga-agent-project/04-slack-reporter/README.md
Normal file
160
ga-agent-project/04-slack-reporter/README.md
Normal file
@@ -0,0 +1,160 @@
|
||||
# Component 4: Slack Reporter
|
||||
|
||||
**Type:** Standalone Service
|
||||
**Priority:** P2
|
||||
**Status:** Not Started
|
||||
|
||||
## Goal
|
||||
|
||||
Automated GA4 reports delivered to Slack channels.
|
||||
|
||||
## Features
|
||||
|
||||
| Report | Schedule | Content |
|
||||
|--------|----------|---------|
|
||||
| Daily Summary | 9:00 AM | Users, sessions, top 5 pages |
|
||||
| Weekly Digest | Monday 9 AM | WoW comparison, trends |
|
||||
| Anomaly Alert | Real-time | Traffic ±30% from baseline |
|
||||
|
||||
## Structure
|
||||
|
||||
```
|
||||
04-slack-reporter/
|
||||
├── README.md
|
||||
├── config.yaml # Configuration
|
||||
├── reporter.py # Main service
|
||||
├── queries/
|
||||
│ ├── daily_summary.py
|
||||
│ ├── weekly_digest.py
|
||||
│ └── anomaly_check.py
|
||||
├── templates/
|
||||
│ └── slack_blocks.py # Slack Block Kit
|
||||
├── requirements.txt
|
||||
├── Dockerfile
|
||||
└── docker-compose.yml
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### config.yaml
|
||||
|
||||
```yaml
|
||||
slack:
|
||||
bot_token: ${SLACK_BOT_TOKEN}
|
||||
default_channel: "#analytics-reports"
|
||||
|
||||
ga4:
|
||||
property_id: "123456789"
|
||||
credentials_path: "/path/to/credentials.json"
|
||||
|
||||
reports:
|
||||
daily_summary:
|
||||
enabled: true
|
||||
schedule: "0 9 * * *" # 9 AM daily
|
||||
channel: "#analytics-reports"
|
||||
|
||||
weekly_digest:
|
||||
enabled: true
|
||||
schedule: "0 9 * * 1" # 9 AM Monday
|
||||
channel: "#analytics-reports"
|
||||
|
||||
anomaly_alert:
|
||||
enabled: true
|
||||
check_interval: 3600 # Check every hour
|
||||
threshold: 0.3 # 30% deviation
|
||||
channel: "#analytics-alerts"
|
||||
```
|
||||
|
||||
## Slack App Setup
|
||||
|
||||
1. Go to [api.slack.com/apps](https://api.slack.com/apps)
|
||||
2. Create New App → From scratch
|
||||
3. Add OAuth scopes:
|
||||
- `chat:write`
|
||||
- `files:write`
|
||||
- `channels:read`
|
||||
4. Install to workspace
|
||||
5. Copy Bot Token (`xoxb-...`)
|
||||
|
||||
## Dependencies
|
||||
|
||||
```
|
||||
# requirements.txt
|
||||
google-analytics-data>=0.18.0
|
||||
google-auth>=2.23.0
|
||||
slack-sdk>=3.23.0
|
||||
apscheduler>=3.10.0
|
||||
pandas>=2.0.0
|
||||
plotly>=5.18.0
|
||||
kaleido>=0.2.1
|
||||
pyyaml>=6.0
|
||||
```
|
||||
|
||||
## Slack Message Format
|
||||
|
||||
Using Block Kit for rich formatting:
|
||||
|
||||
```python
|
||||
def daily_summary_blocks(data: dict) -> list:
|
||||
return [
|
||||
{
|
||||
"type": "header",
|
||||
"text": {"type": "plain_text", "text": "📊 Daily GA4 Summary"}
|
||||
},
|
||||
{
|
||||
"type": "section",
|
||||
"fields": [
|
||||
{"type": "mrkdwn", "text": f"*Users:* {data['users']:,}"},
|
||||
{"type": "mrkdwn", "text": f"*Sessions:* {data['sessions']:,}"},
|
||||
{"type": "mrkdwn", "text": f"*Pageviews:* {data['pageviews']:,}"},
|
||||
{"type": "mrkdwn", "text": f"*Bounce Rate:* {data['bounce_rate']:.1%}"},
|
||||
]
|
||||
},
|
||||
{"type": "divider"},
|
||||
{
|
||||
"type": "section",
|
||||
"text": {"type": "mrkdwn", "text": "*Top Pages:*\n" + data['top_pages']}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
### Local Development
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Set environment variables
|
||||
export SLACK_BOT_TOKEN=xoxb-...
|
||||
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/creds.json
|
||||
|
||||
# Run
|
||||
python reporter.py
|
||||
```
|
||||
|
||||
### Docker
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Cloud Options
|
||||
|
||||
- Google Cloud Run (scheduled via Cloud Scheduler)
|
||||
- AWS Lambda + EventBridge
|
||||
- Railway / Render
|
||||
|
||||
## Checklist
|
||||
|
||||
- [ ] Slack App created
|
||||
- [ ] config.yaml template
|
||||
- [ ] daily_summary.py
|
||||
- [ ] weekly_digest.py
|
||||
- [ ] anomaly_check.py
|
||||
- [ ] slack_blocks.py templates
|
||||
- [ ] reporter.py scheduler
|
||||
- [ ] Dockerfile
|
||||
- [ ] Tested locally
|
||||
- [ ] Deployed
|
||||
Reference in New Issue
Block a user