Skip to content

Commit 003d85d

Browse files
bnoordhuistargos
authored andcommitted
doc: remove GA tracking
The Google Analytics tracking wasn't wholly uncontroversial and hasn't been used in practice. Remove it. PR-URL: #23083 Fixes: #22652 Refs: #6601 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 748d9d2 commit 003d85d

File tree

6 files changed

+7
-56
lines changed

6 files changed

+7
-56
lines changed

Makefile

+1-7
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,6 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
597597
"$ git clone https://github.com/nodejs/node.git"
598598
endif
599599

600-
# Google Analytics ID used for tracking API docs page views, empty
601-
# DOCS_ANALYTICS means no tracking scripts will be included in the
602-
# generated .html files
603-
DOCS_ANALYTICS ?=
604-
605600
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
606601
apidoc_sources = $(wildcard doc/api/*.md)
607602
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
@@ -646,8 +641,7 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets
646641
run-npm-ci = $(PWD)/$(NPM) ci
647642

648643
gen-api = tools/doc/generate.js --node-version=$(FULLVERSION) \
649-
--apilinks=out/apilinks.json \
650-
--analytics=$(DOCS_ANALYTICS) $< --output-directory=out/doc/api
644+
--apilinks=out/apilinks.json $< --output-directory=out/doc/api
651645
gen-apilink = tools/doc/apilinks.js $(wildcard lib/*.js) > $@
652646

653647
out/apilinks.json: $(wildcard lib/*.js) tools/doc/apilinks.js

doc/template.html

-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,5 @@ <h2>Table of Contents</h2>
5454
<script src="assets/sh_main.js"></script>
5555
<script src="assets/sh_javascript.min.js"></script>
5656
<script>highlight(undefined, undefined, 'pre');</script>
57-
<!-- __TRACKING__ -->
5857
</body>
5958
</html>

test/doctool/test-doctool-html.js

+3-18
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const remark2rehype = require('remark-rehype');
2222
const raw = require('rehype-raw');
2323
const htmlStringify = require('rehype-stringify');
2424

25-
function toHTML({ input, filename, nodeVersion, analytics }, cb) {
25+
function toHTML({ input, filename, nodeVersion }, cb) {
2626
const content = unified()
2727
.use(markdown)
2828
.use(html.firstHeader)
@@ -35,7 +35,7 @@ function toHTML({ input, filename, nodeVersion, analytics }, cb) {
3535
.processSync(input);
3636

3737
html.toHTML(
38-
{ input, content, filename, nodeVersion, analytics },
38+
{ input, content, filename, nodeVersion },
3939
cb
4040
);
4141
}
@@ -94,16 +94,14 @@ const testData = [
9494
file: fixtures.path('sample_document.md'),
9595
html: '<ol><li>fish</li><li>fish</li></ol>' +
9696
'<ul><li>Red fish</li><li>Blue fish</li></ul>',
97-
analyticsId: 'UA-67020396-1'
9897
},
9998
];
10099

101100
const spaces = /\s/g;
102101

103-
testData.forEach(({ file, html, analyticsId }) => {
102+
testData.forEach(({ file, html }) => {
104103
// Normalize expected data by stripping whitespace.
105104
const expected = html.replace(spaces, '');
106-
const includeAnalytics = typeof analyticsId !== 'undefined';
107105

108106
readFile(file, 'utf8', common.mustCall((err, input) => {
109107
assert.ifError(err);
@@ -112,7 +110,6 @@ testData.forEach(({ file, html, analyticsId }) => {
112110
input: input,
113111
filename: 'foo',
114112
nodeVersion: process.version,
115-
analytics: analyticsId,
116113
},
117114
common.mustCall((err, output) => {
118115
assert.ifError(err);
@@ -121,18 +118,6 @@ testData.forEach(({ file, html, analyticsId }) => {
121118
// Assert that the input stripped of all whitespace contains the
122119
// expected markup.
123120
assert(actual.includes(expected));
124-
125-
// Testing the insertion of Google Analytics script when
126-
// an analytics id is provided. Should not be present by default.
127-
const scriptDomain = 'google-analytics.com';
128-
if (includeAnalytics) {
129-
assert(actual.includes(scriptDomain),
130-
`Google Analytics script was not present in "${actual}"`);
131-
} else {
132-
assert.strictEqual(actual.includes(scriptDomain), false,
133-
'Google Analytics script was present in ' +
134-
`"${actual}"`);
135-
}
136121
})
137122
);
138123
}));

tools/doc/generate.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ const json = require('./json');
3838
const args = process.argv.slice(2);
3939
let filename = null;
4040
let nodeVersion = null;
41-
let analytics = null;
4241
let outputDir = null;
4342
let apilinks = {};
4443

@@ -47,8 +46,6 @@ args.forEach(function(arg) {
4746
filename = arg;
4847
} else if (arg.startsWith('--node-version=')) {
4948
nodeVersion = arg.replace(/^--node-version=/, '');
50-
} else if (arg.startsWith('--analytics=')) {
51-
analytics = arg.replace(/^--analytics=/, '');
5249
} else if (arg.startsWith('--output-directory=')) {
5350
outputDir = arg.replace(/^--output-directory=/, '');
5451
} else if (arg.startsWith('--apilinks=')) {
@@ -85,7 +82,7 @@ fs.readFile(filename, 'utf8', (er, input) => {
8582
const basename = path.basename(filename, '.md');
8683

8784
html.toHTML(
88-
{ input, content, filename, nodeVersion, analytics },
85+
{ input, content, filename, nodeVersion },
8986
(err, html) => {
9087
const target = path.join(outputDir, `${basename}.html`);
9188
if (err) throw err;

tools/doc/html.js

+1-25
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const gtocHTML = unified()
6262
const templatePath = path.join(docPath, 'template.html');
6363
const template = fs.readFileSync(templatePath, 'utf8');
6464

65-
function toHTML({ input, content, filename, nodeVersion, analytics }, cb) {
65+
function toHTML({ input, content, filename, nodeVersion }, cb) {
6666
filename = path.basename(filename, '.md');
6767

6868
const id = filename.replace(/\W+/g, '-');
@@ -77,30 +77,6 @@ function toHTML({ input, content, filename, nodeVersion, analytics }, cb) {
7777
.replace('__EDIT_ON_GITHUB__', editOnGitHub(filename))
7878
.replace('__CONTENT__', content.toString());
7979

80-
if (analytics) {
81-
HTML = HTML.replace('<!-- __TRACKING__ -->', `
82-
<script type="text/javascript">
83-
// In all the browsers we'll get '1' or 'yes' (FF 32 or above) as a string
84-
// value when enabling 'DO NOT TRACK'.
85-
// For more:
86-
// https://developer.mozilla.org/en-US/docs/Web/API/navigator/doNotTrack
87-
function isDoNotTrack() {
88-
var isDoNotTrackEnabled = navigator.doNotTrack || window.doNotTrack ||
89-
navigator.msDoNotTrack;
90-
return isDoNotTrackEnabled === '1' || isDoNotTrackEnabled === 'yes';
91-
}
92-
if (!isDoNotTrack()) {
93-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;
94-
i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},
95-
i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];
96-
a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,
97-
'script','//www.google-analytics.com/analytics.js','ga');
98-
ga('create', '${analytics}', 'auto');
99-
ga('send', 'pageview');
100-
}
101-
</script>`);
102-
}
103-
10480
const docCreated = input.match(
10581
/<!--\s*introduced_in\s*=\s*v([0-9]+)\.([0-9]+)\.[0-9]+\s*-->/);
10682
if (docCreated) {

vcbuild.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ robocopy /e doc\api %config%\doc\api
458458
robocopy /e doc\api_assets %config%\doc\api\assets
459459

460460
for %%F in (%config%\doc\api\*.md) do (
461-
%node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% --analytics=%DOCS_ANALYTICS% %%F --output-directory=%%~dF%%~pF
461+
%node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% %%F --output-directory=%%~dF%%~pF
462462
)
463463

464464
:run

0 commit comments

Comments
 (0)