From 003d85d2d93f90a7afaaaa61d84d55c1e965adf2 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 25 Sep 2018 16:46:03 +0200 Subject: [PATCH] doc: remove GA tracking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Roman Reiss Reviewed-By: James M Snell Reviewed-By: Refael Ackermann Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Anna Henningsen --- Makefile | 8 +------- doc/template.html | 1 - test/doctool/test-doctool-html.js | 21 +++------------------ tools/doc/generate.js | 5 +---- tools/doc/html.js | 26 +------------------------- vcbuild.bat | 2 +- 6 files changed, 7 insertions(+), 56 deletions(-) diff --git a/Makefile b/Makefile index 6b9aa510f2b89c..c5a6b19da06732 100644 --- a/Makefile +++ b/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 diff --git a/doc/template.html b/doc/template.html index fdcf0d5821b56f..3317eadf3d47e7 100644 --- a/doc/template.html +++ b/doc/template.html @@ -54,6 +54,5 @@

Table of Contents

- diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index 2fcb8315afd325..78f48ae54e8f26 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -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: '
  1. fish
  2. fish
' + '
  • Red fish
  • Blue fish
', - 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}"`); - } }) ); })); diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 28e09d003fa6db..7ca47e2ae06dc8 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -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; diff --git a/tools/doc/html.js b/tools/doc/html.js index c0a94b6534b171..fd74563dd7fc97 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -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('', ` - `); - } - const docCreated = input.match( //); if (docCreated) { diff --git a/vcbuild.bat b/vcbuild.bat index 2eca8ab3c0a921..8627dcb296fba7 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -458,7 +458,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