-
Notifications
You must be signed in to change notification settings - Fork 4
[FSSDK-11998] chore: add cmab and holdout support #94
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3e303f2
Update cmab dependency
muzahidul-opti bbc8df1
feat: add CMAB support with decideAsync API and cache control
muzahidul-opti 9965f55
Predictionendpoint templating fixed
muzahidul-opti f9d9c00
Cmab Sample api added
muzahidul-opti 5d5e119
CMAB android basic implementation done
muzahidul-opti 7fb925c
Add unit test cases
muzahidul-opti 2ec0a3f
fix cmab decide options for android
muzahidul-opti 6b0303e
Claude instruction file added
muzahidul-opti 8b5933b
Updated claude instruction
muzahidul-opti 9ab6dc3
fix test issue
muzahidul-opti 10262d7
Exclude example and test directory for analyzer
muzahidul-opti 95f3c32
clean up
muzahidul-opti 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,125 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Optimizely Flutter SDK - Cross-platform plugin wrapping native Optimizely SDKs (iOS, Android) for A/B testing, feature flags, CMAB, and ODP integration and others. | ||
|
|
||
| **Main Branch:** master | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| lib/ # Dart: Public API, data models, user context, platform bridge | ||
| android/src/main/java/ # Java: OptimizelyFlutterClient.java, Plugin, helpers | ||
| ios/Classes/ # Swift: Plugin, logger bridge, helpers | ||
| test/ # Unit tests (SDK, CMAB, logger, nested objects) | ||
| example/ # Example app | ||
| ``` | ||
|
|
||
| ## Essential Commands | ||
|
|
||
| ```bash | ||
| # Setup | ||
| flutter pub get | ||
|
|
||
| # Testing | ||
| flutter test # All tests | ||
| flutter test test/cmab_test.dart # Specific test | ||
| flutter test --coverage # With coverage | ||
|
|
||
| # Linting | ||
| flutter analyze | ||
|
|
||
| # iOS setup | ||
| cd ios && pod install | ||
|
|
||
| # Run example | ||
| cd example && flutter run | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Bridge Pattern | ||
| ``` | ||
| Dart API (OptimizelyFlutterSdk) | ||
| ↓ | ||
| Wrapper (OptimizelyClientWrapper) + MethodChannel | ||
| ↓ | ||
| Native (Swift/Java plugin implementations) | ||
| ↓ | ||
| Native Optimizely SDKs | ||
| ``` | ||
|
|
||
| ### Critical Patterns | ||
|
|
||
| **1. Response Object Pattern** | ||
| - ALL methods return `BaseResponse` derivatives (never throw exceptions) | ||
| - Check `success` boolean and `reason` string for errors | ||
|
|
||
| **2. Multi-Instance State** | ||
| - SDK instances tracked by `sdkKey` | ||
| - User contexts: `sdkKey → userContextId → context` | ||
| - Notification listeners: `sdkKey → listenerId → callback` | ||
| - Call `close()` for cleanup | ||
|
|
||
| **3. Platform-Specific Type Encoding** | ||
| - **iOS**: Attributes need type metadata: `{"value": 123, "type": "int"}` | ||
| - **Android**: Direct primitives: `{"attribute": 123}` | ||
| - Conversion in `convertToTypedMap()` (`optimizely_client_wrapper.dart`) | ||
|
|
||
| **4. Dual Channels** | ||
| - `optimizely_flutter_sdk` - Main API | ||
| - `optimizely_flutter_logger` - Native log forwarding | ||
|
|
||
| ## Key Files | ||
|
|
||
| **Dart:** | ||
| - `lib/optimizely_flutter_sdk.dart` - Public API entry point | ||
| - `lib/src/optimizely_client_wrapper.dart` - Platform channel bridge | ||
| - `lib/src/user_context/optimizely_user_context.dart` - User context API | ||
| - `lib/src/data_objects/` - 21 response/request models | ||
|
|
||
| **Android:** | ||
| - `android/src/.../OptimizelyFlutterSdkPlugin.java` - MethodChannel handler | ||
| - `android/src/.../OptimizelyFlutterClient.java` - Core client wrapper | ||
| - `android/build.gradle` - Dependencies & build config | ||
|
|
||
| **iOS:** | ||
| - `ios/Classes/SwiftOptimizelyFlutterSdkPlugin.swift` - MethodChannel handler | ||
| - `ios/optimizely_flutter_sdk.podspec` - Pod dependencies | ||
|
|
||
| ## Adding Cross-Platform Features | ||
|
|
||
| 1. Add data models in `lib/src/data_objects/` if needed | ||
| 2. Update `optimizely_client_wrapper.dart` with method channel call | ||
| 3. **Android**: Add case in `OptimizelyFlutterClient.java`, parse args, call native SDK | ||
| 4. **iOS**: Add case in `SwiftOptimizelyFlutterSdkPlugin.swift`, parse args, call native SDK | ||
| 5. Handle type conversions (iOS requires metadata) | ||
| 6. Add tests | ||
| 7. Update public API in `optimizely_flutter_sdk.dart` | ||
|
|
||
|
|
||
| ## Contributing | ||
|
|
||
| ### Commit Format | ||
| Follow [Angular guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines): `feat:`, `fix:`, `docs:`, `refactor:`, `test:` | ||
|
|
||
| ### Requirements | ||
| - **Never commit directly to `master` branch** - Always create a feature branch | ||
| - Tests required for all changes | ||
| - PR to `master` branch | ||
| - All CI checks must pass (unit tests, build validation, integration tests) | ||
| - Apache 2.0 license header on new files | ||
|
|
||
| ### CI Pipeline | ||
| - `unit_test_coverage` (macOS) - Coverage to Coveralls | ||
| - `build_test_android/ios` - Build validation | ||
| - `integration_android/ios_tests` - External test app triggers | ||
|
|
||
| ## Platform Requirements | ||
|
|
||
| - Dart: >=2.16.2 <4.0.0, Flutter: >=2.5.0 | ||
| - Android: minSdk 21, compileSdk 35 | ||
| - iOS: 10.0+, Swift 5.0 | ||
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 |
|---|---|---|
| @@ -1,4 +1,9 @@ | ||
| include: package:flutter_lints/flutter.yaml | ||
|
|
||
| analyzer: | ||
| exclude: | ||
| - example/** | ||
| - test/** | ||
|
|
||
| # Additional information about this file can be found at | ||
| # https://dart.dev/guides/language/analysis-options |
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
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.
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.
Asking out of curiosity, are we planning to add md files like this for every sdk?
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.
I think it is nice to have