From bdd240ab1ab59b273f0b548507b041c1ef15e674 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 22 Oct 2023 17:31:41 +0800 Subject: [PATCH] chore: add tianji analytics script --- client/web/build/inject-analytics.js | 28 +++++++++++++++++++--------- website/docusaurus.config.js | 8 ++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/client/web/build/inject-analytics.js b/client/web/build/inject-analytics.js index 52a75aa8..51a851ad 100644 --- a/client/web/build/inject-analytics.js +++ b/client/web/build/inject-analytics.js @@ -11,15 +11,25 @@ const path = require('path'); const templatePath = path.resolve(__dirname, '../assets/template.html'); +console.log('templatePath', templatePath); + +function appendScript(script) { + let template = fs.readFileSync(templatePath, { + encoding: 'utf-8', + }); + template = template.replace('', script + ''); + + fs.writeFileSync(templatePath, template); +} + // frontjs // const script = ``; -// umami -const script = ``; - -console.log('templatePath', templatePath); -let template = fs.readFileSync(templatePath, { - encoding: 'utf-8', -}); -template = template.replace('', script + ''); -fs.writeFileSync(templatePath, template); +// umami +appendScript( + `` +); +// tianji +appendScript( + `` +); diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 35fa8a2d..5d907dcb 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -136,4 +136,12 @@ module.exports = { 'data-website-id': '22f7ff7b-db54-4222-b123-c8e3acfbf1aa', }, ], + scripts: [ + { + src: 'https://tianji.moonrailgun.com/tracker.js', + async: true, + defer: true, + 'data-website-id': 'clo189w7r0003o65exm2pvdnp', + }, + ], };