Skip to content

Commit b8b9dd5

Browse files
committed
refactor(google-analytics): rename {account => measurementId}
1 parent f0bf6ba commit b8b9dd5

File tree

11 files changed

+23
-23
lines changed

11 files changed

+23
-23
lines changed

Diff for: .env.testing

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ REACT_APP_AUTOCOMPLETE_SEARCH_WIDGET=true
2424

2525
# These are set to fake values just to make sure the paths that
2626
# injects the relevant script tags actually run in end-to-end testing.
27-
BUILD_GOOGLE_ANALYTICS_ACCOUNT=UA-00000000-0
27+
BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID=UA-00000000-0
2828

2929
# The functional tests are done in a production'y way as if it had
3030
# to go into full production mode.

Diff for: .github/workflows/dev-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125

126126
# This just makes sure the Google Analytics script gets used even if
127127
# it goes nowhere.
128-
BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-00000000-0
128+
BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID: UA-00000000-0
129129

130130
# This removes the ability to sign in
131131
REACT_APP_DISABLE_AUTH: true

Diff for: .github/workflows/performance.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151
# Make sure it's set to something so that the build uses the
5252
# Google Analytics tag which is most realistic.
53-
BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-00000000-0
53+
BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID: UA-00000000-0
5454
run: |
5555
yarn build:prepare
5656
# BUILD_FOLDERSEARCH=mdn/kitchensink yarn build

Diff for: .github/workflows/prod-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195
# If it's used on other domains (e.g. stage or dev builds), it's OK
196196
# because ultimately Google Analytics will filter it out since the
197197
# origin domain isn't what that account expects.
198-
BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-36116321-5
198+
BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID: UA-36116321-5
199199

200200
# This enables the MDN Plus
201201
REACT_APP_ENABLE_PLUS: true

Diff for: .github/workflows/stage-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195
BUILD_FLAW_LEVELS: "*:ignore"
196196

197197
# This is the Google Analytics measurement ID for developer.allizom.org.
198-
BUILD_GOOGLE_ANALYTICS_ACCOUNT: G-ZG5HNVZRY0
198+
BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID: G-ZG5HNVZRY0
199199

200200
# This enables the Plus call-to-action banner and the Plus landing page
201201
REACT_APP_ENABLE_PLUS: true

Diff for: .github/workflows/xyz-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
# If it's used on other domains (e.g. stage or dev builds), it's OK
130130
# because ultimately Google Analytics will filter it out since the
131131
# origin domain isn't what that account expects.
132-
BUILD_GOOGLE_ANALYTICS_ACCOUNT: UA-36116321-5
132+
BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID: UA-36116321-5
133133

134134
# This enables the Plus call-to-action banner and the Plus landing page
135135
REACT_APP_ENABLE_PLUS: true

Diff for: docs/envvars.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ Used to serve legacy lives samples that do not support playground rendering.
143143

144144
The base URL used in the Interactive Example iframes.
145145

146-
### `BUILD_GOOGLE_ANALYTICS_ACCOUNT`
146+
### `BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID`
147147

148148
**Default: `''`**
149149

150150
If set, the rendered HTML will have a Google Analytics snippet. For example, to
151-
test use: `export BUILD_GOOGLE_ANALYTICS_ACCOUNT=UA-00000000-0`. By default it's
152-
disabled (empty string).
151+
test use: `export BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID=UA-00000000-0`. By
152+
default it's disabled (empty string).
153153

154154
### `BUILD_ALWAYS_ALLOW_ROBOTS`
155155

Diff for: docs/google-analytics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from the client-side code. The way it works is that you have to send an
55
environment variable, like:
66

77
```bash
8-
BUILD_GOOGLE_ANALYTICS_ACCOUNT=UA-1234678-0
8+
BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID=UA-1234678-0
99
```
1010

1111
and that gets included in the build by more or less code-generating the snippet

Diff for: libs/env/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export const DEFAULT_FLAW_LEVELS: string;
33
export const BASE_URL: string;
44
export const FILES: string;
55
export const FOLDERSEARCH: string;
6-
export const GOOGLE_ANALYTICS_ACCOUNT: string;
6+
export const GOOGLE_ANALYTICS_MEASUREMENT_ID: string;
77
export const NO_PROGRESSBAR: boolean;
88
export const FIX_FLAWS: boolean;
99
export const FIX_FLAWS_DRY_RUN: boolean;

Diff for: libs/env/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export const DEFAULT_FLAW_LEVELS = process.env.BUILD_FLAW_LEVELS || "*:warn";
2828

2929
export const FILES = process.env.BUILD_FILES || "";
3030
export const FOLDERSEARCH = process.env.BUILD_FOLDERSEARCH || "";
31-
export const GOOGLE_ANALYTICS_ACCOUNT =
32-
process.env.BUILD_GOOGLE_ANALYTICS_ACCOUNT || "";
31+
export const GOOGLE_ANALYTICS_MEASUREMENT_ID =
32+
process.env.BUILD_GOOGLE_ANALYTICS_MEASUREMENT_ID || "";
3333
export const NO_PROGRESSBAR = Boolean(
3434
JSON.parse(process.env.BUILD_NO_PROGRESSBAR || process.env.CI || "false")
3535
);

Diff for: tool/cli.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
BUILD_OUT_ROOT,
2929
CONTENT_ROOT,
3030
CONTENT_TRANSLATED_ROOT,
31-
GOOGLE_ANALYTICS_ACCOUNT,
31+
GOOGLE_ANALYTICS_MEASUREMENT_ID,
3232
} from "../libs/env/index.js";
3333
import { runMakePopularitiesFile } from "./popularities.js";
3434
import { runOptimizeClientBuild } from "./optimize-client-build.js";
@@ -180,7 +180,7 @@ interface PopularitiesActionParameters extends ActionParameters {
180180

181181
interface GoogleAnalyticsCodeActionParameters extends ActionParameters {
182182
options: {
183-
account: string;
183+
measurementId: string;
184184
debug: boolean;
185185
outfile: string;
186186
};
@@ -867,25 +867,25 @@ program
867867
default: path.join(BUILD_OUT_ROOT, "static", "js", "gtag.js"),
868868
})
869869
.option(
870-
"--account <id>",
871-
"Google Analytics account ID (defaults to value of $GOOGLE_ANALYTICS_ACCOUNT)",
870+
"--measurement-id <id>",
871+
"Google Analytics measurement ID (defaults to value of $GOOGLE_ANALYTICS_MEASUREMENT_ID)",
872872
{
873-
default: GOOGLE_ANALYTICS_ACCOUNT,
873+
default: GOOGLE_ANALYTICS_MEASUREMENT_ID,
874874
}
875875
)
876876
.action(
877877
tryOrExit(
878878
async ({ options, logger }: GoogleAnalyticsCodeActionParameters) => {
879-
const { outfile, account } = options;
880-
if (account) {
879+
const { outfile, measurementId } = options;
880+
if (measurementId) {
881881
const dntHelperCode = fs
882882
.readFileSync(
883883
new URL("mozilla.dnthelper.min.js", import.meta.url),
884884
"utf-8"
885885
)
886886
.trim();
887887

888-
const gaScriptURL = `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(account)}`;
888+
const gaScriptURL = `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(measurementId)}`;
889889

890890
const code = `
891891
// Mozilla DNT Helper
@@ -895,7 +895,7 @@ if (Mozilla && !Mozilla.dntEnabled()) {
895895
window.dataLayer = window.dataLayer || [];
896896
function gtag(){dataLayer.push(arguments);}
897897
gtag('js', new Date());
898-
gtag('config', '${account}', { 'anonymize_ip': true });
898+
gtag('config', '${measurementId}', { 'anonymize_ip': true });
899899
900900
var gaScript = document.createElement('script');
901901
gaScript.async = true;
@@ -905,7 +905,7 @@ if (Mozilla && !Mozilla.dntEnabled()) {
905905
fs.writeFileSync(outfile, `${code}\n`, "utf-8");
906906
logger.info(
907907
chalk.green(
908-
`Generated ${outfile} for SSR rendering using ${account}.`
908+
`Generated ${outfile} for SSR rendering using ${measurementId}.`
909909
)
910910
);
911911
} else {

0 commit comments

Comments
 (0)