doc: remove GA tracking
The Google Analytics tracking wasn't wholly uncontroversial and hasn't been used in practice. Remove it. PR-URL: https://github.com/nodejs/node/pull/23083 Fixes: https://github.com/nodejs/node/issues/22652 Refs: https://github.com/nodejs/node/pull/6601 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
parent
9577946bed
commit
df6a1306e8
8
Makefile
8
Makefile
@ -597,11 +597,6 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all:
|
||||
"$ git clone https://github.com/nodejs/node.git"
|
||||
endif
|
||||
|
||||
# Google Analytics ID used for tracking API docs page views, empty
|
||||
# DOCS_ANALYTICS means no tracking scripts will be included in the
|
||||
# generated .html files
|
||||
DOCS_ANALYTICS ?=
|
||||
|
||||
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
|
||||
apidoc_sources = $(wildcard doc/api/*.md)
|
||||
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
|
||||
@ -646,8 +641,7 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets
|
||||
run-npm-ci = $(PWD)/$(NPM) ci
|
||||
|
||||
gen-api = tools/doc/generate.js --node-version=$(FULLVERSION) \
|
||||
--apilinks=out/apilinks.json \
|
||||
--analytics=$(DOCS_ANALYTICS) $< --output-directory=out/doc/api
|
||||
--apilinks=out/apilinks.json $< --output-directory=out/doc/api
|
||||
gen-apilink = tools/doc/apilinks.js $(wildcard lib/*.js) > $@
|
||||
|
||||
out/apilinks.json: $(wildcard lib/*.js) tools/doc/apilinks.js
|
||||
|
@ -54,6 +54,5 @@
|
||||
<script src="assets/sh_main.js"></script>
|
||||
<script src="assets/sh_javascript.min.js"></script>
|
||||
<script>highlight(undefined, undefined, 'pre');</script>
|
||||
<!-- __TRACKING__ -->
|
||||
</body>
|
||||
</html>
|
||||
|
@ -22,7 +22,7 @@ const remark2rehype = require('remark-rehype');
|
||||
const raw = require('rehype-raw');
|
||||
const htmlStringify = require('rehype-stringify');
|
||||
|
||||
function toHTML({ input, filename, nodeVersion, analytics }, cb) {
|
||||
function toHTML({ input, filename, nodeVersion }, cb) {
|
||||
const content = unified()
|
||||
.use(markdown)
|
||||
.use(html.firstHeader)
|
||||
@ -35,7 +35,7 @@ function toHTML({ input, filename, nodeVersion, analytics }, cb) {
|
||||
.processSync(input);
|
||||
|
||||
html.toHTML(
|
||||
{ input, content, filename, nodeVersion, analytics },
|
||||
{ input, content, filename, nodeVersion },
|
||||
cb
|
||||
);
|
||||
}
|
||||
@ -94,16 +94,14 @@ const testData = [
|
||||
file: fixtures.path('sample_document.md'),
|
||||
html: '<ol><li>fish</li><li>fish</li></ol>' +
|
||||
'<ul><li>Red fish</li><li>Blue fish</li></ul>',
|
||||
analyticsId: 'UA-67020396-1'
|
||||
},
|
||||
];
|
||||
|
||||
const spaces = /\s/g;
|
||||
|
||||
testData.forEach(({ file, html, analyticsId }) => {
|
||||
testData.forEach(({ file, html }) => {
|
||||
// Normalize expected data by stripping whitespace.
|
||||
const expected = html.replace(spaces, '');
|
||||
const includeAnalytics = typeof analyticsId !== 'undefined';
|
||||
|
||||
readFile(file, 'utf8', common.mustCall((err, input) => {
|
||||
assert.ifError(err);
|
||||
@ -112,7 +110,6 @@ testData.forEach(({ file, html, analyticsId }) => {
|
||||
input: input,
|
||||
filename: 'foo',
|
||||
nodeVersion: process.version,
|
||||
analytics: analyticsId,
|
||||
},
|
||||
common.mustCall((err, output) => {
|
||||
assert.ifError(err);
|
||||
@ -121,18 +118,6 @@ testData.forEach(({ file, html, analyticsId }) => {
|
||||
// Assert that the input stripped of all whitespace contains the
|
||||
// expected markup.
|
||||
assert(actual.includes(expected));
|
||||
|
||||
// Testing the insertion of Google Analytics script when
|
||||
// an analytics id is provided. Should not be present by default.
|
||||
const scriptDomain = 'google-analytics.com';
|
||||
if (includeAnalytics) {
|
||||
assert(actual.includes(scriptDomain),
|
||||
`Google Analytics script was not present in "${actual}"`);
|
||||
} else {
|
||||
assert.strictEqual(actual.includes(scriptDomain), false,
|
||||
'Google Analytics script was present in ' +
|
||||
`"${actual}"`);
|
||||
}
|
||||
})
|
||||
);
|
||||
}));
|
||||
|
@ -38,7 +38,6 @@ const json = require('./json');
|
||||
const args = process.argv.slice(2);
|
||||
let filename = null;
|
||||
let nodeVersion = null;
|
||||
let analytics = null;
|
||||
let outputDir = null;
|
||||
let apilinks = {};
|
||||
|
||||
@ -47,8 +46,6 @@ args.forEach(function(arg) {
|
||||
filename = arg;
|
||||
} else if (arg.startsWith('--node-version=')) {
|
||||
nodeVersion = arg.replace(/^--node-version=/, '');
|
||||
} else if (arg.startsWith('--analytics=')) {
|
||||
analytics = arg.replace(/^--analytics=/, '');
|
||||
} else if (arg.startsWith('--output-directory=')) {
|
||||
outputDir = arg.replace(/^--output-directory=/, '');
|
||||
} else if (arg.startsWith('--apilinks=')) {
|
||||
@ -85,7 +82,7 @@ fs.readFile(filename, 'utf8', (er, input) => {
|
||||
const basename = path.basename(filename, '.md');
|
||||
|
||||
html.toHTML(
|
||||
{ input, content, filename, nodeVersion, analytics },
|
||||
{ input, content, filename, nodeVersion },
|
||||
(err, html) => {
|
||||
const target = path.join(outputDir, `${basename}.html`);
|
||||
if (err) throw err;
|
||||
|
@ -62,7 +62,7 @@ const gtocHTML = unified()
|
||||
const templatePath = path.join(docPath, 'template.html');
|
||||
const template = fs.readFileSync(templatePath, 'utf8');
|
||||
|
||||
function toHTML({ input, content, filename, nodeVersion, analytics }, cb) {
|
||||
function toHTML({ input, content, filename, nodeVersion }, cb) {
|
||||
filename = path.basename(filename, '.md');
|
||||
|
||||
const id = filename.replace(/\W+/g, '-');
|
||||
@ -77,30 +77,6 @@ function toHTML({ input, content, filename, nodeVersion, analytics }, cb) {
|
||||
.replace('__EDIT_ON_GITHUB__', editOnGitHub(filename))
|
||||
.replace('__CONTENT__', content.toString());
|
||||
|
||||
if (analytics) {
|
||||
HTML = HTML.replace('<!-- __TRACKING__ -->', `
|
||||
<script type="text/javascript">
|
||||
// In all the browsers we'll get '1' or 'yes' (FF 32 or above) as a string
|
||||
// value when enabling 'DO NOT TRACK'.
|
||||
// For more:
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/navigator/doNotTrack
|
||||
function isDoNotTrack() {
|
||||
var isDoNotTrackEnabled = navigator.doNotTrack || window.doNotTrack ||
|
||||
navigator.msDoNotTrack;
|
||||
return isDoNotTrackEnabled === '1' || isDoNotTrackEnabled === 'yes';
|
||||
}
|
||||
if (!isDoNotTrack()) {
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;
|
||||
i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},
|
||||
i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];
|
||||
a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,
|
||||
'script','//www.google-analytics.com/analytics.js','ga');
|
||||
ga('create', '${analytics}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
}
|
||||
</script>`);
|
||||
}
|
||||
|
||||
const docCreated = input.match(
|
||||
/<!--\s*introduced_in\s*=\s*v([0-9]+)\.([0-9]+)\.[0-9]+\s*-->/);
|
||||
if (docCreated) {
|
||||
|
@ -460,7 +460,7 @@ robocopy /e doc\api %config%\doc\api
|
||||
robocopy /e doc\api_assets %config%\doc\api\assets
|
||||
|
||||
for %%F in (%config%\doc\api\*.md) do (
|
||||
%node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% --analytics=%DOCS_ANALYTICS% %%F --output-directory=%%~dF%%~pF
|
||||
%node_exe% tools\doc\generate.js --node-version=v%FULLVERSION% %%F --output-directory=%%~dF%%~pF
|
||||
)
|
||||
|
||||
:run
|
||||
|
Loading…
x
Reference in New Issue
Block a user