From f3dabe868752e9847aad6c73476aae865a7ad6f7 Mon Sep 17 00:00:00 2001 From: Adel Date: Mon, 5 Feb 2024 23:21:45 +0100 Subject: [PATCH] fix bugs on dut --- example/lib/Providers/fs_data.dart | 6 +++--- example/lib/widgets/Modifications.dart | 4 ++-- lib/dataUsage/data_report_queue.dart | 26 ++++++++++++++++++++++++-- lib/dataUsage/data_usage_tracking.dart | 2 +- lib/dataUsage/trouble_shooting.g.dart | 9 ++++++--- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/example/lib/Providers/fs_data.dart b/example/lib/Providers/fs_data.dart index 683d8f8..03c4073 100644 --- a/example/lib/Providers/fs_data.dart +++ b/example/lib/Providers/fs_data.dart @@ -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 @@ -63,7 +63,7 @@ class FSData extends ChangeNotifier { } class UserData extends ChangeNotifier { - String _visitorId = "QA6/11"; + String _visitorId = "alias0502"; Map context = { "testing_tracking_manager": true, "condition1": "test" diff --git a/example/lib/widgets/Modifications.dart b/example/lib/widgets/Modifications.dart index c060899..0d06414 100644 --- a/example/lib/widgets/Modifications.dart +++ b/example/lib/widgets/Modifications.dart @@ -17,7 +17,7 @@ class Modifications extends StatefulWidget { class _ModificationsState extends State { var flagType = "string"; var defaultValueBool = false; - final keyFlagController = TextEditingController(text: "btnColor"); + final keyFlagController = TextEditingController(text: "btnTitle"); final defaultValueFlagController = TextEditingController(text: ""); @@ -55,7 +55,7 @@ class _ModificationsState extends State { defaultValue = jsonDecode(defaultValueFlagController.text); } - myFlag = currentVisitor?.getFlag(keyFlagController.text, defaultValue); + myFlag = currentVisitor?.getFlag(keyFlagController.text, 12); var ret = myFlag?.value(); diff --git a/lib/dataUsage/data_report_queue.dart b/lib/dataUsage/data_report_queue.dart index bd7af96..2c4831c 100644 --- a/lib/dataUsage/data_report_queue.dart +++ b/lib/dataUsage/data_report_queue.dart @@ -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()); @@ -52,10 +55,19 @@ class TroubleshootingHit extends BaseHit { Map 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(); } @@ -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 { diff --git a/lib/dataUsage/data_usage_tracking.dart b/lib/dataUsage/data_usage_tracking.dart index 3cfb61b..4a44b20 100644 --- a/lib/dataUsage/data_usage_tracking.dart +++ b/lib/dataUsage/data_usage_tracking.dart @@ -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. diff --git a/lib/dataUsage/trouble_shooting.g.dart b/lib/dataUsage/trouble_shooting.g.dart index bcdfdf0..c713861 100644 --- a/lib/dataUsage/trouble_shooting.g.dart +++ b/lib/dataUsage/trouble_shooting.g.dart @@ -79,14 +79,17 @@ Map _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 ?? "" }; }