managarten/memoro/apps/mobile/POSTHOG_REMOVAL.md
Till-JS e7f5f942f3 chore: initial commit - consolidate 4 projects into monorepo
Projects included:
- maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing)
- manacore (Expo mobile + SvelteKit web + Astro landing)
- manadeck (NestJS backend + Expo mobile + SvelteKit web)
- memoro (Expo mobile + SvelteKit web + Astro landing)

This commit preserves the current state before monorepo restructuring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:38:24 +01:00

158 lines
4.4 KiB
Markdown

# PostHog Removal Summary
## Overview
PostHog analytics has been **completely removed** from the Memoro mobile app. Analytics tracking is now disabled for mobile platforms (iOS/Android), while web continues to use Umami.
## What Was Removed
### Dependencies
-`posthog-react-native` package (from package.json)
### Files Deleted
-`features/analytics/services/analyticsService.ts` - PostHog service
-`features/analytics/services/postHogManager.ts` - PostHog manager
-`B2B_ANALYTICS_DISABLE.md` - Documentation (obsolete)
-`REMOVE_TEST_ALERTS.md` - Test alerts documentation (obsolete)
### Code Changes
**1. AuthContext** (`features/auth/contexts/AuthContext.tsx`)
- Removed PostHog imports
- Removed PostHog initialization on app startup
- Removed PostHog initialization on sign in
- Removed PostHog initialization on sign up
- Removed PostHog reset on sign out
- Removed all test alerts
- Removed `useAnalytics()` hook usage
**2. MultiPlatformAnalytics** (`features/analytics/services/multiPlatformAnalytics.ts`)
- Removed PostHog manager import
- Mobile analytics calls are now no-ops
- Web continues to use Umami
**3. Analytics Index** (`features/analytics/index.ts`)
- Removed PostHog manager exports
- Removed analyticsService export
**4. Feature Flags** (`features/analytics/hooks/useFeatureFlag.ts`)
- `useFeatureFlag()` now always returns `false`
- `useFeatureFlags()` now always returns `{}`
- Kept for backward compatibility
**5. Config** (`config.ts`)
- Removed `POSTHOG_KEY` configuration
- Removed `POSTHOG_HOST` configuration
**6. Layout** (`app/_layout.tsx`)
- Updated comment to reflect PostHog removal
## Current State
### Mobile (iOS/Android)
-**No analytics tracking**
- ✅ All `useAnalytics()` calls are no-ops
- ✅ All feature flag checks return false
- ✅ No data sent to analytics services
- ✅ RevenueCat still works (B2B disable logic intact)
### Web
-**Umami analytics only**
- ✅ All analytics tracking functional
- ✅ No changes to web analytics behavior
## Backward Compatibility
All analytics hooks remain functional:
```typescript
// These still work but do nothing on mobile
const { track, identify, screen, reset } = useAnalytics();
track('event'); // No-op on mobile, works on web
identify('userId'); // No-op on mobile, works on web
// Feature flags always return false/empty
const isEnabled = useFeatureFlag('my-flag'); // Always false
const flags = useFeatureFlags(); // Always {}
```
## Next Steps
### If you want to re-enable analytics:
1. **Choose a new analytics provider** (e.g., Amplitude, Mixpanel, etc.)
2. **Install the package:**
```bash
npm install [new-analytics-package]
```
3. **Create new service file:**
- `features/analytics/services/analyticsService.ts`
4. **Update `multiPlatformAnalytics.ts`** to use new service
5. **Add initialization** to AuthContext (optional, if needed)
### If you want to keep analytics disabled:
- ✅ No action needed - current state is stable
- ✅ App continues to function normally
- ✅ All code is backward compatible
## Cleanup
To clean up your environment:
1. **Remove node_modules and reinstall:**
```bash
rm -rf node_modules package-lock.json
npm install
```
2. **Remove PostHog from environment files** (optional):
- `.env.dev`
- `.env.prod`
- `.env.example`
Remove these lines:
```bash
EXPO_PUBLIC_POSTHOG_KEY=...
EXPO_PUBLIC_POSTHOG_HOST=...
```
## Testing
Verify PostHog is completely removed:
```bash
# Search for any remaining PostHog references
git grep -i posthog
# Should only show this file and maybe some comments/docs
```
## Migration Notes
- **No breaking changes** - all analytics hooks still exist
- **No data loss** - RevenueCat and other services unaffected
- **No user impact** - app functionality unchanged
- **Web analytics** - continues to work with Umami
## Commit Details
**Commit:** `fd18430` - 🔥 refactor: remove PostHog analytics completely from the app
**Stats:**
- 11 files changed
- 29 insertions
- 925 deletions
- Net reduction: ~900 lines of code
**Files affected:**
- B2B_ANALYTICS_DISABLE.md (deleted)
- REMOVE_TEST_ALERTS.md (deleted)
- app/_layout.tsx
- config.ts
- features/analytics/hooks/useFeatureFlag.ts
- features/analytics/index.ts
- features/analytics/services/analyticsService.ts (deleted)
- features/analytics/services/multiPlatformAnalytics.ts
- features/analytics/services/postHogManager.ts (deleted)
- features/auth/contexts/AuthContext.tsx
- package.json