2020-06-01 19:54:32 +02:00
|
|
|
import { getBackgroundMetaMetricState } from '../../../ui/app/selectors'
|
2020-01-09 04:34:58 +01:00
|
|
|
import { sendMetaMetricsEvent } from '../../../ui/app/helpers/utils/metametrics.util'
|
2019-04-29 08:18:40 +02:00
|
|
|
|
|
|
|
const inDevelopment = process.env.NODE_ENV === 'development'
|
|
|
|
|
|
|
|
const METAMETRICS_TRACKING_URL = inDevelopment
|
|
|
|
? 'http://www.metamask.io/metametrics'
|
|
|
|
: 'http://www.metamask.io/metametrics-prod'
|
|
|
|
|
2020-05-06 00:19:38 +02:00
|
|
|
export default function backEndMetaMetricsEvent (metaMaskState, eventData) {
|
2020-06-01 19:54:32 +02:00
|
|
|
const stateEventData = getBackgroundMetaMetricState({ metamask: metaMaskState })
|
2019-04-29 08:18:40 +02:00
|
|
|
|
|
|
|
if (stateEventData.participateInMetaMetrics) {
|
2019-07-31 22:17:11 +02:00
|
|
|
sendMetaMetricsEvent({
|
|
|
|
...stateEventData,
|
|
|
|
...eventData,
|
Remove `url` parameter from `metricsEvent` (#9157)
* 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.
2020-08-07 19:57:27 +02:00
|
|
|
currentPath: METAMETRICS_TRACKING_URL + '/background',
|
2019-07-31 22:17:11 +02:00
|
|
|
})
|
2019-04-29 08:18:40 +02:00
|
|
|
}
|
|
|
|
}
|