Skip to content

Commit

Permalink
fix bugs on dut
Browse files Browse the repository at this point in the history
  • Loading branch information
ABTastyAdel committed Feb 5, 2024
1 parent 1568cb3 commit f3dabe8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
6 changes: 3 additions & 3 deletions example/lib/Providers/fs_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import 'package:flutter/material.dart';

class FSData extends ChangeNotifier {
// Apikey
String _apiKey = ""; //
String _apiKey = "DxAcxlnRB9yFBZYtLDue1q01dcXZCw6aM49CQB23"; //
// EnvId
String _envId = ""; //
String _envId = "bkk9glocmjcg0vtmdlng"; //
// Mode
Mode _mode = Mode.DECISION_API;
// Timeout
Expand Down Expand Up @@ -63,7 +63,7 @@ class FSData extends ChangeNotifier {
}

class UserData extends ChangeNotifier {
String _visitorId = "QA6/11";
String _visitorId = "alias0502";
Map<String, Object> context = {
"testing_tracking_manager": true,
"condition1": "test"
Expand Down
4 changes: 2 additions & 2 deletions example/lib/widgets/Modifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Modifications extends StatefulWidget {
class _ModificationsState extends State<Modifications> {
var flagType = "string";
var defaultValueBool = false;
final keyFlagController = TextEditingController(text: "btnColor");
final keyFlagController = TextEditingController(text: "btnTitle");

final defaultValueFlagController = TextEditingController(text: "");

Expand Down Expand Up @@ -55,7 +55,7 @@ class _ModificationsState extends State<Modifications> {
defaultValue = jsonDecode(defaultValueFlagController.text);
}

myFlag = currentVisitor?.getFlag(keyFlagController.text, defaultValue);
myFlag = currentVisitor?.getFlag(keyFlagController.text, 12);

var ret = myFlag?.value();

Expand Down
26 changes: 24 additions & 2 deletions lib/dataUsage/data_report_queue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ String troubleShootingVersion = "1";
String stackType = "SDK";
String stackName = "Flutter";

// This enum describe the level gievn to hits Troubleshooting or DeveloperUsage
enum HitUsageLevel { INFO, WARNING, ERROR }

class DataReportQueue {
Service _reportService = Service(http.Client());

Expand Down Expand Up @@ -52,10 +55,19 @@ class TroubleshootingHit extends BaseHit {
Map<String, String> speceficCustomFields = {};
// Label for the critical point
String label = "";

// Level by default is INFO
HitUsageLevel hitLevelUsage = HitUsageLevel.INFO;

TroubleshootingHit(String aVisitorId, this.label, this.speceficCustomFields)
: super() {
// Set the type of hit
type = HitCategory.TROUBLESHOOTING;
// Set the visitorId
visitorId = aVisitorId;
// Update level log according to label
_updateLogLevel();
// Set the commun infos
_fillTheCommunFieldsAndCompleteWithCustom();
}

Expand Down Expand Up @@ -93,12 +105,22 @@ class TroubleshootingHit extends BaseHit {
"stack.version": FlagshipVersion,
"flagshipInstanceId":
Flagship.sharedInstance().flagshipInstanceId.toString(),
"logLevel":
Flagship.sharedInstance().getConfiguration()?.getLevel().name ?? "",
"logLevel": hitLevelUsage.name,
};

_communCustomFields.addEntries(this.speceficCustomFields.entries);
}

// Update level log according to label
_updateLogLevel() {
if (label.contains("WARNING") || label.contains("FLAG_NOT_FOUND")) {
hitLevelUsage = HitUsageLevel.WARNING;
} else if (label.contains("ERROR")) {
hitLevelUsage = HitUsageLevel.ERROR;
} else {
hitLevelUsage = HitUsageLevel.INFO;
}
}
}

class DataUsageHit extends TroubleshootingHit {
Expand Down
2 changes: 1 addition & 1 deletion lib/dataUsage/data_usage_tracking.dart
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ enum CriticalPoints {
// Trigger when the Flag.getValue method is called and no flag is found
GET_FLAG_VALUE_FLAG_NOT_FOUND,
// Trigger when the Flag.visitorExposed method is called and no flag is found
VISITOR_EXPOSED_FLAG_NO_FOUND,
VISITOR_EXPOSED_FLAG_NOT_FOUND,
// Trigger when the Flag.visitorExposed method is called and the flag value has a different type with default value
GET_FLAG_VALUE_TYPE_WARNING,
// Trigger when the SDK catches any other error but those listed here.
Expand Down
9 changes: 6 additions & 3 deletions lib/dataUsage/trouble_shooting.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ Map<String, String> _createSdkConfig(FlagshipConfig? sdkConfig) {
"sdk.config.trackingManager.strategy":
sdkConfig?.trackingManagerConfig.batchStrategy.name ?? "",
"sdk.config.trackingManager.batchIntervals":
sdkConfig?.trackingManagerConfig.batchIntervals.toString() ?? "",
((sdkConfig?.trackingManagerConfig.batchIntervals ?? 0) * 1000)
.toString(),
"sdk.config.timeout": sdkConfig?.timeout.toString() ?? "",
"sdk.config.pollingTime": sdkConfig?.pollingTime.toString() ?? "",
"sdk.config.pollingTime": ((sdkConfig?.pollingTime ?? 0) * 1000).toString(),
"sdk.config.mode": sdkConfig?.decisionMode.name ?? "",

"sdk.config.decisionApiUrl": Endpoints.DECISION_API,
"sdk.status": Flagship.getStatus().name,
"sdk.lastInitializationTimestamp":
Flagship.sharedInstance().lastInitializationTimestamp
Flagship.sharedInstance().lastInitializationTimestamp,
"sdk.config.logLevel":
Flagship.sharedInstance().getConfiguration()?.getLevel().name ?? ""
};
}

0 comments on commit f3dabe8

Please sign in to comment.