Bug: Many send-tab telemetry events are missing metadata about the peer device
Status: RESOLVED
Priority: P1
Resolution: FIXED
Created: 2020-05-21 10:23:26+00:00
Resolved: 2020-07-09 02:20:42+00:00

The sync ping contains "command-sent" and "command-received" events designed to measure the success rate of send-tab. Ideally, for each such event we would be able to locate the peer device (that is, the device to which our device sent a tab, or from which our device received a tab) as an item in the `devices` list from the sync ping, and thereby find out its basic device metadata like type and version.

This [redash query](https://sql.telemetry.mozilla.org/queries/71320/source#179175) explores what percentage of events do not have info about the peer device in their sync ping devices list. Key points:

* Around 20% of events contain the id of the peer device, but do not have it as an entry in the devices list of the containing sync ping.
* A further 15% to 20% of events do not have any info about the peer device at all, not even its id.

The second part is like due to Bug 1639835, but that first 20% is a bit of a mystery.

I was able to find an example of such a ping in my local archive, which I'm happy to share for reference:

```
15/05/2020 14:15
{
  "os": {
    "installYear": 2019,
    "hasSuperfetch": true,
    "hasPrefetch": true,
    "name": "Windows_NT",
    "version": "10.0",
    "locale": "en-AU",
    "servicePackMajor": 0,
    "servicePackMinor": 0,
    "windowsBuildNumber": 19041,
    "windowsUBR": 264
  },
  "why": "shutdown",
  "devices": [
    {
      "id": "04dca4827ac13596a49ce634d0a32f55e2ef4c42962680705be09dad8bbd1df5",
      "type": "desktop"
    }
  ],
  "version": 1,
  "syncs": [
    // omitted 
  ],
  "uid": "333412aa09dc23fd3a671315e275578b",
  "syncNodeType": "spanner",
  "deviceID": "04dca4827ac13596a49ce634d0a32f55e2ef4c42962680705be09dad8bbd1df5",
  "sessionStartDate": "2020-05-15T11:00:00.0+10:00",
  "events": [
    [
      9968860,
      "sync",
      "open-uri",
      "command-sent",
      "83499eeabbcc046a7c3c948d0d5753b133b2bc80a24edc8138bf7228e9335fd9",
      {
        "flowID": "d50437b4-8fa5-402d-9c19-5d8bf98ddebb",
        "serverTime": "1589515308.06"
      }
    ],
    [
      10026313,
      "sync",
      "open-uri",
      "command-received",
      "aabea7d669d1f567a60536ab7e2f800b08b56ae58853f575405f87aa7bc5c71a"
    ],
    [
      10168188,
      "sync",
      "open-uri",
      "command-sent",
      "aabea7d669d1f567a60536ab7e2f800b08b56ae58853f575405f87aa7bc5c71a",
      {
        "flowID": "808a2d1e-f576-4553-a9f0-56761b0bce44",
        "serverTime": "1589515910.14"
      }
    ]
  ],
  "histograms": {
      // omitted
  }
}
```

This ping shows me sending a tab to device `83499eeabbcc046a7c3c948d0d5753b133b2bc80a24edc8138bf7228e9335fd9`, and both sending to and receiving from device `aabea7d669d1f567a60536ab7e2f800b08b56ae58853f575405f87aa7bc5c71a`. Neither of those devices appear in the `devices` list, which includes only the current device `04dca4827ac13596a49ce634d0a32f55e2ef4c42962680705be09dad8bbd1df5`.

I understand that we can't necessarily include the full list of peer devices in every sync ping, because sometimes it's very large and has lots of duplicates. But is there something we can do to ensure that it at least includes all the devices that are referenced elsewhere in the ping?