Skip to content
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

fix(deriv_feature_flag): remove env dependancy #477

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading