# Browser Compatibility

## Supported Browsers

BuzzTrail Engage follows the [browserslist](https://github.com/browserslist/browserslist) standard for browser compatibility.

**Configuration** (in [`package.json`](../package.json)):
```json
"browserslist": [
  "> 0.5%",
  "last 2 versions",
  "not dead",
  "not op_mini all"
]
```

This targets:
- **> 0.5%**: Browsers with more than 0.5% market share
- **last 2 versions**: The most recent 2 versions of each browser
- **not dead**: Excludes browsers without official support or updates for 24 months
- **not op_mini all**: Excludes Opera Mini (doesn't support WebRTC/getUserMedia)

### What This Means

| Browser | Status |
|---------|--------|
| **Chrome** (Desktop & Android) | ✅ Fully supported |
| **Safari** (Desktop & iOS) | ⚠️ Supported with limitations* |
| **Firefox** (Desktop & Android) | ✅ Fully supported |
| **Edge** (Chromium-based) | ✅ Fully supported |
| **Opera** | ✅ Fully supported |
| **Samsung Internet** | ✅ Fully supported |

**\* iOS Safari limitations**: Stricter iframe permission policies. Camera/microphone access works but requires user gesture (button click). Works best in full-page mode rather than embedded iframes.

## Required Browser Features

Based on [caniuse.com](https://caniuse.com) data, BuzzTrail Engage requires:

### Critical Features

#### getUserMedia / Stream API
- **What**: Camera and microphone access
- **Spec**: [MDN getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia)
- **caniuse**: [stream](https://caniuse.com/stream)

#### RTCPeerConnection (WebRTC)
- **What**: Peer-to-peer video streaming
- **Spec**: [MDN WebRTC API](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API)
- **caniuse**: [rtcpeerconnection](https://caniuse.com/rtcpeerconnection)

#### Fetch API
- **What**: HTTP requests to Tavus API proxy
- **caniuse**: [fetch](https://caniuse.com/fetch)

#### ES6 Promises
- **What**: Async operations
- **caniuse**: [promises](https://caniuse.com/promises)

#### postMessage API
- **What**: Communication with Daily.co iframe
- **caniuse**: Universal (all modern browsers)

#### CSS Flexbox
- **What**: Layout
- **caniuse**: [flexbox](https://caniuse.com/flexbox)

## Security Requirements

### HTTPS Required
getUserMedia API requires secure context. `http://localhost` is allowed for development.

### User Gesture Required
All modern browsers require user interaction (click) before camera/microphone access. BuzzTrail conversations start from button click.

## Known Browser-Specific Behaviors

### Chrome & Firefox
- ✅ Excellent WebRTC support
- ✅ Stable getUserMedia and RTCPeerConnection APIs

### Safari (Desktop & iOS)
- ⚠️ Stricter iframe permission policies
- ⚠️ getUserMedia in iframes requires `allow="camera;microphone"` attribute (BuzzTrail sets this)
- ⚠️ iOS: Works best in full-page mode rather than deeply nested iframes
- **Recommendation**: Test on target platform (Wix, Webflow, etc.) before production use

### Edge
- ✅ Chromium-based Edge fully supported

## Testing Strategy

For MVP, BuzzTrail uses **automated compatibility checking via ESLint** and documentation:

1. **ESLint compatibility checking** - `eslint-plugin-compat` checks code against browserslist config
2. **Browserslist configuration** - Defines target browsers in `package.json`
3. **caniuse.com data** - Documents required features (this file)
4. **Manual testing** - Test on major browsers during development

This lightweight approach automatically catches incompatible APIs during development without heavy automated browser testing infrastructure.

## Common Issues & Solutions

### Issue: "Camera access denied"
- **Cause**: User denied permission or no HTTPS
- **Solution**: Ensure HTTPS and ask user to grant permissions

### Issue: "getUserMedia is not a function"
- **Cause**: Very old browser (pre-2017)
- **Solution**: Upgrade browser or use supported browser

### Issue: Black screen in Daily.co iframe
- **Cause**: Missing `allow="camera;microphone;autoplay"` on iframe
- **Solution**: BuzzTrail sets this automatically (verified in code)

### Issue: iOS Safari not working in embedded iframe
- **Cause**: Website embedding BuzzTrail blocks iframe permissions
- **Solution**: Test on actual target platform; may need full-page mode

## Browser Support Data Sources

- [getUserMedia / Stream API](https://caniuse.com/stream) - Can I Use
- [RTCPeerConnection](https://caniuse.com/rtcpeerconnection) - Can I Use
- [Fetch API](https://caniuse.com/fetch) - Can I Use
- [ES6 Promises](https://caniuse.com/promises) - Can I Use
- [MDN getUserMedia](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) - Mozilla Developer Network
- [MDN WebRTC API](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) - Mozilla Developer Network

## Browserslist Coverage

The browserslist query `> 0.5%, last 2 versions, not dead, not op_mini all` provides:
- **93%+ global coverage**
- Automatic updates as browsers release new versions
- Excludes unmaintained browsers
- Excludes Opera Mini (incompatible with video APIs)

You can view the exact browser list using [browserslist.dev](https://browserslist.dev/?q=PiAwLjUlLCBsYXN0IDIgdmVyc2lvbnMsIG5vdCBkZWFkLCBub3Qgb3BfbWluaSBhbGw%3D).

### Running Locally

Check which browsers are targeted:
```bash
npx browserslist
```

Test compatibility with ESLint:
```bash
pnpm nx lint engage-package
```

## Questions?

For browser-specific issues:
1. Check [caniuse.com](https://caniuse.com) for latest compatibility data
2. Test on actual target platform (Wix, Webflow, etc.)
3. Report issues to BuzzTrail support with browser name, version, and platform

Last updated: 2025-10-24
