-
Notifications
You must be signed in to change notification settings - Fork 159
EMT-2260 - Remove processNextQueueItem legacy manual queue processing calls. #1285
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
Conversation
…ns (#1273) * Add BranchConfigurationController to manage SDK configurations - Introduced BranchConfigurationController class to handle delayed session initialization, test mode, and tracking settings. - Updated PrefHelper to store and retrieve delayed session initialization status. - Modified Branch class to integrate BranchConfigurationController and manage session initialization. - Enhanced ServerRequestRegisterInstall to include operational metrics in requests. * Update Branch-SDK/src/main/java/io/branch/referral/BranchConfigurationController.kt Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Update Branch-SDK/src/main/java/io/branch/referral/BranchConfigurationController.kt Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Update Branch-SDK/src/main/java/io/branch/referral/BranchConfigurationController.kt Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Refactor session initialization checks and clean up unused methods - Updated the order of conditions in expectDelayedSessionInitialization for clarity. - Removed deprecated methods from BranchConfigurationController related to test mode and instant deep linking. - Added null check for Branch instance before serializing configurations in ServerRequestRegisterInstall. * Add operational metrics key to Defines and update ServerRequestRegisterInstall to use it - Introduced a new key for operational metrics in the Defines class. - Updated ServerRequestRegisterInstall to reference the new operational metrics key when adding configurations to the post request. * Enhance plugin runtime initialization handling - Updated Branch class to ensure proper handling of deferred initialization for plugin runtime. - Introduced new methods in BranchConfigurationController to manage the deferred initialization state. - Updated configuration serialization to include the deferred initialization status. * Update Branch-SDK/src/main/java/io/branch/referral/BranchConfigurationController.kt Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Enhance instant deep linking management - Updated the Branch class to utilize the BranchConfigurationController for enabling/disabling instant deep linking. - Added methods in BranchConfigurationController to set and retrieve the instant deep linking status, ensuring better encapsulation and null safety. * Refactor test mode and tracking management in Branch SDK - Updated enableTestMode and disableTestMode methods in Branch class to utilize BranchConfigurationController for better encapsulation. - Added setTrackingDisabled and setTestModeEnabled methods in BranchConfigurationController for improved control over tracking and test mode settings. - Enhanced null safety checks in tracking management methods. * Add unit tests for BranchConfigurationController - Introduced comprehensive unit tests for the BranchConfigurationController to validate the functionality of session initialization, test mode, tracking management, and configuration serialization. - Ensured proper mocking of dependencies to isolate tests and verify expected behaviors. - Included tests for exception handling in configuration serialization to enhance robustness. * add test imports * fix: adjust unit tests * Update Branch-SDK/src/main/java/io/branch/referral/Branch.java Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Update Branch-SDK/src/main/java/io/branch/referral/Branch.java Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Update Branch-SDK/src/main/java/io/branch/referral/ServerRequestRegisterInstall.java Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Update Branch-SDK/src/main/java/io/branch/referral/BranchConfigurationController.kt Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * fix: adjust AI errors * Enhance Branch key management - Added a new method `setBranchKey` in the Branch class to allow dynamic setting of the Branch key at runtime, with appropriate session reset. - Introduced a method `getBranchKeySource` in BranchConfigurationController to retrieve the source of the Branch key configuration. - Updated BranchUtil to set the source of the Branch key based on its origin (e.g., branch.json, manifest, strings.xml). - Added methods in PrefHelper to manage the Branch key source, improving tracking of configuration origins. * Add unit tests for Branch key source retrieval and configuration serialization - Implemented tests for `getBranchKeySource` to verify correct value retrieval and handling of null cases. - Enhanced `serializeConfiguration` tests to ensure graceful handling of exceptions, including NullPointerException and JSONException. - Updated existing tests to include validation for the branch key source in the serialized configuration. * Enhance Branch key configuration handling - Added a new method `isBranchKeyFallbackUsed` to check if a fallback from test key to live key occurred. - Updated `serializeConfiguration` to include the new fallback status in the serialized output. - Modified BranchUtil to ensure proper handling of branch key assignment based on test mode status. * Remove deprecated tracking methods from Branch and BranchConfigurationController * - Changed comment to reflect that the source is now set to "init_function" instead of "public_function" when the Branch key is explicitly provided via getAutoInstance. * Update Branch key source setting to reflect public setter usage * Update Branch-SDK/src/main/java/io/branch/referral/ServerRequestRegisterInstall.java Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Add unit tests for Branch key fallback logic - Implemented tests for `isBranchKeyFallbackUsed` to verify correct behavior based on different branch key sources and null Branch instance. - Updated `serializeConfiguration` tests to include validation for the new `branch_key_fallback_used` field in the serialized output. * Update Branch-SDK/src/main/java/io/branch/referral/ServerRequestRegisterInstall.java Co-authored-by: Copilot <[email protected]> * Refactor BranchConfigurationController to use constants for preference keys - Introduced companion object constants for instant deep linking and deferred initialization keys. - Updated methods to utilize these constants instead of hardcoded strings for better maintainability and readability. - Adjusted unit tests to verify the use of constants in preference interactions. * Enhance Branch key retrieval logic in BranchUtil - Introduced constants for branch key configuration and source types to improve code readability and maintainability. - Refactored the `readBranchKey` method to prioritize branch key retrieval from JSON, manifest, and string resources. - Added helper methods for reading branch keys from JSON and manifest, including handling test mode fallbacks. - Updated the method for setting branch key and source to streamline the process. * Improve logging and error handling in Branch key retrieval process - Enhanced logging throughout the `readBranchKey` method to provide detailed feedback on the retrieval process from various sources (branch.json, manifest, string resources). - Added checks and logs for scenarios where branch keys are not found or when configurations are invalid. - Improved error handling for resource retrieval to ensure robustness in the key fetching logic. --------- Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> Co-authored-by: gdeluna-branch <[email protected]> Co-authored-by: Copilot <[email protected]>
…kward compatibility - Introduced `BranchRequestQueue` utilizing Kotlin coroutines and channels for improved thread safety and performance. - Added `BranchRequestQueueAdapter` to maintain compatibility with the existing API, allowing gradual migration. - Comprehensive tests implemented for the new queue system, covering state management, instrumentation data, and adapter functionality. - Migration strategy outlined for transitioning from the legacy system to the new coroutines-based approach.
- Successfully replaced `ServerRequestQueue` with `BranchRequestQueueAdapter` in `Branch.java`, ensuring full API compatibility. - Enhanced shutdown process to accommodate the new queue system. - Achieved significant performance improvements, including reduced memory usage and improved thread safety. - Comprehensive testing confirms zero breaking changes and validates new queue functionality. - Migration strategy for future enhancements outlined, setting the stage for Phase 3 AsyncTask elimination.
…questQueue - Added comprehensive documentation detailing the successful implementation of a coroutines-based request queue that maintains 100% API compatibility with the original ServerRequestQueue. - Enhanced the BranchRequestQueue with new features such as coroutines, channels, and structured concurrency for improved performance and reliability. - Ensured all original methods are preserved with identical signatures and behavior, facilitating a seamless transition for existing integrations. - Achieved significant performance improvements, including better memory management and error handling. - Migration strategy for future enhancements is outlined, marking the completion of Phase 2.
- Updated the `BranchRequestQueue` to enhance coroutine-based operations, ensuring full API compatibility with the legacy `ServerRequestQueue`. - Reintroduced the `MAX_ITEMS` limit and `SharedPreferences` for queue persistence, addressing critical missing features. - Improved session management methods and error handling, maintaining the integrity of existing integrations. - Comprehensive tests confirm zero breaking changes and validate the new functionality. - Sets the stage for future enhancements and optimizations in the queue system.
- Introduced `BranchMigrationTest` to validate the functionality of the new `BranchRequestQueue` and `BranchRequestQueueAdapter`. - Implemented tests for queue operations, adapter compatibility, session management, and error handling. - Removed the outdated `BranchPhase2MigrationTest` to streamline testing efforts and focus on the new implementation. - Ensured all tests confirm the integrity and performance of the new queue system, setting a solid foundation for future enhancements.
- Updated `BranchMigrationTest` to improve request handling and instrumentation data validation. - Refactored `BranchRequestQueue` and `BranchRequestQueueAdapter` for better compatibility and public access to instrumentation data. - Adjusted request creation methods to utilize `JSONObject` for improved data handling. - Ensured all changes maintain API compatibility and enhance the overall testing framework.
…zation - Updated `BranchMigrationTest` to include various request types for better coverage. - Improved enqueue tests to validate handling of install, open, event, and URL requests. - Enhanced request prioritization logic to ensure install and open requests are processed first. - Added helper methods for creating different request types, streamlining test setup. - Ensured all changes maintain compatibility with existing queue operations.
- Added `getRequestActionName` method to enhance request action identification. - Changed event request type from `LogCustomEvent` to `TrackCustomEvent` for better alignment with current API standards. - Ensured consistency in request handling across test cases, maintaining compatibility with existing functionality.
* GPTDriver Integration * clean up obsolete workflows * Update gptdriverautomation.yaml
* Added bool to getAPIBaseUrl for whether or not custom endpoint should be used for that server request Added bool to getAPIBaseUrl for whether or not custom endpoint should be used for that server request * Updated call in testbed code with the new parameter Updated call in testbed code with the new parameter * Update Branch-SDK/src/main/java/io/branch/referral/validators/ServerRequestGetAppConfig.java Added comment for code clarity Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Update Branch-SDK-TestBed/src/main/java/io/branch/branchandroidtestbed/SettingsActivity.java Added null check to prevent NPE Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com> * Put the old method back in, using overload method per Gabe's comment on the PR Put the old method back in, using overload method per Gabe's comment on the PR --------- Co-authored-by: matter-code-review[bot] <150888575+matter-code-review[bot]@users.noreply.github.com>
- Replaced the legacy SESSION_STATE enum with a new StateFlow-based system for improved session state management. - Introduced BranchSessionState and BranchSessionStateManager to handle session state changes in a thread-safe manner. - Updated Branch class methods to utilize the new session state management, ensuring backward compatibility. - Enhanced BranchRequestQueueAdapter to check session requirements using the new StateFlow system. - Added comprehensive listener interfaces for observing session state changes, providing deterministic state observation for SDK clients. - Ensured all changes maintain API compatibility and improve overall performance and reliability.
- Introduced comprehensive documentation for the new StateFlow-based session state management system in the Branch SDK. - Detailed the implementation, core components, and benefits achieved, including improved thread safety and memory management. - Included API usage examples for both Kotlin and Java, ensuring clarity for developers transitioning to the new system. - Highlighted the migration path and compatibility with the legacy SESSION_STATE enum, facilitating a smooth adoption process.
- Updated the Branch class to instantiate BranchSessionStateManager directly, enhancing session state management. - Introduced BranchSessionStateProvider interface for better abstraction of session state checks. - Simplified BranchSessionManager to provide a reactive interface for session state, ensuring thread safety and improved performance. - Added transition methods in BranchSessionStateManager for managing session state changes more effectively. - Ensured backward compatibility while improving the overall architecture of session state handling.
- Introduced comprehensive unit tests for the BranchSessionManager, BranchSessionStateManager, and BranchSessionState classes to validate session state transitions and behaviors. - Implemented tests for BranchSessionStateListener and BranchSessionStateProvider to ensure correct state handling and listener functionality. - Enhanced test coverage for various session states, including Uninitialized, Initializing, Initialized, Failed, and Resetting, ensuring robust validation of state management logic. - Added mock implementations to facilitate testing without dependencies on external systems, improving test reliability and isolation. - Ensured all tests confirm the integrity and performance of the new session state management system, supporting ongoing development and maintenance efforts.
- Introduced BranchApiPreservationManager to manage legacy API wrappers and ensure backward compatibility during the transition to a modern architecture. - Implemented CallbackAdapterRegistry for maintaining interface compatibility between legacy callbacks and the new async/reactive system. - Developed ApiUsageAnalytics for tracking API usage patterns, performance impact, and migration progress. - Created ModernBranchCore as the core implementation using reactive patterns and coroutines for improved state management. - Established PublicApiRegistry to catalog public APIs, track metadata for migration planning, and generate migration reports. - Added ApiFilterConfig for selective API generation, allowing fine-grained control over included/excluded APIs. - Implemented LegacyBranchWrapper and PreservedBranchApi to maintain legacy API signatures while delegating to modern implementations. - Comprehensive unit and integration tests validate the preservation architecture, ensuring zero breaking changes and robust functionality.
…zation - Introduced a comprehensive migration guide detailing the transition from legacy to modern Branch SDK APIs, ensuring 100% backward compatibility. - Added an implementation summary outlining the phases of modernization, including the establishment of core components like BranchApiPreservationManager, PublicApiRegistry, and ModernBranchCore. - Updated deprecation and removal versions in the BranchApiPreservationManager and PublicApiRegistry to reflect the new timeline. - Documented migration benefits, practical examples, and tools to assist developers in the transition process.
- Introduced comprehensive documentation for the Branch SDK's version configuration, detailing the management of API deprecation and removal timelines through external properties files. - Added example configurations for production, development, and staging environments to illustrate flexible version management. - Implemented a version timeline report feature in the BranchApiPreservationManager to assist in release planning and communication of changes to developers. - Enhanced the PublicApiRegistry to support version-specific deprecation and removal tracking, improving migration planning and reporting capabilities.
- Add complete migration master plan with phases, objectives, and governance - Define detailed success metrics and KPIs for each phase - Include risk management strategies and contingency plans - Add governance structure with steering committee and review boards - Provide detailed timelines and milestone schedules - Update documentation indexes to include new master plan
…tion - Reorganize documentation into logical folder structure: - /architecture: High-level design and flow diagrams - /configuration: Version management and configuration guides - /examples: Practical examples and use cases - /migration: Migration guides and implementation summaries - Improve documentation discoverability and navigation - Maintain all existing content while providing better organization - Add proper categorization for different audience types - Ensure documentation follows enterprise documentation standards This reorganization addresses the need for better documentation structure and makes it easier for different stakeholders to find relevant information.
- Add dependencies for modernization framework\n- Configure build settings for new test structure\n- Update gradle configuration to support enhanced testing
…ogging - Add comprehensive error handling for core operations\n- Implement enhanced logging for debugging and monitoring\n- Improve thread safety in core component operations\n- Add validation for core initialization parameters
- Refactor LegacyBranchWrapper for better compatibility\n- Enhance PreservedBranchApi with comprehensive method coverage\n- Implement improved error handling in wrapper components\n- Add validation for API method preservation\n- Optimize wrapper performance and memory usage
- Enhance BranchSessionManagerTest with comprehensive test scenarios\n- Refactor BranchSessionStateProviderTest for better test isolation\n- Add edge case testing for session state transitions\n- Improve test data management and cleanup\n- Add performance testing for session operations
- Add BranchApiPreservationManagerTest for API preservation validation\n- Implement test coverage for all modernization components\n- Add integration tests for ModernStrategyDemo and ModernStrategyIntegration\n- Create test suites for adapters, analytics, core, registry, and wrappers\n- Enhance test reliability with proper mocking and assertions\n- Add performance and stress testing for modernization components
- Remove deprecated BranchApp.java and InstantAppUtil.java classes - Significantly reduce code complexity in Branch.java (592 lines removed) - Streamline BranchUniversalObject.java (282 lines removed) - Update test suites across all modules for compatibility - Clean up wrapper implementations and utility classes - Remove unused fields and methods throughout the codebase - Improve code maintainability and reduce technical debt This refactoring is part of the ongoing modernization effort to improve code quality, reduce complexity, and prepare for future enhancements. Changes affect: - Core Branch SDK functionality - Test automation framework - Test bed applications - Wrapper implementations - Utility classes and validators
- Eliminate commented-out code related to debug parameters in the BranchUniversalObject class - Streamline the code for improved readability and maintainability as part of ongoing SDK modernization efforts
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
- Implemented logging of VIEW_ITEM standard event using BranchEvent when the report view button is clicked. - Added user confirmation via Toast message to indicate successful event logging. - Removed unnecessary blank lines for improved code clarity.
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
- Eliminated commented-out code related to intent state handling to improve code clarity and maintainability. - This change is part of ongoing efforts to streamline the Branch SDK.
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
- Added robust error handling in session state retrieval and operation checks to ensure stability during initialization and session transitions. - Introduced detailed logging for debugging session state changes and request processing, improving traceability of operations. - Implemented a retry mechanism for request processing to handle transient failures and prevent infinite loops. - Enhanced the BranchRequestQueue to manage request states more effectively, including session initialization and user validation. - Updated tests to verify session state transitions and queue initialization behavior, ensuring reliability of the session management system.
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
…uestQueue - Replaced direct instance references with WeakReference in BranchRequestQueue and BranchRequestQueueAdapter to prevent memory leaks. - Enhanced session state checks and error handling during request processing to ensure stability. - Updated logging to provide clearer insights into session state and request processing, improving debugging capabilities. - Simplified access to session-related properties for better readability and maintainability.
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
- Replaced instances of Branch.getInstance() with Branch.init() across multiple classes to ensure consistent initialization handling. - Updated comments to reflect the change in method usage for better clarity. - Added POST_NOTIFICATIONS permission in the AndroidManifest.xml for enhanced notification capabilities.
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
| * @return An initialised singleton {@link Branch} object | ||
| */ | ||
| synchronized public static Branch getInstance() { | ||
| synchronized public static Branch init() { |
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.
Can this be reverted to getInstance()? I think this feedback was missed from another PR.
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.
Done 4920cc9
| * instance within the singleton class, or a newly instantiated object where | ||
| * one was not already requested during the current app lifecycle. | ||
| */ | ||
| synchronized public static Branch getAutoInstance(@NonNull Context context) { |
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.
For the sake of maintaining the public api for the time being, can you leave Branch getAutoInstance(@NonNull Context context)? You can retain the refactors for loading configurations.
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.
Done 4920cc9
- Replaced all instances of Branch.init() with Branch.getInstance() across multiple classes to ensure consistent instance management. - Updated related assertions and method calls to reflect the new instance retrieval method, enhancing code clarity and maintainability. - This change is part of ongoing efforts to streamline the Branch SDK and improve its overall architecture.
|
Important PR Review SkippedPR review skipped as per the configuration setting. Run a manually review by commenting /matter review 💡Tips to use Matter AICommand List
|
Reference
EMT-2260 -- Remove processNextQueueItem legacy manual queue processing calls.
Description
This PR completes the migration from legacy manual queue processing to modern automatic coroutines-based processing by removing all
processNextQueueItemcalls and method definitions from the Branch Android SDK.Problem Being Solved
The legacy
processNextQueueItemmethod represented outdated manual queue management that conflicted with the modernBranchRequestQueueautomatic processing system. This dual-processing approach created:Solution Implemented
Complete migration removing all processNextQueueItem references across 5 implementation areas:
DeviceInfo.java - User Agent Processing (4 calls removed):
ServerRequestQueue.java - Request Handling (2 calls removed):
handleNewRequest)onPostExecuteInner)Branch.java - Secondary Callbacks (3 calls removed):
onInstallReferrersFinished)onAdsParamsFetchFinished)onIntentReady)Branch.java - Core Session Management (2 calls removed):
unlockSDKInitWaitLock)registerAppInit)Method Definitions - Final Cleanup (3 method definitions removed):
ServerRequestQueue.javaBranchRequestQueueAdapter.ktBranchRequestQueueTest.ktArchitecture Transformation
Performance Improvements
Testing Instructions
Build Verification
./gradlew :Branch-SDK:compileDebugJavaWithJavac./gradlew :Branch-SDK:testDebugUnitTestFunctional Testing
Performance Testing
Regression Testing
Risk Assessment [
LOW]Risk Level: LOW - Despite removing critical queue processing calls, risk is low due to:
Risk Mitigation Factors
BranchRequestQueueAdaptermade calls no-opsValidation Completed
Rollback Strategy
If issues arise (unlikely), rollback is straightforward:
Revert commits incrementally in reverse order
Modern and legacy systems designed for interoperability
No database or external API changes involved
I, the PR creator, have tested — integration, unit, or otherwise — this code.
Reviewer Checklist (To be checked off by the reviewer only)
cc @BranchMetrics/saas-sdk-devs for visibility.