-
Notifications
You must be signed in to change notification settings - Fork 5
CU-868ex18rd Migrating to countly #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Analytics Migration: Aptabase to Countly | ||
|
|
||
| ## Overview | ||
| Successfully migrated the project from Aptabase analytics to Countly with minimal disruption to the codebase. | ||
|
|
||
| ## What Was Changed | ||
|
|
||
| ### 1. Dependencies | ||
| - ❌ **Removed**: `@aptabase/react-native` | ||
| - ✅ **Added**: `countly-sdk-react-native-bridge@25.4.0` | ||
|
|
||
| ### 2. Analytics Service (`src/services/analytics.service.ts`) | ||
| - **Completely rewritten** to use Countly SDK | ||
| - **Maintained same interface** for components (same method names and signatures) | ||
| - **Enhanced error handling** with retry logic and graceful degradation | ||
| - **Added comprehensive session management** (start, end, extend) | ||
| - **Proper user properties support** | ||
| - **Environment-driven initialization** with fallback configuration | ||
|
|
||
| #### Key Features: | ||
| - ✅ Event tracking with properties | ||
| - ✅ User properties management | ||
| - ✅ Session lifecycle management | ||
| - ✅ Error handling with retry mechanism | ||
| - ✅ Service status monitoring | ||
| - ✅ Graceful degradation on failures | ||
|
|
||
| ### 3. Hook Integration (`src/hooks/use-analytics.ts`) | ||
| - **Updated** to use new `analyticsService` instead of `aptabaseService` | ||
| - **Interface unchanged** - components continue working without modifications | ||
| - **Performance optimized** with `useCallback` | ||
|
|
||
| ### 4. Environment Configuration | ||
| - **Updated** `env.js` to support Countly variables: | ||
| - `RESPOND_COUNTLY_APP_KEY` (replaces `RESPOND_APTABASE_APP_KEY`) | ||
| - `RESPOND_COUNTLY_URL` (replaces `RESPOND_APTABASE_URL`) | ||
| - **Updated** `.env.development` with new variable names | ||
|
|
||
| ### 5. App Initialization | ||
| - **Integrated** analytics service into `AppInitializationService` | ||
| - **Automatic initialization** during app startup | ||
| - **Proper error handling** - analytics failures don't break app startup | ||
| - **Environment-based configuration** - uses env vars automatically | ||
|
|
||
| ### 6. Removed Components | ||
| - ❌ **Deleted**: `src/components/common/aptabase-provider.tsx` | ||
| - ❌ **Removed**: All references to `AptabaseProviderWrapper` in `_layout.tsx` | ||
| - ❌ **Cleaned up**: Old Aptabase mocks in test files | ||
|
|
||
| ### 7. Test Coverage | ||
| - ✅ **New comprehensive test suite** for `analytics.service.ts` (23 passing tests) | ||
| - ✅ **Updated hook tests** to use new service | ||
| - ✅ **Cleaned up** old Aptabase references in component tests | ||
| - ✅ **All tests passing** for analytics-related code | ||
|
|
||
| ## Migration Benefits | ||
|
|
||
| ### ✅ Minimal Disruption | ||
| - **Zero changes** required in components using analytics | ||
| - **Same API interface** maintained across the migration | ||
| - **Existing analytics calls** continue working unchanged | ||
|
|
||
| ### ✅ Enhanced Reliability | ||
| - **Better error handling** with exponential backoff retry logic | ||
| - **Graceful degradation** when analytics fails | ||
| - **Service status monitoring** with automatic recovery | ||
| - **Proper session management** | ||
|
|
||
| ### ✅ Improved Architecture | ||
| - **Centralized initialization** through AppInitializationService | ||
| - **Environment-driven configuration** | ||
| - **Comprehensive test coverage** | ||
| - **Better logging and debugging** | ||
|
|
||
| ## Configuration Required | ||
|
|
||
| To complete the setup, you need to configure the environment variables: | ||
|
|
||
| ```bash | ||
| # In your .env files (development, staging, production) | ||
| RESPOND_COUNTLY_APP_KEY=your_countly_app_key_here | ||
| RESPOND_COUNTLY_URL=https://your-countly-server.com | ||
| ``` | ||
|
|
||
| ## Testing Status | ||
|
|
||
| ✅ **All analytics tests passing**: | ||
| - `src/services/__tests__/analytics.service.test.ts` - 23 tests ✅ | ||
| - `src/hooks/__tests__/use-analytics.test.ts` - All tests ✅ | ||
| - Component integration tests working ✅ | ||
|
|
||
| ## Next Steps | ||
|
|
||
| 1. **Configure Countly server credentials** in environment files | ||
| 2. **Test in development environment** to verify data flow | ||
| 3. **Deploy to staging** for validation | ||
| 4. **Monitor analytics data** to ensure proper tracking | ||
|
|
||
| ## Rollback Plan (if needed) | ||
|
|
||
| If rollback is required: | ||
| 1. Reinstall: `yarn add @aptabase/react-native` | ||
| 2. Restore: `src/services/aptabase.service.ts` from git history | ||
| 3. Revert: Environment variable changes | ||
| 4. Restore: `AptabaseProviderWrapper` in `_layout.tsx` | ||
|
|
||
| However, the migration maintains full API compatibility, so rollback should not be necessary. | ||
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export default jest.fn().mockImplementation(() => ({ | ||
| setLoggingEnabled: jest.fn().mockReturnThis(), | ||
| enableCrashReporting: jest.fn().mockReturnThis(), | ||
| setRequiresConsent: jest.fn().mockReturnThis(), | ||
| giveConsent: jest.fn().mockReturnThis(), | ||
| setLocation: jest.fn().mockReturnThis(), | ||
| enableParameterTamperingProtection: jest.fn().mockReturnThis(), | ||
| })); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| export const initWithConfig = jest.fn(); | ||
| export const events = { | ||
| recordEvent: jest.fn(), | ||
| startEvent: jest.fn(), | ||
| endEvent: jest.fn(), | ||
| cancelEvent: jest.fn(), | ||
| }; | ||
| export const setUserData = jest.fn(); | ||
| export const endSession = jest.fn(); | ||
| export const startSession = jest.fn(); | ||
| export const isInitialized = jest.fn().mockResolvedValue(false); | ||
|
|
||
| export default { | ||
| initWithConfig, | ||
| events, | ||
| setUserData, | ||
| endSession, | ||
| startSession, | ||
| isInitialized, | ||
| }; |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align env var names with implementation
Docs list RESPOND_COUNTLY_* keys, but the service currently reads COUNTLY_*; reconcile both sides and document the final names.
Also applies to: 79-83
🤖 Prompt for AI Agents