mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Send web3 usage metrics once per origin/property (#9237)
The usage metrics for the injected web3 instance were being sent upon each use, which exceeded the limits of our Matomo plan. These metrics are now only being sent upon the first usage, for each origin and property.
This commit is contained in:
parent
aaacf66c6e
commit
f77151003e
@ -1,3 +1,6 @@
|
||||
|
||||
const recordedWeb3Usage = {}
|
||||
|
||||
/**
|
||||
* Returns a middleware that implements the following RPC methods:
|
||||
* - metamask_logInjectedWeb3Usage
|
||||
@ -15,11 +18,17 @@ export default function createMethodMiddleware ({ origin, sendMetrics }) {
|
||||
|
||||
const { action, name } = req.params[0]
|
||||
|
||||
sendMetrics({
|
||||
action,
|
||||
name,
|
||||
customVariables: { origin },
|
||||
})
|
||||
if (!recordedWeb3Usage[origin]) {
|
||||
recordedWeb3Usage[origin] = {}
|
||||
}
|
||||
if (!recordedWeb3Usage[origin][name]) {
|
||||
recordedWeb3Usage[origin][name] = true
|
||||
sendMetrics({
|
||||
action,
|
||||
name,
|
||||
customVariables: { origin },
|
||||
})
|
||||
}
|
||||
|
||||
res.result = true
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user