-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add web3 usage metrics, prepare for web3 removal (#9144)
* add web3 usage metrics * move web3 metrics method to new middleware * rename some methods, files, and exports
- Loading branch information
Showing
8 changed files
with
114 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/scripts/lib/backend-metametrics.js → app/scripts/lib/background-metametrics.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Returns a middleware that implements the following RPC methods: | ||
* - metamask_logInjectedWeb3Usage | ||
* | ||
* @param {Object} opts - The middleware options | ||
* @param {string} opts.origin - The origin for the middleware stack | ||
* @param {Function} opts.sendMetrics - A function for sending a metrics event | ||
* @returns {(req: any, res: any, next: Function, end: Function) => void} | ||
*/ | ||
export default function createMethodMiddleware ({ origin, sendMetrics }) { | ||
return function methodMiddleware (req, res, next, end) { | ||
switch (req.method) { | ||
|
||
case 'metamask_logInjectedWeb3Usage': | ||
|
||
const { action, name } = req.params[0] | ||
|
||
sendMetrics({ | ||
action, | ||
name, | ||
customVariables: { origin }, | ||
}) | ||
|
||
res.result = true | ||
break | ||
|
||
default: | ||
return next() | ||
} | ||
return end() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters