Commit 8401e68
authored
feat!: add time-based delay for first metrics sending (#7624)
## Explanation
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
`ProfileMetricsController` is being overhauled to rely on a
timestamp-based delay for the first sending of metrics, rather than
waiting for a second App Unlock event. This change ensures that metrics
are sent even if the user only unlocks the app once during a session.
The delay is skipped immediately if:
- A transaction is submitted
- The user is already opted-in when `KeyringController:unlock` is fired
(this covers both users who have opted-in in a previous session, and
users who just onboarded and opted-in during onboarding).
- The consumer client calls the `.skipInitialDelay()` method or the
`ProfileMetricsController:skipInitialDelay` action via messenger.
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## Checklist
- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduces a timestamp-based initial delay for first profile metrics
send, with configurable duration and multiple skip paths.
>
> - Add `initialDelayEndTimestamp` state and default 10-minute delay;
constructor accepts `initialDelayDuration`
> - New `skipInitialDelay()` method and
`ProfileMetricsController:skipInitialDelay` action; auto-skip on
`KeyringController:unlock` when already opted-in and on
`TransactionController:transactionSubmitted`
> - Polling now starts on unlock; `_executePoll` exits until delay
completes; state metadata updated to persist/expose new field
> - BREAKING: messenger must allow
`TransactionController:transactionSubmitted`; add
`@metamask/transaction-controller` dependency and TS references; export
new method-action types; tests and README dependency graph updated
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
0237820. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 9dbe5d1 commit 8401e68
File tree
10 files changed
+378
-128
lines changed- packages/profile-metrics-controller
- src
10 files changed
+378
-128
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| |||
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| 362 | + | |
360 | 363 | | |
361 | 364 | | |
362 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
10 | 17 | | |
11 | 18 | | |
| 19 | + | |
| 20 | + | |
12 | 21 | | |
13 | 22 | | |
14 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments