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

Track decryption failures #4856

Merged
merged 2 commits into from
Jan 5, 2022
Merged

Track decryption failures #4856

merged 2 commits into from
Jan 5, 2022

Conversation

BillCarsonFr
Copy link
Member

Fixes #4719

Track and report failure to decrypt errors

@BillCarsonFr BillCarsonFr requested review from bmarty and ganfra January 5, 2022 09:25
@github-actions
Copy link

github-actions bot commented Jan 5, 2022

Unit Test Results

  66 files  ±0    66 suites  ±0   1m 12s ⏱️ +24s
135 tests ±0  135 ✔️ ±0  0 💤 ±0  0 ±0 
418 runs  ±0  418 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit b275546. ± Comparison against base commit 5efe1f4.

♻️ This comment has been updated with latest results.

Copy link
Member

@bmarty bmarty 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 need a small cleanup.

throw MXCryptoError.Base(
MXCryptoError.ErrorType.UNKNOWN_MESSAGE_INDEX,
throwable.olmException.message ?: "",
throwable.olmException.message)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: in this case we could use hard-coded "UNKNOWN_MESSAGE_INDEX" since this is the value of throwable.olmException.message

Copy link
Member Author

Choose a reason for hiding this comment

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

Udpated, I did put null in detailedReason; not sure what could be put here

private fun addDecryptionFailure(failure: DecryptionFailure) {
// de duplicate
synchronized(failures) {
if (failures.indexOfFirst { it.failedEventId == failure.failedEventId } == -1) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: use none instead of indexOfFirst

Copy link
Member Author

Choose a reason for hiding this comment

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

done

}

private fun checkFailures() {
val now = System.currentTimeMillis()
Copy link
Member

Choose a reason for hiding this comment

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

Please inject Clock in the constructor

Copy link
Member Author

Choose a reason for hiding this comment

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

added

@@ -122,6 +124,10 @@ class TimelineItemFactory @Inject constructor(private val messageItemFactory: Me
Timber.v("Type ${event.root.getClearType()} not handled")
defaultItemFactory.create(params)
}
}.also {
if (it != null && event.isEncrypted()) {
decryptionFailureTracker.e2eEventDisplayedInTimeline(event.roomId, event.eventId, event.root.mCryptoError)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just pass the TimelineEvent instead of 3 members of the TimelineEvent to simplify the signature of this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

import javax.inject.Inject
import javax.inject.Singleton

data class DecryptionFailure(
Copy link
Member

Choose a reason for hiding this comment

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

Could be private I think

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@BillCarsonFr BillCarsonFr force-pushed the feature/bca/posthog_e2e branch from e7c5ed8 to b275546 Compare January 5, 2022 15:43
*/
@Singleton
class DecryptionFailureTracker @Inject constructor(
private val vectorAnalytics: VectorAnalytics,
Copy link
Member

Choose a reason for hiding this comment

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

Note to myself: change to inject the new interface AnalyticsTracker from #4734

MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID -> Error.Name.OlmKeysNotSentError
MXCryptoError.ErrorType.OLM -> {
Error.Name.OlmUnspecifiedError
}
Copy link
Member

Choose a reason for hiding this comment

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

Just a small remark: why a different formatting here?

@bmarty bmarty merged commit fd854a6 into develop Jan 5, 2022
@bmarty bmarty deleted the feature/bca/posthog_e2e branch January 5, 2022 17:54
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.

Analytics: Track Errors
2 participants