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
|
|
|
|
2020-08-07 21:28:23 +02:00
|
|
|
export default function backgroundMetaMetricsEvent (metaMaskState, eventData) {
|
2020-08-09 05:42:36 +02:00
|
|
|
|
|
|
|
eventData.eventOpts['category'] = 'Background'
|
|
|
|
|
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,
|
Use `pathname` instead of URL for `currentPath` metrics parameter (#9158)
The `currentPath` parameter passed to our metrics utility had been
passed the full URL rather than just the path, contrary to what the
name would imply. We only used the path portion, so passing the full
URL did lead to complications.
Now just the `pathname` is passed in, rather than the full URL. This
simplifies the metrics logic, and it incidentally fixes two bugs.
The main bug fixed is regarding Firefox metrics. Previously we had
assumed the `currentPath` would start with `chrome-extension://`, which
of course was not true on Firefox. This lead to us incorrectly parsing
the `currentPath`, so path tracking was broken for Firefox events.
This broken parsing is now bypassed entirely, so metrics should now
work the same on Firefox as on Chrome.
The second bug was that we were incorrectly setting the tracking URL
for background events during tests. As a result, we were incorrectly
detecting ourselves as an internal site that had referred the user to
us. But this was not of major concern, since it only affected test
metrics (which get sent to the development Matomo project).
Lastly, this change let us discard the `pathname` parameter used in
the `overrides` parameter of the `metricsEvent` function. Now that
`currentPath` is equivalent to `pathname`, the `pathname` parameter is
redundant.
2020-08-07 20:32:46 +02:00
|
|
|
currentPath: '/background',
|
2019-07-31 22:17:11 +02:00
|
|
|
})
|
2019-04-29 08:18:40 +02:00
|
|
|
}
|
|
|
|
}
|