1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-28 15:22:05 +03:00

Add raw error to analytics E2E error event context (#8447)

* Add raw error to analytics E2E error context

* Fix code style

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Valere
2022-05-05 05:46:03 +02:00
committed by GitHub
parent f34b4f1182
commit 07d8070037
2 changed files with 31 additions and 3 deletions

View File

@ -57,6 +57,33 @@ describe('DecryptionFailureTracker', function() {
done();
});
it('tracks a failed decryption with expected raw error for a visible event', function(done) {
const failedDecryptionEvent = createFailedDecryptionEvent();
let count = 0;
let reportedRawCode = "";
const tracker = new DecryptionFailureTracker((total, errcode, rawCode) => {
count += total;
reportedRawCode = rawCode;
}, () => "UnknownError");
tracker.addVisibleEvent(failedDecryptionEvent);
const err = new MockDecryptionError('INBOUND_SESSION_MISMATCH_ROOM_ID');
tracker.eventDecrypted(failedDecryptionEvent, err);
// Pretend "now" is Infinity
tracker.checkFailures(Infinity);
// Immediately track the newest failures
tracker.trackFailures();
expect(count).not.toBe(0, 'should track a failure for an event that failed decryption');
expect(reportedRawCode).toBe('INBOUND_SESSION_MISMATCH_ROOM_ID', 'Should add the rawCode to the event context');
done();
});
it('tracks a failed decryption for an event that becomes visible later', function(done) {
const failedDecryptionEvent = createFailedDecryptionEvent();