diff --git a/.env.example b/.env.example index 5cc02c39..73eab092 100644 --- a/.env.example +++ b/.env.example @@ -32,3 +32,4 @@ DELAY_SEND_SMS_TIMEOUT_WHEN_REG_NOT_SUCCESS=7200 HIGH_FREQUENCY_TIME_RANGE=2 HIGH_FREQUENCY_COUNT=10 CREATOR_INFO=steem|steemcurator01|steemcurator02|booming01|booming02|booming03|booming04 +GOOGLE_ANALYTICS_ID= diff --git a/app.js b/app.js index be643ab5..0c3d280c 100644 --- a/app.js +++ b/app.js @@ -19,6 +19,7 @@ https.globalAgent.maxSockets = 100; const app = express(); const clientConfig = getClientConfig(); +const clientConfigObject = JSON.parse(clientConfig); // database cleanup task // removes actions and completed requests older than 60 days @@ -98,6 +99,19 @@ hbs.registerHelper('clientConfig', () => clientConfig); hbs.registerHelper('baseCss', () => new hbs.SafeString(process.env.NODE_ENV !== 'production' ? '' : '')); hbs.registerHelper('baseJs', () => new hbs.SafeString(``)); hbs.registerHelper('recaptchaJs', () => new hbs.SafeString(process.env.RECAPTCHA_SWITCH !== 'OFF' ? '' : '')); +hbs.registerHelper('gaCode', () => { + let gaCode = ''; + if (clientConfigObject) { + gaCode = ` + `; + } + return new hbs.SafeString(gaCode); +}); hbs.registerPartials(`${__dirname}/views/partials`); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'hbs'); diff --git a/helpers/getClientConfig.js b/helpers/getClientConfig.js index 24f035ab..bbbcc58b 100644 --- a/helpers/getClientConfig.js +++ b/helpers/getClientConfig.js @@ -14,6 +14,7 @@ function getClientConfig() { 'RECAPTCHA_SWITCH', 'PENDING_CLAIMED_ACCOUNTS_THRESHOLD', 'CREATOR_INFO', + 'GOOGLE_ANALYTICS_ID', ]; return JSON.stringify( diff --git a/views/index.hbs b/views/index.hbs index 1a3d5ae8..c3f5ffb7 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,6 +1,7 @@ + {{gaCode}} {{title}}