# Future Enhancements - "Shit We Might Want to Do Some Day"

**Status**: Backlog / Nice-to-Have
**Priority**: Post-MVP
**Created**: 2025-10-24

This document captures ideas, enhancements, and features that would be valuable but are not critical for MVP launch. Review periodically to prioritize based on customer feedback and business needs.

---

## Email Validation Enhancements

### Backend Email Validation Service

**What**: Move email validation from frontend to backend for better control and zero bundle size impact.

**Why Not MVP**:
- Frontend validation with lightweight library (~2-3 KB) is sufficient for MVP
- Backend adds complexity without significant user benefit for initial launch
- Can be added later without breaking changes

**Implementation** (when ready):

**Location**: `apps/proxy-server/api/validate-email.js` (Tavus Proxy Server on Vercel)

**Packages**:
```bash
pnpm add mailchecker @myselfraj/is-business-mail
```

**Endpoint**:
```javascript
// POST /api/validate-email
export default async function handler(req, res) {
  const { email, config } = req.body;

  // 1. Format validation
  if (!isEmail(email)) {
    return res.status(400).json({ valid: false, error: 'invalid_format' });
  }

  // 2. Disposable email check
  if (config?.blockDisposable && !mailchecker.isValid(email)) {
    return res.status(400).json({ valid: false, error: 'disposable_email' });
  }

  // 3. Business email requirement
  if (config?.requireBusinessEmail && !isBusinessMail(email)) {
    return res.status(400).json({ valid: false, error: 'free_email_provider' });
  }

  return res.status(200).json({ valid: true });
}
```

**Benefits**:
- Zero frontend bundle size impact
- Centralized validation logic
- Can update disposable email list without redeploying frontend
- Customer-specific rules stored on backend
- Can rate limit validation requests

**Effort**: 2-4 hours
**Priority**: Low (only if bundle size becomes issue)

---

### Advanced Email Validation

**Features**:
1. **SMTP Validation** - Check if email actually exists (MX record lookup, SMTP handshake)
2. **Domain Reputation** - Score email domains by trustworthiness
3. **Typo Detection** - Suggest corrections (gmail.con → gmail.com)
4. **Role Account Detection** - Flag info@, admin@, noreply@ addresses
5. **Catch-all Domain Detection** - Detect domains that accept all emails

**Packages**:
- `deep-email-validator` - SMTP + DNS checks
- `mailcheck` (Kicksend) - Typo suggestions
- `email-spell-checker` - Domain corrections

**Why Not MVP**:
- SMTP validation is slow (500ms-2s) and can fail
- Adds significant complexity
- Most customers don't need this level of validation
- Can cause false positives (valid emails rejected)

**Effort**: 8-16 hours
**Priority**: Low (niche use case)

---

## Gating Form Enhancements

### Complete Language Support (27 Remaining Languages)

**What**: Add translations for all 32 Tavus-supported languages.

**Current**: 5 languages (en, no, de, es, fr)
**Future**: All 32 languages

**Remaining Languages** (27):
- Portuguese (pt), Chinese (zh), Japanese (ja), Hindi (hi), Italian (it)
- Korean (ko), Dutch (nl), Polish (pl), Russian (ru), Swedish (sv)
- Turkish (tr), Indonesian (id), Filipino (fil), Bulgarian (bg), Romanian (ro)
- Arabic (ar), Czech (cs), Greek (el), Finnish (fi), Croatian (hr)
- Malay (ms), Slovak (sk), Danish (da), Tamil (ta), Ukrainian (uk)
- Hungarian (hu), Vietnamese (vi)

**Implementation**:
```typescript
// Add to libs/gating/src/lib/i18n/translations.ts
export const translations = {
  // ... existing 5 languages ...
  pt: { translation: { /* Portuguese translations */ } },
  zh: { translation: { /* Chinese translations */ } },
  // ... etc.
};
```

**Translation Sources**:
- Professional translation service (recommended)
- Google Translate (initial draft, then review)
- Native speakers (highest quality)
- i18next integration services (Locize, Crowdin)

**Why Not MVP**: 5 languages cover majority of customers initially.

**Effort**: 16-24 hours (including review/QA)
**Priority**: Medium (add based on customer demand per language)

---

### Webhook Lead Submission

**What**: Implement webhook submission for lead data.

**Current**: Supabase-only storage
**Future**: Webhook + Both options working

**Implementation**:
```typescript
// Already scaffolded in libs/gating/src/lib/supabase/submit-lead.ts
// Just needs testing and activation

storage: {
  destination: 'webhook',  // or 'both'
  webhookUrl: 'https://api.customer.com/leads'
}
```

**Features**:
- POST lead data to customer's webhook URL
- Retry logic with exponential backoff
- Webhook signature verification (HMAC)
- Error handling and logging

**Why Not MVP**: Supabase storage sufficient for initial customers.

**Effort**: 4-8 hours (core already implemented, needs testing + retry logic)
**Priority**: Medium (B2B customers may require webhooks)

---

### Custom Validation Rules

**What**: Allow customers to define custom validation rules per field.

**Example**:
```typescript
emailValidation: {
  blockFreeProviders: true,
  customBlockedDomains: ['competitor.com', 'spam.net'],
  customValidator: (email) => {
    // Custom logic: only allow .edu emails
    return email.endsWith('.edu');
  }
}
```

**Why Not MVP**: Built-in validation covers 95% of use cases.

**Effort**: 4-8 hours
**Priority**: Low (wait for specific customer requests)

---

### Conditional Field Display

**What**: Show/hide fields based on other field values.

**Example**:
```typescript
{
  field: 'company',
  showIf: (formData) => formData.email && !isFreeEmailProvider(formData.email)
}
```

**Why Not MVP**: Adds complexity, most forms have static fields.

**Effort**: 8-16 hours
**Priority**: Low (advanced use case)

---

### Multi-Step Forms

**What**: Split long forms into multiple steps/pages.

**Example**:
```typescript
steps: [
  { fields: ['email'], title: 'Get Started' },
  { fields: ['name', 'company'], title: 'About You' },
  { fields: ['phone'], title: 'Final Step' }
]
```

**Why Not MVP**: Single-step forms convert better for MVP.

**Effort**: 16-24 hours
**Priority**: Low (only if customers request)

---

### Progressive Profiling

**What**: Show different fields based on user's previous interactions.

**Example**:
- First visit: Only email required
- Return visit: Ask for name and company
- Third visit: Ask for phone number

**Implementation**:
```typescript
interface ProgressiveGatingConfig {
  stages: Array<{
    visit: number;
    fields: Array<'name' | 'email' | 'phone' | 'company'>;
  }>;
}
```

**Why Not MVP**: Adds complexity without clear ROI for initial customers.

**Effort**: 4-8 hours
**Priority**: Medium (could increase conversion)

---

### Social Login Integration

**What**: Allow "Sign in with Google/LinkedIn" instead of form.

**Benefits**:
- Faster conversion (1 click vs. form)
- Pre-filled, accurate data
- Higher quality leads (verified accounts)

**Libraries**:
- `@react-oauth/google`
- `react-linkedin-login-oauth2`

**Why Not MVP**: Requires OAuth setup, privacy policy updates, data handling changes.

**Effort**: 8-16 hours
**Priority**: Medium (B2B customers may want this)

---

### Form Analytics

**What**: Track form interaction metrics.

**Metrics**:
- Field focus time
- Drop-off rates per field
- Validation error frequency
- Time to complete
- A/B test results

**Why Not MVP**: Nice-to-have data, not critical for launch.

**Effort**: 4-8 hours
**Priority**: Low (analytics can wait)

---

## i18n Enhancements

### Translation Management Platform Integration

**What**: Integrate with translation management platforms for easier updates.

**Platforms**:
- **Locize** - i18next official partner, real-time updates
- **Crowdin** - Collaborative translation, version control
- **Phrase** - Professional translation workflows
- **POEditor** - Simple key-based translation editor

**Benefits**:
- Non-technical users can update translations
- Professional translators can contribute
- Track translation completion %
- A/B test different translations
- Update without code deployments

**Implementation**:
```typescript
// With Locize backend plugin
import Backend from 'i18next-locize-backend';

i18next.use(Backend).init({
  backend: {
    projectId: 'abc123',
    apiKey: 'xyz789'
  }
});
```

**Why Not MVP**: Static translations files sufficient initially.

**Effort**: 4-8 hours (integration) + platform setup
**Priority**: Low (only after scaling to many languages)

---

### Automatic Language Detection

**What**: Detect user's browser language and auto-select gating form language.

**Implementation**:
```typescript
const userLanguage = navigator.language.split('-')[0]; // 'en', 'no', 'de'
const supportedLanguage = supportedLanguages.includes(userLanguage)
  ? userLanguage
  : 'en'; // fallback

BuzzTrail.init({
  language: supportedLanguage
});
```

**Why Not MVP**: Customer specifies language in config (they know their audience).

**Effort**: 1-2 hours
**Priority**: Low (trivial to add later)

---

### Region-Specific Variants

**What**: Support regional language variants (es-ES vs es-MX, en-US vs en-GB).

**Example**:
```typescript
language: 'es-MX' // Mexican Spanish
language: 'es-ES' // Spain Spanish
```

**Why Not MVP**: Generic language codes sufficient for MVP (Tavus handles variants).

**Effort**: 4-8 hours (requires translation effort)
**Priority**: Low (wait for customer demand)

---

### Lazy-Loading Translations

**What**: Load translation files on-demand instead of bundling all 32 languages.

**Implementation**:
```typescript
// Load translation file dynamically
const translation = await import(`./i18n/${language}.json`);
i18next.addResourceBundle(language, 'translation', translation);
```

**Benefits**:
- Smaller initial bundle
- Only load languages actually used

**Why Not MVP**:
- All 32 languages together are only ~50-100 KB gzipped
- Adds complexity (async loading, loading states)
- Not worth the effort for MVP

**Effort**: 4-8 hours
**Priority**: Low (only if bundle size becomes issue)

---

## Configuration Management

### Customer Dashboard

**What**: Web UI for customers to manage their BuzzTrail configuration.

**Features**:
- Edit gating form fields
- Customize labels/translations
- Configure email validation rules
- View lead analytics
- Test configuration live

**Why Not MVP**:
- Customers can use JavaScript config for MVP
- Dashboard requires auth, backend, database
- Significant engineering effort

**Effort**: 40-80 hours (full feature)
**Priority**: Medium (customer request after MVP)

---

### Configuration API

**What**: REST API to fetch customer configuration from backend.

**Current**: Config hardcoded in JavaScript
**Future**: Fetch from API

```typescript
// Instead of:
BuzzTrail.init({ customerId: 'norsk-unloc', /* hardcoded config */ });

// Fetch config:
const config = await fetch(`${API_URL}/config/norsk-unloc`);
BuzzTrail.init(config);
```

**Benefits**:
- Update config without redeploying website
- Centralized configuration management
- A/B testing different configs

**Why Not MVP**:
- Hardcoded config is simpler for MVP
- Requires backend API, database schema
- Customers can embed config in their code initially

**Effort**: 8-16 hours
**Priority**: Medium (useful after multiple customers)

---

## Storage Enhancements

### Duplicate Lead Detection

**What**: Detect and handle duplicate form submissions.

**Strategies**:
1. **Email-based**: Prevent same email submitting multiple times
2. **Session-based**: One submission per browser session
3. **Time-based**: Limit submissions within timeframe (e.g., 1 hour)
4. **Fingerprint-based**: Browser fingerprinting for anonymous detection

**Implementation**:
```typescript
duplicateDetection: {
  method: 'email' | 'session' | 'time' | 'fingerprint',
  action: 'block' | 'warn' | 'allow',
  timeWindow?: '1h' | '24h' | '7d'
}
```

**Why Not MVP**: Not a common problem initially, can add when reported.

**Effort**: 8-16 hours
**Priority**: Low (reactive based on customer feedback)

---

### Lead Export Functionality

**What**: Allow customers to export collected leads.

**Formats**:
- CSV export
- Excel (XLSX) export
- JSON export
- Webhook batch delivery

**Implementation**:
```typescript
// Backend endpoint
GET /api/customers/:customerId/leads/export?format=csv&from=2025-01-01

// Returns downloadable file
```

**Why Not MVP**: Customers can query Supabase directly for MVP.

**Effort**: 8-16 hours
**Priority**: Medium (customer convenience feature)

---

### Webhook Retry Logic

**What**: Retry webhook deliveries on failure with exponential backoff.

**Current**: Single attempt, fail silently
**Future**: Retry up to 3 times with delays (1s, 5s, 15s)

**Why Not MVP**:
- Supabase storage more reliable for MVP
- Webhooks are optional feature
- Can add retry logic when customers request webhooks

**Effort**: 4-8 hours
**Priority**: Low (wait for webhook adoption)

---

### Webhook Signatures

**What**: Sign webhook payloads so customers can verify authenticity.

**Implementation**:
```typescript
const signature = hmac('sha256', webhookSecret, JSON.stringify(payload));
headers['X-BuzzTrail-Signature'] = signature;
```

**Why Not MVP**: Security feature, not critical for initial launch.

**Effort**: 2-4 hours
**Priority**: Low (add when enterprise customers request)

---

### Lead Enrichment

**What**: Automatically enrich lead data with company information.

**Services**:
- Clearbit
- FullContact
- Hunter.io

**Example**:
```typescript
// User submits: john@acme.com
// Enrichment adds:
{
  email: 'john@acme.com',
  company: 'Acme Corporation',
  industry: 'Software',
  size: '100-500 employees',
  location: 'San Francisco, CA'
}
```

**Why Not MVP**:
- Costs money (API fees)
- Adds latency
- Privacy concerns (GDPR)
- Not all customers want enrichment

**Effort**: 8-16 hours
**Priority**: Low (enterprise feature, wait for demand)

---

## Browser Compatibility Enhancements

### Runtime Feature Detection

**What**: Detect browser capabilities at runtime and show warnings.

**Current**: Documentation only
**Future**: Check features and alert user

```typescript
const capabilities = checkBrowserCompatibility();
if (!capabilities.isSupported) {
  showUnsupportedBrowserMessage(capabilities.issues);
}
```

**Why Not MVP**:
- Browserslist + ESLint catches issues at build time
- Modern browsers (last 2 versions) all support required features
- Adds ~5-10 KB for detection logic

**Effort**: 4-8 hours (see 170-browser-compatibility-strategy.md)
**Priority**: Low (very few users on unsupported browsers)

---

## Performance Enhancements

### Service Worker Caching

**What**: Cache BuzzTrail package in service worker for offline support.

**Benefits**:
- Instant load on repeat visits
- Works offline (after first visit)
- Reduced bandwidth

**Why Not MVP**:
- CDN caching already fast
- Adds complexity
- Most users have good internet

**Effort**: 8-16 hours
**Priority**: Low (optimization, not critical)

---

### Code Splitting

**What**: Split package into smaller chunks loaded on demand.

**Example**:
```typescript
// Core: 10 KB (always loaded)
// Gating form: 5 KB (load when gating.enabled = true)
// i18n: Load language on demand
```

**Why Not MVP**:
- Entire package is already small (<30 KB gzipped)
- Adds complexity (async imports, loading states)
- Not worth effort for MVP size

**Effort**: 8-16 hours
**Priority**: Low (only if package grows significantly)

---

## Security Enhancements

### Content Security Policy (CSP) Support

**What**: Ensure package works with strict CSP headers.

**Issues**:
- Inline styles in Tavus iframe
- postMessage communication
- Dynamic script loading

**Why Not MVP**:
- Most customers don't use strict CSP
- Can be tested and fixed when customer reports issue

**Effort**: 4-8 hours
**Priority**: Low (wait for customer CSP issues)

---

### GDPR Consent Management

**What**: Integrate with cookie consent platforms (OneTrust, Cookiebot).

**Features**:
- Don't load until consent given
- Respect "Do Not Track"
- Provide data deletion API

**Why Not MVP**:
- Customer handles GDPR via privacy policy URL
- BuzzTrail doesn't set cookies
- Not storing PII without consent

**Effort**: 8-16 hours
**Priority**: Low (customers manage their own GDPR)

---

## Analytics & Monitoring

### Conversation Analytics

**What**: Track conversation metrics in real-time dashboard.

**Metrics**:
- Conversations started
- Average duration
- Drop-off rate
- User satisfaction
- Common questions

**Why Not MVP**:
- Focus on making conversations work first
- Analytics can be added later
- Supabase already logs basic metrics

**Effort**: 16-32 hours
**Priority**: Medium (valuable after MVP launch)

---

### Error Tracking

**What**: Integrate with Sentry/Rollbar for error monitoring.

**Benefits**:
- Catch production errors
- Stack traces with context
- User impact tracking

**Why Not MVP**:
- Can add logging to existing code
- Sentry integration trivial to add later
- Console.error sufficient for MVP

**Effort**: 2-4 hours
**Priority**: Low (add after MVP launch)

---

## Developer Experience

### Gating Form Themes & Styling

**What**: Pre-built themes and advanced styling options.

**Pre-built Themes**:
```typescript
theme: 'minimal' | 'professional' | 'playful' | 'custom'
```

**Advanced Styling**:
```typescript
styling: {
  colors: {
    primary: '#007bff',
    error: '#dc3545',
    background: '#ffffff'
  },
  fonts: {
    family: 'Inter, sans-serif',
    size: { base: '16px', label: '14px' }
  },
  borderRadius: '8px',
  shadows: true
}
```

**Why Not MVP**: Inline styles work, customers can override with CSS.

**Effort**: 16-24 hours
**Priority**: Medium (improves brand consistency)

---

### Form Field Components Library

**What**: Export individual field components for custom forms.

**Example**:
```typescript
import { EmailField, PhoneField } from '@buzztrail-ai/gating';

// Build custom form with individual fields
<form>
  <EmailField
    value={email}
    onChange={setEmail}
    validateFreeProviders={true}
  />
  <PhoneField value={phone} onChange={setPhone} />
</form>
```

**Why Not MVP**: `<GatingForm>` component sufficient for MVP.

**Effort**: 8-16 hours
**Priority**: Low (advanced customization)

---

### Headless Form API

**What**: Provide form logic without UI (bring your own components).

**Example**:
```typescript
import { useGatingForm } from '@buzztrail-ai/gating';

function CustomForm() {
  const form = useGatingForm(config);

  return (
    <MyCustomUI
      data={form.formData}
      errors={form.validation.errors}
      onSubmit={form.handleSubmit}
    />
  );
}
```

**Why Not MVP**: Hook already exported, just needs documentation.

**Effort**: 2-4 hours (documentation only)
**Priority**: Low (power user feature)

---

### TypeScript SDK

**What**: Full TypeScript types for all APIs.

**Current**: Types exist but could be improved
**Future**: Complete type definitions, JSDoc comments, examples

**Why Not MVP**: Types already exist for core functionality.

**Effort**: 4-8 hours
**Priority**: Low (nice-to-have, not blocking)

---

### Developer Documentation

**What**: Comprehensive docs site with examples, tutorials, API reference.

**Features**:
- Getting started guide
- API reference (generated from types)
- Integration examples (React, Vue, vanilla JS)
- Troubleshooting guide
- Video tutorials

**Why Not MVP**:
- README sufficient for MVP
- Can build docs after proving product-market fit

**Effort**: 40-80 hours
**Priority**: Medium (after MVP with customers)

---

### Debugging Tools

**What**: Built-in debugging utilities for troubleshooting.

**Features**:
```typescript
BuzzTrail.debug.enable(); // Verbose logging
BuzzTrail.debug.getState(); // Inspect internal state
BuzzTrail.debug.simulateError(); // Test error handling
```

**Why Not MVP**: Console logging sufficient for MVP debugging.

**Effort**: 4-8 hours
**Priority**: Low (developer convenience)

---

## Testing Infrastructure

### Automated Browser Testing

**What**: Playwright tests across Chrome, Firefox, Safari, Edge.

**Current**: ESLint compatibility checking + manual testing
**Future**: Automated E2E tests

**Why Not MVP**:
- Browserslist + ESLint catch API compatibility issues
- Manual testing sufficient for MVP
- Automated tests require significant infrastructure

**Effort**: 16-32 hours (see 170-browser-compatibility-strategy.md)
**Priority**: Low (only if bugs increase)

---

### Visual Regression Testing

**What**: Automated screenshot comparison across browsers.

**Tools**: Percy, Chromatic, BackstopJS

**Why Not MVP**:
- UI is minimal (form + iframe)
- Manual QA sufficient
- Adds CI/CD complexity

**Effort**: 8-16 hours
**Priority**: Low (optimization, not critical)

---

## Scalability Enhancements

### CDN Optimization

**What**: Optimize CDN delivery with edge caching, compression, etc.

**Current**: jsDelivr/unpkg default caching
**Future**: Custom CDN config, Cloudflare optimization

**Why Not MVP**: Default CDN performance is excellent.

**Effort**: 4-8 hours
**Priority**: Low (only if traffic scales significantly)

---

### Rate Limiting

**What**: Rate limit API calls to prevent abuse.

**Implementation**: Redis-based rate limiter on proxy server

**Why Not MVP**:
- Low traffic initially
- Vercel has built-in rate limiting
- Can add when abuse detected

**Effort**: 4-8 hours
**Priority**: Low (add if abuse occurs)

---

## Review Schedule

Review this document:
- After MVP launch (collect customer feedback)
- Quarterly (prioritize based on demand)
- When facing specific technical challenges

**Decision Criteria**:
1. Customer requests (vote with usage)
2. Technical debt (blocking future work)
3. Competitive pressure (others have it)
4. ROI (effort vs. value)

---

## Summary

This PRD captures **post-MVP enhancements** that would be valuable but aren't critical for initial launch. Focus on:

✅ **MVP First**: Ship core functionality fast
✅ **Customer Feedback**: Let customers guide priorities
✅ **Incremental**: Add features as needed, not preemptively
✅ **Pragmatic**: Solve real problems, not imagined ones

**Next Steps**: Ship MVP → Gather feedback → Prioritize from this list
