Skip to content

Commit

Permalink
Fixed issue with report and issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
jigar-f committed Oct 4, 2023
1 parent 3095b99 commit bc174ab
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 38 deletions.
13 changes: 13 additions & 0 deletions internalsdk/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ import (
"github.com/getlantern/flashlight/v7/issue"
)

var issueMap = map[string]string{
"Cannot access blocked sites": "3",
"Cannot complete purchase": "0",
"Cannot sign in": "1",
"Spinner loads endlessly": "2",
"Slow": "4",
"Chat not working": "7",
"Discover not working": "8",
"Cannot link device": "5",
"Application crashes": "6",
"Other": "9",
}

func SendIssueReport(
session Session,
issueType string,
Expand Down
25 changes: 21 additions & 4 deletions internalsdk/session_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type SessionModel struct {
// Might be eaier to move all const at one place
// All keys are expose to front end so we can use same to avoid duplication and reduce error
const DEVICE_ID = "deviceid"
const DEVICE = "device"
const MODEL = "model"
const OS_VERSION = "os_version"
const PAYMENT_TEST_MODE = "paymentTestMode"
Expand Down Expand Up @@ -773,13 +774,16 @@ func userCreate(m *baseModel, local string) error {

func reportIssue(session *SessionModel, reportIssue ReportIssue) error {
// Check if email is there is yes then store it
if reportIssue.Email != " " {
if reportIssue.Email != "" {
err := pathdb.Mutate(session.db, func(tx pathdb.TX) error {
pathdb.Put[string](tx, EMAIL_ADDRESS, reportIssue.Email, "")
return nil
})
return err
if err != nil {
return err
}
}

//Check If user is pro or not
pro, proErr := session.IsProUser()
if proErr != nil {
Expand All @@ -801,9 +805,22 @@ func reportIssue(session *SessionModel, reportIssue ReportIssue) error {
// Get os version
osVersion, osVersionErr := session.db.Get(OS_VERSION)
if osVersionErr != nil {
return modelErr
return osVersionErr
}
reportIssueErr := SendIssueReport(session, "1", "This is testing desc", level, reportIssue.Email, "IPHONE", string(model), string(osVersion))
// Get os version
device, deviceErr := session.db.Get(DEVICE)
if deviceErr != nil {
return deviceErr
}
//Ignore the first value
// First value is type of value
deviceStr := string(device[1:])
osVersionStr := string(osVersion[1:])
modelStr := string(model[1:])
issueKey := issueMap[reportIssue.Issue]

log.Debugf("Report an issue index %v desc %v level %v email %v, device %v model %v version %v ", issueKey, reportIssue.Description, level, reportIssue.Email, deviceStr, modelStr, osVersionStr)
reportIssueErr := SendIssueReport(session, issueKey, reportIssue.Description, level, reportIssue.Email, deviceStr, modelStr, osVersionStr)
if reportIssueErr != nil {
return reportIssueErr
}
Expand Down
8 changes: 5 additions & 3 deletions ios/Runner/Lantern/Models/SessionModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,24 @@ class SessionModel: BaseModel<InternalsdkSessionModel> {
}

// Set initly data that needed by flashlight
// Set initly data that needed by flashlight
// later on values change be chaneg by mehtod or by flashlight
// later on values change be chaneg by methods or by flashlight
private func createInitData() -> [String: [String: Any]] {
let device = UIDevice.current
let deviceId = device.identifierForVendor!.uuidString
let model = device.model
let systemVersion = device.systemVersion
let systemName = device.systemName
let systemVersion = device.systemVersion
let langStr = Locale.current.identifier
return [
Constants.developmentMode: ["type": ValueUtil.TYPE_BOOL, "value": true],
Constants.prouser: ["type": ValueUtil.TYPE_BOOL, "value": false],
Constants.deviceid: ["type": ValueUtil.TYPE_STRING, "value": deviceId],
Constants.device: ["type": ValueUtil.TYPE_STRING, "value": systemName],
Constants.model: ["type": ValueUtil.TYPE_STRING, "value": model],
Constants.osVersion: ["type": ValueUtil.TYPE_STRING, "value": systemVersion],
Constants.playVersion: ["type": ValueUtil.TYPE_BOOL, "value": isRunningFromAppStore()],
Constants.lang: ["type": ValueUtil.TYPE_STRING, "value": langStr]

]
}

Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/Lantern/Utils/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct Constants {
static var developmentMode = InternalsdkDEVELOPMNET_MODE
static var prouser = InternalsdkPRO_USER
static var deviceid = InternalsdkDEVICE_ID
static var device = InternalsdkDEVICE_ID
static var device = InternalsdkDEVICE
static var model = InternalsdkMODEL
static var osVersion = InternalsdkOS_VERSION
static var playVersion = InternalsdkIS_PLAY_VERSION
Expand Down
69 changes: 39 additions & 30 deletions lib/account/report_issue.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:email_validator/email_validator.dart';
import 'package:lantern/common/common.dart';
import 'package:lantern/common/ui/app_loading_dialog.dart';

bool isEmpty(value) => value == null || value == '';

Expand Down Expand Up @@ -165,40 +166,48 @@ class _ReportIssueState extends State<ReportIssue> {
descFieldKey.currentState?.validate() ==
false,
text: 'send_report'.i18n,
onPressed: () async {
await sessionModel
.reportIssue(
emailController.value.text,
issueController.value.text,
descController.value.text)
.then((value) async {
CDialog.showInfo(
context,
title: 'report_sent'.i18n,
description:
'thank_you_for_reporting_your_issue'
.i18n,
actionLabel: 'continue'.i18n,
agreeAction: () async {
await context.pushRoute(Support());
return true;
},
);
}).onError((error, stackTrace) {
CDialog.showError(
context,
error: e,
stackTrace: stackTrace,
description: (error as PlatformException)
.message
.toString(), // This is coming localized
);
});
},
onPressed: onSendReportTap,
))),
])),
);
});
});
}

Future<void> onSendReportTap() async {
try {
AppLoadingDialog.showLoadingDialog(
context,
);
await sessionModel.reportIssue(emailController.value.text,
issueController.value.text, descController.value.text);

// For Android we have native dialog
// Todo need to remove native dialog and use this one for Android & IOS
if (Platform.isIOS) {
AppLoadingDialog.dismissLoadingDialog(context);
}
CDialog.showInfo(
context,
title: 'report_sent'.i18n,
description: 'thank_you_for_reporting_your_issue'.i18n,
actionLabel: 'continue'.i18n,
agreeAction: () async {
await context.pushRoute(Support());
return true;
},
);
} catch (error, stackTrace) {
if (Platform.isIOS) {
AppLoadingDialog.dismissLoadingDialog(context);
}

CDialog.showError(
context,
error: error,
stackTrace: stackTrace,
description: (error as PlatformException).message.toString(),
);
}
}
}
11 changes: 11 additions & 0 deletions lib/common/ui/app_loading_dialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:lantern/common/common.dart';

class AppLoadingDialog {
static void showLoadingDialog(BuildContext context) {
context.loaderOverlay.show(widget: spinner);
}

static void dismissLoadingDialog(BuildContext context) {
context.loaderOverlay.hide();
}
}

0 comments on commit bc174ab

Please sign in to comment.