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

Adding error handling for iOS #1334

Merged
merged 8 commits into from
Jul 11, 2023
Merged

Adding error handling for iOS #1334

merged 8 commits into from
Jul 11, 2023

Conversation

noahnsimbe
Copy link
Contributor

@noahnsimbe noahnsimbe commented Jul 7, 2023

Summary of Changes (What does this PR do?)

  • Adds slack error handling for iOS.
  • Migrates logic for checking for outdated versions to the backend.
  • Removes unused constants.
  • Simplifies the codebase.

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done
  • This change ready to hit production in its current state
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included issue number in the "Closes #ISSUE-NUMBER" part of the "What are the relevant tickets?" section to link the issue.
  • I've updated corresponding documentation for the changes in this PR.
  • I have written unit and/or e2e tests for my change(s).

How should this be manually tested?

  • Please include the steps to be done inorder to setup and test this PR.

What are the relevant tickets?

Screenshots (optional)

Comment on lines +119 to +136
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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending errors slack

Comment on lines +30 to +36
if (!Platform.isAndroid) {
if (fatal) {
await AirqoApiClient.sendErrorToSlack(exception as Object, stackTrace);
}

return;
}
Copy link
Contributor Author

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

Comment on lines -62 to -66
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';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup

Comment on lines -113 to -118
Future<AppStoreVersion?> latestVersion() async {
AppStoreVersion? appStoreVersion;

try {
final PackageInfo packageInfo = await PackageInfo.fromPlatform();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic transferred to API

Comment on lines -15 to +20
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");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplifying the code

Comment on lines -692 to -700
// 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;
Copy link
Contributor Author

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
Copy link
Collaborator

@Baalmart Baalmart left a 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!

@Baalmart Baalmart merged commit 9d8336e into staging Jul 11, 2023
21 of 23 checks passed
@Baalmart Baalmart deleted the mobile-error-handling branch July 11, 2023 06:07
@Baalmart Baalmart mentioned this pull request Jul 11, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants