Skip to content

Commit 50e9338

Browse files
committed
Use the 'glean' command in the JS web-extension sample
1 parent 49a64e5 commit 50e9338

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,6 @@ web-ext-artifacts/
121121

122122
# This is the name of the folder we will add the glean generated files in for our samples.
123123
generated/
124+
125+
# This is the name of the Glean virtual environment
126+
.venv

samples/web-extension/javascript/README.md

+7-15
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,28 @@ Whenever this web extensions popup is opened it will trigger Glean.js events.
1010
1111
## How to run this sample
1212

13-
1. Generate metrics and pings files.
14-
15-
```bash
16-
npm run glean_parser
17-
```
18-
19-
> This command requires that you have [`glean_parser`](https://pypi.org/project/glean-parser/) available.
20-
> glean_parser is a Python package. To install it run `pip install glean_parser`.
21-
> Javascript support was added to glean_parser on version 2.1.0, make sure your version is up to date.
22-
23-
2. Link the `@mozilla/glean` package. On the glean/ folder run:
13+
1. Link the `@mozilla/glean` package. On the glean/ folder run:
2414

2515
```bash
2616
npm link
2717
```
2818

29-
3. Link the `@mozilla/glean` package to this sample web extension. On this `web-extension` folder run:
19+
2. Link the `@mozilla/glean` package to this sample web extension. On this `web-extension` folder run:
3020

3121
```bash
22+
npm install
3223
npm link @mozilla/glean
3324
```
3425

35-
4. Build this sample. On this `web-extension` folder run:
26+
3. Build this sample. On this `web-extension` folder run:
3627

3728
```bash
38-
npm install
3929
npm run build
4030
```
4131

42-
5. Load the web extension on your browser of choice.
32+
> **Note** This operation will take some time on the first run, because it will create a virtual environment for running the glean-parser.
33+
34+
4. Load the web extension on your browser of choice.
4335

4436
- **Firefox**
4537
1. Go to [about:debugging#/runtime/this-firefox](about:debugging#/runtime/this-firefox);

samples/web-extension/javascript/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"description": "A sample web extension using Glean.js",
55
"main": "dist/bundle.js",
66
"scripts": {
7-
"glean_parser": "glean_parser translate src/metrics.yaml src/pings.yaml -f javascript -o src/generated",
8-
"build": "webpack --watch --config webpack.config.js --mode production",
9-
"dev": "webpack --watch --config webpack.config.js --mode development"
7+
"glean": "glean translate src/metrics.yaml src/pings.yaml -f javascript -o src/generated",
8+
"build": "npm run glean && webpack --watch --config webpack.config.js --mode production",
9+
"dev": "npm run glean && webpack --watch --config webpack.config.js --mode development"
1010
},
1111
"author": "The Glean Team <[email protected]>",
1212
"license": "MPL-2.0",

0 commit comments

Comments
 (0)