Skip to content

Commit

Permalink
fix(deriv_feature_flag): remove env dependancy (#477)
Browse files Browse the repository at this point in the history
* fix(deriv_feature_flag): remove env dependancy

* chore(deriv_feature_flag): add document to FeatureFlagConfig
  • Loading branch information
ahrar-deriv authored Feb 15, 2024
1 parent f3503ca commit c62b20e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,19 @@ class FeatureFlagConfig {
/// Force specific experiments to always assign a specific variation (QA).
final Map<String, int> forcedVariations;

/// Feature flag service host url
final String hostUrl;

/// Feature flag service client key
final String clientKey;

FeatureFlagConfig({
this.attributes = const <String, dynamic>{},
this.qaMode = false,
this.enable = true,
this.forcedVariations = const <String, int>{},
this.features = const {},
required this.hostUrl,
required this.clientKey,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class DerivGrowthBook extends BaseGrowthBook implements GrowthBookConfig {

DerivGrowthBook({required FeatureFlagConfig featureFlagConfig}) {
_gbsdkBuilderApp = GBSDKBuilderApp(
hostURL: GrowthBookConfig.gbHostUrl,
apiKey: GrowthBookConfig.gbClientKey,
hostURL: featureFlagConfig.hostUrl,
apiKey: featureFlagConfig.clientKey,
attributes: featureFlagConfig.attributes,
enable: featureFlagConfig.enable,
qaMode: featureFlagConfig.qaMode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import 'dart:developer' as logger;
import 'package:deriv_env/env.dart';
import 'package:growthbook_sdk_flutter/growthbook_sdk_flutter.dart';

/// A class that contains the whole GrowthBook config data.
class GrowthBookConfig {
/// Determine the GrowthBook client api key.
static String get gbClientKey => Env().get<String>('GROWTHBOOK_API_KEY');

/// Determine the Growth Book Host URL.
static String get gbHostUrl => Env().get<String>('GROWTHBOOK_HOST_URL');

/// Convert client side FeatureFlags to GrowthBook FeatureFlags.
static Map<String, GBFeature> gbFeatures(Map<String, dynamic> features) {
if (features.isEmpty) {
Expand Down
7 changes: 1 addition & 6 deletions packages/deriv_feature_flag/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
name: deriv_feature_flag
description: A new Flutter package project.
description: wrapper to handle feature flag for deriv applications
version: 0.1.0
publish_to: none

environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
deriv_env:
git:
url: [email protected]:regentmarkets/flutter-deriv-packages.git
path: packages/deriv_env
ref: deriv_env-v0.0.1+1
flutter:
sdk: flutter
growthbook_sdk_flutter: ^3.0.0+0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'mock_classes.dart';

void main() async {
final FeatureFlagConfig featureFlagConfig = FeatureFlagConfig(
hostUrl: '',
clientKey: '',
features: {
Features.isSocialAuthEnabled.key: GBFeature(defaultValue: true),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'mock_classes.dart';
void main() {
final mockGrowthBookSDK = MockGrowthBookSDK();
final FeatureFlagConfig featureFlagConfig = FeatureFlagConfig(
hostUrl: '',
clientKey: '',
features: {
Features.isSocialAuthEnabled.key: GBFeature(defaultValue: true),
},
Expand Down

0 comments on commit c62b20e

Please sign in to comment.