Skip to content

Commit

Permalink
tidy up code and remove of UA GA
Browse files Browse the repository at this point in the history
  • Loading branch information
nikiwycherley committed Jun 22, 2023
1 parent 7a7af1b commit dc69d8e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 17 deletions.
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ DEFRA employees can find examples of environment variables stored in our private
| FLOOD_APP_BING_URL | MS Bing Location Search | yes | | | For location search |
| FLOOD_APP_GEOSERVER_URL | Geoserver | yes | | | For maps ows |
| FLOOD_APP_SERVICE_URL | flood-service | yes | | | For flood api |
| FLOOD_APP_GA_ID | Google analytics Id | no | | | |
| FLOOD_APP_GA4_ID | Google analytics 4 Id | no | | | |
| FLOOD_APP_GTM_ID | Google Tag Manager Id | no | | | |
| FLOOD_APP_NRW_STATION_URL | NRW station search | yes | https://rivers-and-seas.naturalresources.wales/Station/ | |
Expand Down
4 changes: 0 additions & 4 deletions server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ const schema = joi.object({
ordnanceSurveyKey: joi.string().optional(),
browserRefreshUrl: joi.string().optional(),
httpTimeoutMs: joi.number().default(10000),
gaAccId: joi.string().default(''),
gaFourAccId: joi.string().default(''),
gtmAccId: joi.string().default(''),
gaOptId: joi.string().default(''),
siteUrl: joi.string().default(`http://localhost:${defaultPort}`),
floodRiskUrl: joi.string().default(`http://localhost:${defaultPort}`),
sessionPassword: joi.string(),
Expand Down Expand Up @@ -49,10 +47,8 @@ const config = {
bingUrl: process.env.FLOOD_APP_BING_URL,
nrwStationUrl: process.env.FLOOD_APP_NRW_STATION_URL,
httpTimeoutMs: process.env.FLOOD_APP_HTTP_TIMEOUT,
gaAccId: process.env.FLOOD_APP_GA_ID,
gaFourAccId: process.env.FLOOD_APP_GA4_ID,
gtmAccId: process.env.FLOOD_APP_GTM_ID,
gaOptId: process.env.FLOOD_APP_GA_OPT_ID,
siteUrl: process.env.FLOOD_APP_SITE_URL,
floodRiskUrl: process.env.FLOOD_RISK_URL,
sessionPassword: process.env.FLOOD_APP_SESSION_PASSWORD,
Expand Down
4 changes: 1 addition & 3 deletions server/plugins/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const nunjucks = require('nunjucks')
const util = require('../util')
const config = require('../config')
const pkg = require('../../package.json')
const { gaAccId, gaOptId, floodFisUrl, gaFourAccId, gtmAccId } = config
const { floodFisUrl, gaFourAccId, gtmAccId } = config

module.exports = {
plugin: require('@hapi/vision'),
Expand Down Expand Up @@ -38,8 +38,6 @@ module.exports = {
appVersion: pkg.version,
assetPath: '/assets',
serviceName: 'Check for flooding',
gaAccId,
gaOptId,
floodFisUrl,
gaFourAccId,
gtmAccId
Expand Down
3 changes: 1 addition & 2 deletions server/src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ window.flood = {
}
`
document.head.appendChild(script)

// Rest of the function...
}
}
}
Expand Down Expand Up @@ -240,6 +238,7 @@ if (saveButton) {
setCookie('set_cookie_usage', 'true', 30)
calledGTag = true
window.flood.utils.setGTagAnalyticsCookies()
window.flood.utils.disableGoogleAnalytics()
} else {
setCookie('set_cookie_usage', '', -1)
deleteGA4Cookies()
Expand Down
3 changes: 0 additions & 3 deletions test/wepack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ const webpackConfig = require('../webpack.config')
lab.experiment('webpack config test', () => {
let sandbox
// let server
process.env.FLOOD_APP_GA_ID = 'TEST_GA_ID'
process.env.FLOOD_APP_GA4_ID = 'TEST_GA4_ID'
process.env.FLOOD_APP_GTM_ID = 'TEST_GTM_ID'
process.env.FLOOD_APP_GA_OPT_ID = 'TEST_GA_OPT_ID'
process.env.NODE_ENV = 'dev'
const webPack = webpackConfig()
lab.beforeEach(async () => {
Expand All @@ -26,7 +24,6 @@ lab.experiment('webpack config test', () => {

lab.test('webpack config', async () => {
Code.expect(webPack.plugins[0].definitions).to.be.a.object()
Code.expect(webPack.plugins[0].definitions['process.env.GA_ID']).to.equal('"TEST_GA_ID"')
Code.expect(webPack.plugins[0].definitions['process.env.GA4_ID']).to.equal('"TEST_GA4_ID"')
Code.expect(webPack.plugins[0].definitions['process.env.GTM_ID']).to.equal('"TEST_GTM_ID"')
})
Expand Down
6 changes: 2 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path')
const env = process.env.NODE_ENV
const inDev = env === 'dev' || env === 'development' || env === 'test'
const inDev = env === 'dev' || env === 'development'
const webpack = require('webpack')
module.exports = (env, argv) => ({
mode: !inDev ? 'production' : 'development',
Expand Down Expand Up @@ -45,10 +45,8 @@ module.exports = (env, argv) => ({
target: ['web', 'es5'],
plugins: [
new webpack.DefinePlugin({
'process.env.GA_ID': JSON.stringify(process.env.FLOOD_APP_GA_ID),
'process.env.GA4_ID': JSON.stringify(process.env.FLOOD_APP_GA4_ID),
'process.env.GTM_ID': JSON.stringify(process.env.FLOOD_APP_GTM_ID),
'process.env.GA_OPT_ID': JSON.stringify(process.env.FLOOD_APP_GA_OPT_ID)
'process.env.GTM_ID': JSON.stringify(process.env.FLOOD_APP_GTM_ID)
})
]
})

0 comments on commit dc69d8e

Please sign in to comment.