-
Notifications
You must be signed in to change notification settings - Fork 31
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
Adding error handling for iOS #1334
Conversation
PackageInfo packageInfo = await PackageInfo.fromPlatform(); | ||
final retryClient = RetryClient( | ||
http.Client(), | ||
retries: 10, | ||
); | ||
|
||
await retryClient.post( | ||
Uri.parse(Config.slackWebhookUrl), | ||
headers: { | ||
HttpHeaders.contentTypeHeader: 'application/json', | ||
}, | ||
body: jsonEncode({ | ||
'text': "Exception: ${exception.toString()}\n\n " | ||
"App details: $packageInfo\n\n " | ||
"StackTrace: $stackTrace\n\n", | ||
}), | ||
); | ||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending errors slack
if (!Platform.isAndroid) { | ||
if (fatal) { | ||
await AirqoApiClient.sendErrorToSlack(exception as Object, stackTrace); | ||
} | ||
|
||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending iOS errors to slack
static String get placesSearchUrl => | ||
'https://maps.googleapis.com/maps/api/place/'; | ||
|
||
static String get appStoreUrl => | ||
'https://apps.apple.com/ug/app/airqo-monitoring-air-quality/id1337573091'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup
Future<AppStoreVersion?> latestVersion() async { | ||
AppStoreVersion? appStoreVersion; | ||
|
||
try { | ||
final PackageInfo packageInfo = await PackageInfo.fromPlatform(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic transferred to API
if (queryParams.isNotEmpty) { | ||
url = '$url?'; | ||
queryParams.forEach( | ||
(key, value) { | ||
url = queryParams.keys.first.compareTo(key) == 0 | ||
? '$url$key=$value' | ||
: '$url&$key=$value'; | ||
}, | ||
); | ||
} | ||
String formattedUrl = '$url?TOKEN=${Config.airqoApiV2Token}'; | ||
queryParams | ||
.forEach((key, value) => formattedUrl = "$formattedUrl&$key=$value"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifying the code
// checking first code | ||
if (versionSections.first > candidateSections.first) return 1; | ||
|
||
if (versionSections.first < candidateSections.first) return -1; | ||
|
||
// checking second code | ||
if (versionSections[1] > candidateSections[1]) return 1; | ||
|
||
if (versionSections[1] < candidateSections[1]) return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic transferred to the APIs
Update rest_api.dart
8b54eb5
to
72cbaf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @noahnsimbe , this looks good to me! Thanks!
Based on the details of the PR, I will just go ahead and merge it to make things timely!
Thanks!
Summary of Changes (What does this PR do?)
Status of maturity (all need to be checked before merging):
How should this be manually tested?
What are the relevant tickets?
Screenshots (optional)