Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persisting segment events in MetaMetricsController store #16198

Merged
merged 37 commits into from
Nov 7, 2022

Conversation

jpuri
Copy link
Contributor

@jpuri jpuri commented Oct 13, 2022

Fixes #16173

PR address issue of segment events being lost in MV3 due to service worker restart. Events are now saved in MetaMetricsController store and resend to segment SDK till they are successfully submitted to segment.

@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@jpuri jpuri marked this pull request as ready for review October 13, 2022 13:32
@jpuri jpuri requested a review from a team as a code owner October 13, 2022 13:32
@jpuri jpuri marked this pull request as draft October 13, 2022 13:34
@metamaskbot
Copy link
Collaborator

Builds ready [0a7e086]
Page Load Metrics (2319 ± 124 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint86148105178
domContentLoaded190729202306262126
load190729202319259124
domInteractive190729202306262126

highlights:

storybook

@jpuri jpuri marked this pull request as ready for review October 14, 2022 01:07
@darkwing
Copy link
Contributor

Test failures look legit.

@metamaskbot
Copy link
Collaborator

Builds ready [0f5067f]
Page Load Metrics (2552 ± 77 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint972678483876421
domContentLoaded21592804251416177
load21592868255216177
domInteractive21592804251416177

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [0a6e834]
Page Load Metrics (2606 ± 224 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint96980214243117
domContentLoaded207240312594471226
load207240312606467224
domInteractive207240312594471226

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [c0889b9]
Page Load Metrics (2089 ± 118 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint942294222476229
domContentLoaded174324632064245118
load175424632089246118
domInteractive174324632064245118

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [9bfdae5]
Page Load Metrics (2573 ± 190 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1012191342813
domContentLoaded198133782530374180
load198134072573396190
domInteractive198133782530374180

highlights:

storybook


this.store = new ObservableStore({
participateInMetaMetrics: null,
participateInMetaMetrics: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to be null to start or we will track events before they opt in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ops my bad, thanks for catching this

@MetaMask MetaMask deleted a comment Nov 4, 2022
@MetaMask MetaMask deleted a comment Nov 4, 2022
@jpuri jpuri dismissed a stale review via 590758e November 4, 2022 09:10
@metamaskbot
Copy link
Collaborator

Builds ready [ef5ae4a]
Page Load Metrics (2419 ± 83 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1002238238460221
domContentLoaded21052777239718388
load21052777241917283
domInteractive21052777239718388

highlights:

storybook

@jpuri jpuri requested a review from darkwing November 4, 2022 15:44
@seaona
Copy link
Contributor

seaona commented Nov 7, 2022

@jpuri from QA looks good! I'm re-running Firefox e2e tests, as the installation script failed. Hopefully this fixes it!

@metamaskbot
Copy link
Collaborator

Builds ready [1805f8c]
Page Load Metrics (2055 ± 94 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint9112310594
domContentLoaded16722347203419895
load16722347205519594
domInteractive16722347203419895

highlights:

storybook

// and pass a callback to remove it from store once request is submitted to segment
// Saving segmentApiCalls in controller store in MV3 ensures that events are tracked
// even if service worker terminates before events are submiteed to segment.
_submitSegmentAPICall(eventType, payload, callback) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: in regards to eventType, why use event over method? I'm thinking events mean something different for data analytics and JavaScript

It could be helpful to add a description for eventType here. e.g.

@param {string} eventType - Segment API call name
@see {@link https://segment.com/docs/connections/spec/} 

Copy link
Contributor

@segun segun left a comment

Choose a reason for hiding this comment

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

LGTM

@jpuri jpuri dismissed darkwing’s stale review November 7, 2022 23:02

Dismissing as QA id done by Mariona

@jpuri jpuri merged commit e7deab4 into develop Nov 7, 2022
@jpuri jpuri deleted the segment_event_storage branch November 7, 2022 23:03
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-qa Label will automate into QA workspace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segment MV3 issue: fix segment events being lost due to service worker restart
7 participants