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

Remove url parameter from metricsEvent #9157

Merged
merged 2 commits into from
Aug 7, 2020
Merged

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Aug 7, 2020

The url parameter was used to override the currentPath, but it never worked correctly. It was supposed to be used for setting the url query parameter that was sent to Matomo, but currentPath was always used even if it url was set and currentPath was empty.

Instead, currentPath is now always used. There was never a need to provide an "override" for currentPath when it can be set directly. The metrics provider does set currentPath automatically by default, but this can be overwritten already by passing a second parameter to metricsEvent.

There were two places this url parameter was being used: background events, and path changes. Background events were submitted with no currentPath, so because of the bug with the url parameter, the metrics utility would crash upon each event. So those were never actually sent. This commit will fix that crash.

The currentPath parameter was supplied as an empty string for the path change events, so those never crashed. They just had the url query string parameter set incorrectly (to an empty string). It should now be correctly populated, which should mean we'll be capturing all path changes now. Previously we were only capturing path changes to pages that happened to include an event, because of this blank url problem.

@Gudahtt
Copy link
Member Author

Gudahtt commented Aug 7, 2020

This depends upon #9155
#9155 has been merged

Base automatically changed from change-background-metrics-event-category-name to develop August 7, 2020 16:45
The `url` parameter was used to override the `currentPath`, but it
never worked correctly. It was supposed to be used for setting the
`url` query parameter that was sent to Matomo, but `currentPath` was
always used even if it `url` was set and `currentPath` was empty.

Instead, `currentPath` is now always used. There was never a need to
provide an "override" for `currentPath` when it can be set directly.
The metrics provider does set `currentPath` automatically by default,
but this can be overwritten already by passing a second parameter to
`metricsEvent`.

There were two places this `url` parameter was being used: background
events, and path changes. Background events were submitted with no
`currentPath`, so because of the bug with the `url` parameter, the
metrics utility would crash upon each event. So those were never
actually sent. This commit will fix that crash.

The `currentPath` parameter was supplied as an empty string for the
path change events, so those never crashed. They just had the `url`
query string parameter set incorrectly (to an empty string). It should
now be correctly populated, which should mean we'll be capturing all
path changes now. Previously we were only capturing path changes to
pages that happened to include an event, because of this blank `url`
problem.
@Gudahtt Gudahtt force-pushed the remove-metrics-url-parameter branch from a81869f to 0979a30 Compare August 7, 2020 16:46
@Gudahtt Gudahtt marked this pull request as ready for review August 7, 2020 16:52
@Gudahtt Gudahtt requested a review from a team as a code owner August 7, 2020 16:52
@Gudahtt Gudahtt requested a review from danjm August 7, 2020 16:52
rekmarks
rekmarks previously approved these changes Aug 7, 2020
Copy link
Member

@rekmarks rekmarks left a comment

Choose a reason for hiding this comment

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

LGTM!

The `pv_id` parameter currently isn't generated correctly on Firefox,
as the generation assumes that the current URL starts with
`chrome-extension://`. The `url` query parameter is still unique for
each path, so it's probably good enough for generating an id for each
page.

This is just a temporary fix; it will be removed in a future PR, where
Firefox will be properly supported.
@Gudahtt Gudahtt force-pushed the remove-metrics-url-parameter branch from bc8031f to a4a276b Compare August 7, 2020 17:35
@metamaskbot
Copy link
Collaborator

Builds ready [a4a276b]
Page Load Metrics (571 ± 49 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint289337136
domContentLoaded31469456910249
load31869757110249
domInteractive31469356910249

@Gudahtt Gudahtt merged commit 8713927 into develop Aug 7, 2020
@Gudahtt Gudahtt deleted the remove-metrics-url-parameter branch August 7, 2020 17:57
Gudahtt added a commit that referenced this pull request Aug 7, 2020
* Remove `url` parameter from `metricsEvent`

The `url` parameter was used to override the `currentPath`, but it
never worked correctly. It was supposed to be used for setting the
`url` query parameter that was sent to Matomo, but `currentPath` was
always used even if it `url` was set and `currentPath` was empty.

Instead, `currentPath` is now always used. There was never a need to
provide an "override" for `currentPath` when it can be set directly.
The metrics provider does set `currentPath` automatically by default,
but this can be overwritten already by passing a second parameter to
`metricsEvent`.

There were two places this `url` parameter was being used: background
events, and path changes. Background events were submitted with no
`currentPath`, so because of the bug with the `url` parameter, the
metrics utility would crash upon each event. So those were never
actually sent. This commit will fix that crash.

The `currentPath` parameter was supplied as an empty string for the
path change events, so those never crashed. They just had the `url`
query string parameter set incorrectly (to an empty string). It should
now be correctly populated, which should mean we'll be capturing all
path changes now. Previously we were only capturing path changes to
pages that happened to include an event, because of this blank `url`
problem.

* Use `url` query parameter as fallback for generating `pv_id`

The `pv_id` parameter currently isn't generated correctly on Firefox,
as the generation assumes that the current URL starts with
`chrome-extension://`. The `url` query parameter is still unique for
each path, so it's probably good enough for generating an id for each
page.

This is just a temporary fix; it will be removed in a future PR, where
Firefox will be properly supported.
Gudahtt added a commit that referenced this pull request Aug 10, 2020
* origin/master: (44 commits)
  Add category in eventOpts (#9164)
  Update changelog for v8.0.7 (#9161)
  Version v8.0.7
  Remove web3 e2e tests (#9159)
  Add web3 usage metrics, prepare for web3 removal (#9144)
  Use `pathname` instead of URL for `currentPath` metrics parameter (#9158)
  Remove `url` parameter from `metricsEvent` (#9157)
  Change MetaMetrics category for background events (#9155)
  remove .network-name height
  Use [email protected] (#9154)
  Update 'react-devtools' to ^4.8.0 (#9140)
  Fix connection removal bug (#9137)
  Add source map validator to CI (#9135)
  Update source map validator target files (#9133)
  Improve sourcemap validator console report (#9131)
  Add `validate-source-maps` npm script (#9134)
  Non-zero exit code upon failure to validate source maps (#9132)
  Update `brfs` from v1.6.1 to v2.0.2 (#9115)
  Factor out `getEnvironment` function in build script (#9114)
  Update `browserify` from v16.2.3 to v16.5.1 (#9113)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants