Repository navigation
Metabase analytics integration and security improvements - #262
Merged
Merged
Conversation
This PR implements a comprehensive membership and payment flow with integrated analytics, plus critical security fixes from code review. ## Analytics Integration - Embedded Metabase dashboard at /admin/analytics - Revenue tracking with SQL views for analytics - Sample data seeding script for testing - Three-tab admin navigation (Members, Agreements, Analytics) - Documentation in README.md and ANALYTICS.md Database views added: - revenue_summary: Total revenue and transaction metrics - customer_health: Subscription status and health indicators - subscription_metrics: Billing interval breakdown and trends ## Security Fixes (Critical) 1. **Admin authentication via environment variable** - Replaced hardcoded email domain with ADMIN_EMAILS env var - More flexible and secure admin access control - File: server/src/middleware/auth.ts 2. **SQL injection protection** - Added column name whitelist in updateOrganization() - Prevents injection through dynamic column names - File: server/src/db/organization-db.ts 3. **Structured logging** - Replaced all console.log/warn/error with structured logger - Eliminates JWT token logging risk - Better production logging with context objects - Files: server/src/billing/stripe-client.ts, server/src/http.ts 4. **Error handling for revenue tracking** - Added try-catch around revenue event insertions - Prevents webhook failures from cascading - File: server/src/http.ts (webhook handlers) ## Infrastructure Changes - Added Jest configuration for unit tests - Added billing/stripe-client tests - Added organization-db tests - Added webhook security tests - Metabase Docker Compose configuration - Database migrations for revenue tracking ## Testing - All 29 tests passing - TypeScript compilation successful - No secrets exposed in version control 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Resolved conflicts by keeping security fixes from membership-payment-flow branch: - Structured logging with Pino (stripe-client.ts, http.ts) - ADMIN_EMAILS environment variable (auth.ts, .env.local.example) - SQL injection protection (organization-db.ts) - Error handling for revenue tracking (http.ts) - Metabase analytics integration (README.md) Also preserved Security Requirements section from main branch in README.md.
bmilekic
pushed a commit
to bmilekic/adcp
that referenced
this pull request
Dec 5, 2025
…xtprotocol#262) This PR implements a comprehensive membership and payment flow with integrated analytics, plus critical security fixes from code review. ## Analytics Integration - Embedded Metabase dashboard at /admin/analytics - Revenue tracking with SQL views for analytics - Sample data seeding script for testing - Three-tab admin navigation (Members, Agreements, Analytics) - Documentation in README.md and ANALYTICS.md Database views added: - revenue_summary: Total revenue and transaction metrics - customer_health: Subscription status and health indicators - subscription_metrics: Billing interval breakdown and trends ## Security Fixes (Critical) 1. **Admin authentication via environment variable** - Replaced hardcoded email domain with ADMIN_EMAILS env var - More flexible and secure admin access control - File: server/src/middleware/auth.ts 2. **SQL injection protection** - Added column name whitelist in updateOrganization() - Prevents injection through dynamic column names - File: server/src/db/organization-db.ts 3. **Structured logging** - Replaced all console.log/warn/error with structured logger - Eliminates JWT token logging risk - Better production logging with context objects - Files: server/src/billing/stripe-client.ts, server/src/http.ts 4. **Error handling for revenue tracking** - Added try-catch around revenue event insertions - Prevents webhook failures from cascading - File: server/src/http.ts (webhook handlers) ## Infrastructure Changes - Added Jest configuration for unit tests - Added billing/stripe-client tests - Added organization-db tests - Added webhook security tests - Metabase Docker Compose configuration - Database migrations for revenue tracking ## Testing - All 29 tests passing - TypeScript compilation successful - No secrets exposed in version control 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a comprehensive membership and payment flow with integrated analytics, plus critical security fixes from code review.
Analytics Integration
/admin/analyticsDatabase Views Added
revenue_summary: Total revenue and transaction metricscustomer_health: Subscription status and health indicatorssubscription_metrics: Billing interval breakdown and trendsSecurity Fixes (Critical)
All issues identified during code review have been addressed:
1. Admin Authentication via Environment Variable
server/src/middleware/auth.tsADMIN_EMAILSenv var2. SQL Injection Protection
server/src/db/organization-db.tsupdateOrganization()method3. Structured Logging
server/src/billing/stripe-client.ts,server/src/http.tsconsole.log/warn/errorwith structured logger (50+ instances)4. Error Handling for Revenue Tracking
server/src/http.ts(webhook handlers)Infrastructure Changes
Testing
✅ All 29 tests passing
✅ TypeScript compilation successful
✅ No secrets exposed in version control
✅ Schema validation passed (146 schemas)
Documentation
Notes