Skip to content

Commit de9a2cc

Browse files
authored
Add PostHog codes for trust requirement failures (#28292)
* Add PostHog codes for trust requirement failures * add tests for new codes
1 parent 86bb0ec commit de9a2cc

File tree

4 files changed

+16
-33
lines changed

4 files changed

+16
-33
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"dependencies": {
8585
"@babel/runtime": "^7.12.5",
8686
"@formatjs/intl-segmenter": "^11.5.7",
87-
"@matrix-org/analytics-events": "^0.26.0",
87+
"@matrix-org/analytics-events": "^0.27.0",
8888
"@matrix-org/emojibase-bindings": "^1.3.3",
8989
"@vector-im/matrix-wysiwyg": "2.37.13",
9090
"@matrix-org/react-sdk-module-api": "^2.4.0",

src/DecryptionFailureTracker.ts

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export class DecryptionFailureTracker {
8282
return "HistoricalMessage";
8383
case DecryptionFailureCode.HISTORICAL_MESSAGE_USER_NOT_JOINED:
8484
return "ExpectedDueToMembership";
85+
case DecryptionFailureCode.SENDER_IDENTITY_PREVIOUSLY_VERIFIED:
86+
return "ExpectedVerificationViolation";
87+
case DecryptionFailureCode.UNSIGNED_SENDER_DEVICE:
88+
return "ExpectedSentByInsecureDevice";
8589
default:
8690
return "UnknownError";
8791
}

test/unit-tests/DecryptionFailureTracker-test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ describe("DecryptionFailureTracker", function () {
496496
await createAndTrackEventWithError(DecryptionFailureCode.HISTORICAL_MESSAGE_USER_NOT_JOINED);
497497
await createAndTrackEventWithError(DecryptionFailureCode.MEGOLM_KEY_WITHHELD);
498498
await createAndTrackEventWithError(DecryptionFailureCode.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE);
499+
await createAndTrackEventWithError(DecryptionFailureCode.SENDER_IDENTITY_PREVIOUSLY_VERIFIED);
500+
await createAndTrackEventWithError(DecryptionFailureCode.UNSIGNED_SENDER_DEVICE);
499501
await createAndTrackEventWithError(DecryptionFailureCode.UNKNOWN_ERROR);
500502

501503
// Pretend "now" is Infinity
@@ -510,6 +512,8 @@ describe("DecryptionFailureTracker", function () {
510512
"ExpectedDueToMembership",
511513
"OlmKeysNotSentError",
512514
"RoomKeysWithheldForUnverifiedDevice",
515+
"ExpectedVerificationViolation",
516+
"ExpectedSentByInsecureDevice",
513517
"UnknownError",
514518
]);
515519
});

yarn.lock

+7-32
Original file line numberDiff line numberDiff line change
@@ -1919,10 +1919,10 @@
19191919
resolved "https://registry.yarnpkg.com/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz#497c67a1cef50d1a2459ba60f315e448d2ad87fe"
19201920
integrity sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q==
19211921

1922-
"@matrix-org/analytics-events@^0.26.0":
1923-
version "0.26.0"
1924-
resolved "https://registry.yarnpkg.com/@matrix-org/analytics-events/-/analytics-events-0.26.0.tgz#7c8f8f924d8313c87951a0e941640ef8ff78f3d6"
1925-
integrity sha512-cjKZBejajUG8wPhVygMkBTwTLdEn74luUP6g6RjCUqPR3RYIl3NVi58Zil8CWfRTILb4wVLCPpAvehgXJn1HnQ==
1922+
"@matrix-org/analytics-events@^0.27.0":
1923+
version "0.27.0"
1924+
resolved "https://registry.yarnpkg.com/@matrix-org/analytics-events/-/analytics-events-0.27.0.tgz#5d983b82a82ba58d138dff778f3b7db34aa6a87d"
1925+
integrity sha512-ZNH8B+SUnZwcf0H+DjEZPFxmBYlYAEqZEF/yiAxyP85zn0qHfHm5nRx++BQdORAN4oaxcPW2sGbdULJyr64rGg==
19261926

19271927
"@matrix-org/emojibase-bindings@^1.3.3":
19281928
version "1.3.3"
@@ -10832,16 +10832,7 @@ string-length@^4.0.1:
1083210832
char-regex "^1.0.2"
1083310833
strip-ansi "^6.0.0"
1083410834

10835-
"string-width-cjs@npm:string-width@^4.2.0":
10836-
version "4.2.3"
10837-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
10838-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
10839-
dependencies:
10840-
emoji-regex "^8.0.0"
10841-
is-fullwidth-code-point "^3.0.0"
10842-
strip-ansi "^6.0.1"
10843-
10844-
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
10835+
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1084510836
version "4.2.3"
1084610837
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1084710838
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -10945,14 +10936,7 @@ string_decoder@~1.1.1:
1094510936
dependencies:
1094610937
safe-buffer "~5.1.0"
1094710938

10948-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
10949-
version "6.0.1"
10950-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
10951-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
10952-
dependencies:
10953-
ansi-regex "^5.0.1"
10954-
10955-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
10939+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1095610940
version "6.0.1"
1095710941
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1095810942
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -12040,16 +12024,7 @@ word-wrap@^1.2.5:
1204012024
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
1204112025
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
1204212026

12043-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
12044-
version "7.0.0"
12045-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
12046-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
12047-
dependencies:
12048-
ansi-styles "^4.0.0"
12049-
string-width "^4.1.0"
12050-
strip-ansi "^6.0.0"
12051-
12052-
wrap-ansi@^6.2.0, wrap-ansi@^7.0.0, wrap-ansi@^8.1.0, wrap-ansi@^9.0.0, "wrap-ansi@npm:wrap-ansi@^7.0.0":
12027+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^6.2.0, wrap-ansi@^7.0.0, wrap-ansi@^8.1.0, wrap-ansi@^9.0.0, "wrap-ansi@npm:wrap-ansi@^7.0.0":
1205312028
version "7.0.0"
1205412029
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1205512030
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

0 commit comments

Comments
 (0)