Commit beeab74
authored
feat!: track analytics for OTA Snap updates (#4049)
## Changes
- Emit `SnapController:snapUpdated` in `#handleRegistryUpdate()` after
each successful OTA update. As a side effect, this also fixes missing
notifications to `CronjobController` (cronjob re-registration) and
`WebSocketService` (connection teardown) on OTA updates.
- Add `ota: boolean` to the `SnapControllerSnapUpdatedEvent` payload to
distinguish OTA updates from user-initiated ones.
- Update the `snapUpdated` analytics subscriber to track the `Snap
Updated` event for OTA updates (previously all preinstalled Snap updates
were silently skipped).
- Add `ota`, `client_version`, and `client_type` properties to the `Snap
Updated` analytics event.
- Add `clientConfig: ClientConfig` to `SnapControllerArgs` (same shape
as `SnapRegistryControllerArgs`) to give the controller access to the
client type and version.
## Breaking changes
- The `SnapController` constructor now requires a `clientConfig`
parameter.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Breaking constructor and messenger event contract changes require host
app updates; analytics and lifecycle side effects on OTA updates are new
behavior for preinstalled snaps.
>
> **Overview**
> **`SnapController:snapUpdated`** gains a fifth payload field **`ota`**
so listeners can tell over-the-air registry updates apart from
user-driven ones. After a successful preinstalled snap OTA in
**`#handleRegistryUpdate`**, the controller now **publishes** that event
with **`ota: true`** (and **`preinstalled: true`**), which also drives
**cronjob re-registration** and **WebSocket teardown** that previously
did not run on OTA.
>
> The **`Snap Updated`** analytics handler no longer skips every
preinstalled update: it still skips when **`preinstalled && !ota`**, but
**records OTA** with **`ota: true`**. All tracked **`Snap Updated`**
events now include **`ota`**, **`client_version`**, and
**`client_type`** from a new required constructor arg **`clientConfig`**
(same **`ClientConfig`** shape as the registry controller).
>
> **Breaking:** **`SnapController`** must be constructed with
**`clientConfig`**, and any code that publishes or asserts on
**`snapUpdated`** must pass the **`ota`** boolean.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7ea3aad. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 4755cab commit beeab74
6 files changed
Lines changed: 127 additions & 11 deletions
File tree
- packages/snaps-controllers/src
- cronjob
- snaps
- registry
- test-utils
- websocket
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
779 | 779 | | |
780 | 780 | | |
781 | 781 | | |
| 782 | + | |
782 | 783 | | |
783 | 784 | | |
784 | 785 | | |
| |||
Lines changed: 89 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6651 | 6651 | | |
6652 | 6652 | | |
6653 | 6653 | | |
| 6654 | + | |
6654 | 6655 | | |
6655 | 6656 | | |
6656 | 6657 | | |
| |||
9327 | 9328 | | |
9328 | 9329 | | |
9329 | 9330 | | |
| 9331 | + | |
9330 | 9332 | | |
9331 | 9333 | | |
9332 | 9334 | | |
| |||
10537 | 10539 | | |
10538 | 10540 | | |
10539 | 10541 | | |
| 10542 | + | |
10540 | 10543 | | |
10541 | 10544 | | |
10542 | 10545 | | |
10543 | 10546 | | |
10544 | 10547 | | |
10545 | 10548 | | |
| 10549 | + | |
10546 | 10550 | | |
10547 | | - | |
10548 | 10551 | | |
10549 | | - | |
10550 | 10552 | | |
10551 | | - | |
10552 | 10553 | | |
10553 | 10554 | | |
10554 | | - | |
10555 | 10555 | | |
| 10556 | + | |
| 10557 | + | |
| 10558 | + | |
10556 | 10559 | | |
| 10560 | + | |
10557 | 10561 | | |
10558 | 10562 | | |
10559 | 10563 | | |
| |||
10578 | 10582 | | |
10579 | 10583 | | |
10580 | 10584 | | |
| 10585 | + | |
10581 | 10586 | | |
10582 | 10587 | | |
10583 | 10588 | | |
| |||
11330 | 11335 | | |
11331 | 11336 | | |
11332 | 11337 | | |
| 11338 | + | |
| 11339 | + | |
| 11340 | + | |
| 11341 | + | |
| 11342 | + | |
| 11343 | + | |
| 11344 | + | |
| 11345 | + | |
| 11346 | + | |
| 11347 | + | |
| 11348 | + | |
| 11349 | + | |
| 11350 | + | |
| 11351 | + | |
| 11352 | + | |
| 11353 | + | |
| 11354 | + | |
| 11355 | + | |
| 11356 | + | |
| 11357 | + | |
| 11358 | + | |
| 11359 | + | |
| 11360 | + | |
| 11361 | + | |
| 11362 | + | |
| 11363 | + | |
| 11364 | + | |
| 11365 | + | |
| 11366 | + | |
| 11367 | + | |
| 11368 | + | |
| 11369 | + | |
| 11370 | + | |
| 11371 | + | |
| 11372 | + | |
| 11373 | + | |
| 11374 | + | |
| 11375 | + | |
| 11376 | + | |
| 11377 | + | |
| 11378 | + | |
| 11379 | + | |
| 11380 | + | |
| 11381 | + | |
| 11382 | + | |
| 11383 | + | |
| 11384 | + | |
| 11385 | + | |
| 11386 | + | |
| 11387 | + | |
| 11388 | + | |
| 11389 | + | |
| 11390 | + | |
| 11391 | + | |
| 11392 | + | |
| 11393 | + | |
| 11394 | + | |
| 11395 | + | |
| 11396 | + | |
| 11397 | + | |
| 11398 | + | |
| 11399 | + | |
| 11400 | + | |
| 11401 | + | |
| 11402 | + | |
| 11403 | + | |
| 11404 | + | |
| 11405 | + | |
| 11406 | + | |
| 11407 | + | |
| 11408 | + | |
| 11409 | + | |
| 11410 | + | |
| 11411 | + | |
| 11412 | + | |
| 11413 | + | |
| 11414 | + | |
| 11415 | + | |
11333 | 11416 | | |
11334 | 11417 | | |
11335 | 11418 | | |
| |||
13437 | 13520 | | |
13438 | 13521 | | |
13439 | 13522 | | |
| 13523 | + | |
13440 | 13524 | | |
13441 | 13525 | | |
13442 | 13526 | | |
| |||
13544 | 13628 | | |
13545 | 13629 | | |
13546 | 13630 | | |
| 13631 | + | |
13547 | 13632 | | |
13548 | 13633 | | |
13549 | 13634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| |||
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
| 464 | + | |
463 | 465 | | |
464 | 466 | | |
465 | 467 | | |
| |||
699 | 701 | | |
700 | 702 | | |
701 | 703 | | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
702 | 709 | | |
703 | 710 | | |
704 | 711 | | |
| |||
787 | 794 | | |
788 | 795 | | |
789 | 796 | | |
| 797 | + | |
| 798 | + | |
790 | 799 | | |
791 | 800 | | |
792 | 801 | | |
| |||
831 | 840 | | |
832 | 841 | | |
833 | 842 | | |
| 843 | + | |
834 | 844 | | |
835 | 845 | | |
836 | 846 | | |
| |||
911 | 921 | | |
912 | 922 | | |
913 | 923 | | |
| 924 | + | |
914 | 925 | | |
915 | 926 | | |
916 | 927 | | |
| |||
978 | 989 | | |
979 | 990 | | |
980 | 991 | | |
981 | | - | |
| 992 | + | |
982 | 993 | | |
983 | 994 | | |
984 | 995 | | |
| |||
989 | 1000 | | |
990 | 1001 | | |
991 | 1002 | | |
992 | | - | |
| 1003 | + | |
993 | 1004 | | |
994 | 1005 | | |
995 | 1006 | | |
| |||
999 | 1010 | | |
1000 | 1011 | | |
1001 | 1012 | | |
| 1013 | + | |
1002 | 1014 | | |
1003 | | - | |
1004 | 1015 | | |
1005 | | - | |
1006 | 1016 | | |
1007 | | - | |
1008 | 1017 | | |
1009 | 1018 | | |
1010 | | - | |
1011 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
1012 | 1023 | | |
| 1024 | + | |
1013 | 1025 | | |
1014 | 1026 | | |
1015 | 1027 | | |
| |||
1485 | 1497 | | |
1486 | 1498 | | |
1487 | 1499 | | |
| 1500 | + | |
1488 | 1501 | | |
1489 | 1502 | | |
1490 | 1503 | | |
| |||
1641 | 1654 | | |
1642 | 1655 | | |
1643 | 1656 | | |
| 1657 | + | |
1644 | 1658 | | |
1645 | 1659 | | |
1646 | 1660 | | |
| |||
1655 | 1669 | | |
1656 | 1670 | | |
1657 | 1671 | | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
1658 | 1681 | | |
1659 | 1682 | | |
1660 | 1683 | | |
| |||
2836 | 2859 | | |
2837 | 2860 | | |
2838 | 2861 | | |
| 2862 | + | |
2839 | 2863 | | |
2840 | 2864 | | |
2841 | 2865 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
607 | 607 | | |
608 | 608 | | |
609 | 609 | | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
610 | 614 | | |
611 | 615 | | |
612 | 616 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
491 | 492 | | |
492 | 493 | | |
493 | 494 | | |
| |||
0 commit comments