Skip to content

Fix metrics error when options are not used#9985

Merged
Gudahtt merged 1 commit intodevelopfrom
fix-metrics-without-options
Dec 3, 2020
Merged

Fix metrics error when options are not used#9985
Gudahtt merged 1 commit intodevelopfrom
fix-metrics-without-options

Conversation

@Gudahtt
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt commented Dec 3, 2020

Attempts to send metrics would fail when no options were used. This was because when the options parameter was not set, it was often sent over our RPC connection as undefined, which gets serialized to null when the message is converted to JSON. This null parameter didn't trigger the default parameter set in the metametrics controller, as default parameters are only used for undefined.

Instead the options parameter is now treated as fully optional, with no default value set. The optional chaining operator is used to ensure it won't blow up if it's not set. A fallback of {} was used for the one destructure case as well.

Attempts to send metrics would fail when no `options` were used. This
was because when the options parameter was not set, it was often sent
over our RPC connection as `undefined`, which gets serialized to `null`
when the message is converted to JSON. This `null` parameter didn't
trigger the default parameter set in the metametrics controller, as
default parameters are only used for `undefined`.

Instead the `options` parameter is now treated as fully optional, with
no default value set. The optional chaining operator is used to ensure
it won't blow up if it's not set. A fallback of `{}` was used for the
one destructure case as well.
@Gudahtt Gudahtt marked this pull request as ready for review December 3, 2020 17:18
@Gudahtt Gudahtt requested a review from a team as a code owner December 3, 2020 17:18
@Gudahtt Gudahtt requested a review from danjm December 3, 2020 17:18
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [7d72d9c]
Page Load Metrics (384 ± 40 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint317555168
domContentLoaded2815203828340
load2835213848340
domInteractive2815193828340

Copy link
Copy Markdown
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

@Gudahtt Gudahtt merged commit 703a063 into develop Dec 3, 2020
@Gudahtt Gudahtt deleted the fix-metrics-without-options branch December 3, 2020 19:05
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants