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

Troubleshoot notifications screen #2596

Merged
merged 27 commits into from
Apr 2, 2024
Merged

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Mar 22, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Add a troubleshoot notification screen with tests to help users understand why notification are not working.

Test coverage:
image

Remaining work (will be done in a separate PR):

  • Add a link to report an issue if at least one test is failing (this will also be added to the user story).
  • Improve logs: give more details about the failing tests, like outputting a report
  • Improve analytics: give details about the failing tests.
  • Add tests about the current push rules. In particular the app could show a list of muted rooms.

Motivation and context

Closes #2601

Screenshots / GIFs

Firebase UnifiedPush Quick fix
image image image

and recorded screenshot

Tests

  • Navigate to Setttings / Notification / Troubleshoot notifications
  • Run the tests

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

Copy link
Contributor

github-actions bot commented Mar 22, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/SmCSsH

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 74.88372% with 162 lines in your changes are missing coverage. Please review.

Project coverage is 73.37%. Comparing base (609f636) to head (5310456).
Report is 2 commits behind head on develop.

Files Patch % Lines
...troubleshoot/impl/TroubleshootNotificationsView.kt 71.83% 2 Missing and 18 partials ⚠️
...id/services/analytics/impl/DefaultScreenTracker.kt 0.00% 13 Missing ⚠️
...s/pushproviders/unifiedpush/UnifiedPushProvider.kt 0.00% 11 Missing ⚠️
...braries/push/impl/DefaultGetCurrentPushProvider.kt 0.00% 10 Missing ⚠️
...s/pushproviders/firebase/IsPlayServiceAvailable.kt 0.00% 9 Missing ⚠️
.../android/libraries/push/impl/DefaultPushService.kt 0.00% 7 Missing ⚠️
...ders/unifiedpush/UnifiedPushDistributorProvider.kt 0.00% 7 Missing ⚠️
...ment/android/libraries/push/impl/PushersManager.kt 0.00% 6 Missing ⚠️
...s/push/impl/notifications/NotificationDisplayer.kt 0.00% 6 Missing ⚠️
...ies/pushproviders/firebase/FirebasePushProvider.kt 0.00% 6 Missing ⚠️
... and 29 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2596      +/-   ##
===========================================
+ Coverage    73.23%   73.37%   +0.14%     
===========================================
  Files         1428     1459      +31     
  Lines        34585    35177     +592     
  Branches      6682     6752      +70     
===========================================
+ Hits         25328    25812     +484     
- Misses        5763     5851      +88     
- Partials      3494     3514      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bmarty bmarty force-pushed the feature/bma/troubleshootNotification branch 5 times, most recently from e78e9d6 to 5b186ae Compare March 27, 2024 21:17
@bmarty bmarty marked this pull request as ready for review March 28, 2024 08:02
@bmarty bmarty requested a review from a team as a code owner March 28, 2024 08:02
@bmarty bmarty requested review from jmartinesp and removed request for a team March 28, 2024 08:02
@bmarty bmarty changed the title Troubleshoot notifications screen WIP Troubleshoot notifications screen Mar 28, 2024
Copy link
Contributor

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

LGTM, just some suggestions. Thanks for the work on this!

suspend fun run(coroutineScope: CoroutineScope)
suspend fun reset()
suspend fun quickFix(coroutineScope: CoroutineScope) {
error("Quick fix not implemented, you need to override this method in your test")
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is an interface, wouldn't not providing a default implementation force any devs to implement this? It seems more effective than having it crash on runtime because someone forgot to override the default behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, but I guess the developer who add a test with a quick fix will test it and so see the error.
And since quick fix support is optional I prefer to provide a default implementation.

.value
.navigationState
.currentSessionId()
?.let { pushStoreFactory.create(it) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Not part of this PR, but maybe this pushStoreFactory.create(it) should be instead pushStoreFactory.get(it) or maybe getOrCreate? I found it weird that we're creating an extra PushStore here until I realised the create method would actually get an existing one if it's there.

Copy link
Member Author

@bmarty bmarty Apr 2, 2024

Choose a reason for hiding this comment

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

You're right: d592f3a.

sealed class PushGatewayFailure : Throwable(cause = null) {
data object PusherRejected : PushGatewayFailure()
sealed class PushGatewayFailure : Exception() {
class PusherRejected : PushGatewayFailure()
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is needed to trigger UI changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

I change this to fix this warning: Serializable object must implement 'readResolve' . Also I think it's better to extend Exception rather than Throwable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I was actually talking about the data object -> class change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think the warning was about the data object. I did not dig further...

import javax.inject.Inject

@SingleIn(AppScope::class)
class DiagnosticPushHandler @Inject constructor() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move this and NotificationClickHandle to a sub-package?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could create a subpackage per test, to ease the readability, but it's maybe over engineering since the package only have 6 classes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking about separating the handlers from the tests, but I guess it's not really worth it.

notificationClickHandler.state.first()
Timber.d("Notification clicked!")
}
val s = withTimeoutOrNull(30.seconds) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit hard to understand, IMO. Maybe we could use just withTimeout inside a try/catch block or runCatching, the successful path leading to the Success state and the catch clause for TimeoutCancellationException emitting the Failure case?

Copy link
Member Author

@bmarty bmarty Apr 2, 2024

Choose a reason for hiding this comment

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

Yes, good idea, thanks: 378a9c6.

@bmarty bmarty force-pushed the feature/bma/troubleshootNotification branch from c9f68ef to 378a9c6 Compare April 2, 2024 14:40
@ElementBot
Copy link
Collaborator

ElementBot commented Apr 2, 2024

Warnings
⚠️

features/messages/impl/src/main/res/values-be/translations.xml#L45 - For locale "be" (Belarusian) the following quantity should also be defined: few (e.g. "з 2 кніг за 2 дні")

⚠️

gradle/libs.versions.toml#L139 - A newer version of org.robolectric:robolectric than 4.11.1 is available: 4.12

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L7 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L12 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L21 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L29 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L42 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L50 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-cs/translations.xml#L65 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/push/impl/src/main/res/values-sk/translations.xml#L7 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/push/impl/src/main/res/values-sk/translations.xml#L12 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/push/impl/src/main/res/values-sk/translations.xml#L21 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/push/impl/src/main/res/values-sk/translations.xml#L29 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/push/impl/src/main/res/values-sk/translations.xml#L42 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/push/impl/src/main/res/values-sk/translations.xml#L50 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/push/impl/src/main/res/values-sk/translations.xml#L65 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/pushproviders/unifiedpush/src/main/res/values-cs/translations.xml#L5 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/pushproviders/unifiedpush/src/main/res/values-sk/translations.xml#L5 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L4 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L22 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L152 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-cs/translations.xml#L174 - For locale "cs" (Czech) the following quantity should also be defined: many (e.g. "10.0 dne")

⚠️

libraries/ui-strings/src/main/res/values-sk/translations.xml#L4 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/ui-strings/src/main/res/values-sk/translations.xml#L22 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/ui-strings/src/main/res/values-sk/translations.xml#L151 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

⚠️

libraries/ui-strings/src/main/res/values-sk/translations.xml#L173 - For locale "sk" (Slovak) the following quantity should also be defined: many (e.g. "10.0 dňa")

Generated by 🚫 dangerJS against 5310456

@bmarty bmarty force-pushed the feature/bma/troubleshootNotification branch from 3e20075 to cb435c5 Compare April 2, 2024 16:12
Copy link

sonarcloud bot commented Apr 2, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@bmarty bmarty merged commit f4076dc into develop Apr 2, 2024
16 checks passed
@bmarty bmarty deleted the feature/bma/troubleshootNotification branch April 2, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a notification troubleshoot screen
3 participants