Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add more encryption properties to PostHog #12415

Merged
merged 13 commits into from
May 16, 2024

Conversation

uhoreg
Copy link
Member

@uhoreg uhoreg commented Apr 12, 2024

Fixes element-hq/element-web#27168

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • Sign-off given on the changes (see CONTRIBUTING.md).

@uhoreg uhoreg requested a review from a team as a code owner April 12, 2024 00:53
@uhoreg uhoreg marked this pull request as draft April 12, 2024 00:54
@uhoreg
Copy link
Member Author

uhoreg commented Apr 12, 2024

Sorry, forgot to create this PR as a draft

@uhoreg uhoreg added the T-Task Refactoring, enabling or disabling functionality, other engineering tasks label Apr 12, 2024
@uhoreg

This comment was marked as resolved.

@uhoreg
Copy link
Member Author

uhoreg commented Apr 17, 2024

@BillCarsonFr what does the userTrustsOwnIdentity flag in the PostHog schema represent? I'm trying to figure out how to map it to the functions that the crypto API gives us. Is isCrossSigningReady good enough?

@uhoreg
Copy link
Member Author

uhoreg commented May 3, 2024

merged latest develop

Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

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

LGTM

@uhoreg uhoreg requested review from richvdh and robintown May 7, 2024 16:26
@uhoreg
Copy link
Member Author

uhoreg commented May 7, 2024

Oh, it still needs an Element Web reviewer. I've requested review from Robin and Rich because those were the people GitHub had randomly chosen initially.

src/DecryptionFailureTracker.ts Show resolved Hide resolved
src/DecryptionFailureTracker.ts Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
@uhoreg uhoreg requested a review from richvdh May 13, 2024 23:08
@uhoreg
Copy link
Member Author

uhoreg commented May 13, 2024

I think that I've addressed all the requested changes.

*
* @param {function} fn The tracking function, which will be called when failures
* are tracked. The function should have a signature `(count, trackedErrorCode) => {...}`,
* where `count` is the number of failures and `errorCode` matches the output of `errorCodeMapFn`.
* are tracked. The function should have a signature `(trackedErrorCode, rawError, properties) => {...}`,
Copy link
Member

Choose a reason for hiding this comment

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

[I'm not convinced it's correct that this function is called when failures are "tracked", but that's an existing problem I guess.]

src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
src/DecryptionFailureTracker.ts Outdated Show resolved Hide resolved
* @param matrixEvent the event that was decrypted
*
* @param nowTs the current timestamp
*/
public eventDecrypted(e: MatrixEvent, nowTs: number): void {
Copy link
Member

Choose a reason for hiding this comment

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

this should probably not be public any more?

Copy link
Member Author

Choose a reason for hiding this comment

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

On the one hand, I agree. On the other hand, I'm not particularly excited about littering DecryptionFailureTracker-test.ts with a ton of @ts-ignores

Comment on lines 192 to 195
/** Callback for when an event is decrypted.
*
* This function should be called after a decryption attempt on an event. It
* should be called whether the decryption is successful or not.
Copy link
Member

Choose a reason for hiding this comment

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

As an alternative to making this private:

Suggested change
/** Callback for when an event is decrypted.
*
* This function should be called after a decryption attempt on an event. It
* should be called whether the decryption is successful or not.
/** Callback for when an event is decrypted, successfully or otherwise.
*
* It is unnecessary to call this function explicitly: it is automatically called on a decryption event.
* It is only exposed for testing.

(I'd probably vote in favour of the ts-ignore dance for unit tests. You could probably even encapsulate it in a single helper method in the test. But at this point I think we should just land this rather than attempting to gold-plate it.)

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 actually like the idea of encapsulating it in a helper function, so I'm doing that. (I'm also updating the doc comment to say that it's called by the event handler, rather than saying that it should be called.)

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

LGTM

@uhoreg uhoreg added this pull request to the merge queue May 16, 2024
Merged via the queue into matrix-org:develop with commit eed8d15 May 16, 2024
27 checks passed
@uhoreg uhoreg deleted the posthog_decryption_stats branch May 16, 2024 00:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Task Refactoring, enabling or disabling functionality, other engineering tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crypto | Add more properties to unable to decrypt Posthog events to allow more filtering
3 participants