element-hq / element-hq/element-meta
Gather sender client information for UTDs via device keys info
- Dominant language
- No language data
- Stars
- 112
- Forks
- 25
- Avg merge
- 6h 6m
- Merged PRs (30d)
- 4
Description
In our analytics data (in Posthog), we want to be able to distinguish UTD events based on the client and version of the *sender* of the event (because often the problem is on the sender side rather than the recipient). The problem is that currently, we don't know this information.
It is proposed to resolve this as follows:
* Include information on client information in the device keys that are uploaded via `/keys/upload` and then downloaded via `/keys/query`.
* When we receive an undecryptable room message, locate the sending device via the `sender_key` (or `device_id`) embedded in the message, so that we can include the client metadata in the Posthog event.
Notes:
* We will need to update the legal team to ensure that the privacy policy is updated: https://github.com/element-hq/legal-compliance/issues/445.
* We will need to re-upload the device keys each time the client is upgraded to ensure the version is maintained. (This of course leads to races where, by the time a message is received, the sender has upgraded to a different client version. Hopefully that won't happen often enough to significantly impact the data.)
* Consider whether we should only expose this information for people who have opted into analytics. Or some other control. It does expose the client information to anyone on the internet who cares to ask, which could be seen as something of a privacy leak.
* Potential issue: `sender_key` and `device_id` are both [deprecated](https://spec.matrix.org/v1.10/client-server-api/#mmegolmv1aes-sha2). But they are still there today, and we don't see a good alternative, so we will use them for now and deal with the problem if/when they disappear.
# Implementation
Add an object like the following to the response to [`/keys/query`](https://spec.matrix.org/v1.11/client-server-api/#post_matrixclientv3keysquery):
```json
{
"io.element.client_data": {
"app_name": "Element",
"app_platform": "Web Platform",
"app_version": "1.11.70"
}
}
```
These properties are based on those already sent to Posthog.
It's worth noting that we can't simply add this data to the body of the key uploaded with [`/keys/upload`](https://spec.matrix.org/v1.11/client-server-api/#post_matrixclientv3keysupload), otherwise a change to `app_version` will invalidate any cross-signing signatures, and hence require re-verification of the device. Instead, we must add it to the `unsigned` section, but that isn't currently exposed via `/keys/upload`. In short, whatever we do, **we need server-side and spec changes**.
## Uploading the new data
Extend [`POST /keys/upload`](https://spec.matrix.org/v1.11/client-server-api/#post_matrixclientv3keysupload) to accept an `unsigned` property, which is then merged with the existing `unsigned` property for `/keys/query`.
# Tasks (note: most are closed to reduce noise, but not actually done)
```[tasklist]
## General
- [ ] https://github.com/element-hq/element-internal/issues/647
- [ ] https://github.com/element-hq/element-internal/issues/648
- [ ] https://github.com/element-hq/element-internal/issues/649
- [ ] https://github.com/element-hq/element-internal/issues/650
- [ ] https://github.com/element-hq/synapse/issues/17943
- [ ] https://github.com/element-hq/element-internal/issues/651
- [ ] https://github.com/element-hq/element-internal/issues/652
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4278
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4279
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4280
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4281
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4282
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4283
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4286
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4287
- [ ] https://github.com/matrix-org/matrix-rust-sdk/issues/4288
- [ ] https://github.com/element-hq/element-web/issues/28487
- [ ] https://github.com/element-hq/element-android/issues/8946
- [ ] https://github.com/element-hq/element-ios/issues/7873
- [ ] https://github.com/element-hq/element-x-android/issues/3888
- [ ] https://github.com/element-hq/element-x-ios/issues/3529
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.