# Analytics Infrastructure

Comprehensive analytics infrastructure with multi-provider support.

## Providers

This project integrates with the following analytics providers:

- **mixpanel**: Analytics tracking

## Configuration

### Environment Variables

- `NEXT_PUBLIC_MIXPANEL_TOKEN`: Mixpanel project token

## Usage

### Frontend Tracking

```typescript
import { useAnalytics } from '@/hooks/useAnalytics';

function MyComponent() {
  const { trackEvent, identify } = useAnalytics();

  const handleClick = async () => {
    await trackEvent({
      name: 'button_clicked',
      properties: { button: 'cta' },
    });
  };

  return <button onClick={handleClick}>Click Me</button>;
}
```

### Backend Tracking

```typescript
import { backendAnalytics } from '@/services/analytics';

await backendAnalytics.trackEvent({
  userId: user.id,
  event: 'order_completed',
  properties: {
    orderId: order.id,
    revenue: order.total,
  },
});
```

## Events

No custom events defined.

## Funnels

No funnels defined.

## Privacy and Consent

This analytics implementation includes GDPR-compliant consent management:

```typescript
import { consentManager } from '@/analytics/privacy/consent';

// Grant consent
await consentManager.grantConsent({
  analytics: true,
  marketing: false,
  functional: true,
});

// Check consent
if (consentManager.hasAnalyticsConsent()) {
  // Track events
}

// Revoke consent
await consentManager.revokeConsent();
```

## License

Generated by Bangstack
