2018-03-10 03:56:39 +01:00
|
|
|
# Development
|
|
|
|
|
2021-09-16 05:18:28 +02:00
|
|
|
Several files which are needed for developing on MetaMask.
|
2018-03-10 03:56:39 +01:00
|
|
|
|
2021-09-16 05:18:28 +02:00
|
|
|
Usually each file or directory contains information about its scope / usage.
|
2022-04-19 17:15:41 +02:00
|
|
|
|
|
|
|
## Segment
|
|
|
|
|
|
|
|
### Debugging with the Mock Segment API
|
|
|
|
|
|
|
|
To start the [Mock Segment API](./mock-segment.js):
|
|
|
|
|
|
|
|
- Add/replace the `SEGMENT_HOST` and `SEGMENT_WRITE_KEY` variables in `.metamaskrc`
|
|
|
|
```
|
|
|
|
SEGMENT_HOST='http://localhost:9090'
|
|
|
|
SEGMENT_WRITE_KEY='FAKE'
|
|
|
|
```
|
|
|
|
- Build the project to the `./dist/` folder with `yarn dist`
|
|
|
|
- Run the Mock Segment API from the command line
|
|
|
|
```
|
|
|
|
node development/mock-segment.js
|
|
|
|
```
|
|
|
|
|
|
|
|
Events triggered whilst using the extension will be logged to the console of the Mock Segment API.
|
|
|
|
|
|
|
|
More information on the API and its usage can be found [here](./mock-segment.js#L28).
|
|
|
|
|
|
|
|
### Debugging in Segment
|
|
|
|
|
|
|
|
To debug in a production Segment environment:
|
|
|
|
|
|
|
|
- Create a free account on [Segment](https://segment.com/)
|
|
|
|
- Create a New Workspace
|
|
|
|
- Add a Source (Node.js)
|
|
|
|
- Copy the `Write Key` from the API Keys section under Settings
|
|
|
|
- Add/replace the `SEGMENT_HOST` and `SEGMENT_WRITE_KEY` variables in `.metamaskrc`
|
|
|
|
```
|
|
|
|
SEGMENT_HOST='https://api.segment.io'
|
|
|
|
SEGMENT_WRITE_KEY='COPIED_WRITE_KEY'
|
|
|
|
```
|
|
|
|
- Build the project to the `./dist/` folder with `yarn dist`
|
|
|
|
|
|
|
|
Events triggered whilst using the extension will be displayed in Segment's Debugger.
|
|
|
|
|
|
|
|
### Debugging Segment requests in MetaMask
|
|
|
|
|
|
|
|
To opt in to MetaMetrics;
|
|
|
|
- Unlock the extension
|
|
|
|
- Open the Account menu
|
|
|
|
- Click the `Settings` menu item
|
|
|
|
- Click the `Security & Privacy` menu item
|
|
|
|
- Toggle the `Participate in MetaMetrics` menu option to the `ON` position
|
|
|
|
|
|
|
|
You can inspect the requests in the `Network` tab of your browser's Developer Tools (background.html)
|
|
|
|
by filtering for `POST` requests to `/v1/batch`. The full url will be `http://localhost:9090/v1/batch`
|
|
|
|
or `https://api.segment.io/v1/batch` respectively.
|