Skip to content

Commit

Permalink
add smartlook integration
Browse files Browse the repository at this point in the history
  • Loading branch information
rosado committed Jul 11, 2024
1 parent d652141 commit 3ca80b8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
3 changes: 1 addition & 2 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import HmpoConfig from 'hmpo-config'
import yaml from 'js-yaml'
import fs from 'fs'
import _ from 'lodash'

const readConfig = (config) => {
return yaml.load(fs.readFileSync(`./config/${config}.yaml`, 'utf8'))
Expand All @@ -16,7 +15,7 @@ const getConfig = () => {

const customConfig = readConfig(environment)

const combinedConfig = _.merge({}, defaultConfig, customConfig)
const combinedConfig = Object.assign({}, defaultConfig, customConfig)

const config = new HmpoConfig()
config.addConfig(combinedConfig)
Expand Down
6 changes: 5 additions & 1 deletion config/production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ redis: {
host: 'production-pub-async-redis-eihmmv.serverless.euw2.cache.amazonaws.com',
port: '6379'
}
url: 'https://publish.digital-land.info/'
url: 'https://publish.digital-land.info/'
smartlook: {
key: '6383ab27d6f6a02f043a518bea629cd232dc0131',
region: 'eu'
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"test:acceptance": "NODE_ENV=development playwright test --config ./test/acceptance/playwright.config.js",
"test:acceptance:ci": "NODE_ENV=ci playwright test --config ./test/acceptance/playwright.config.js",
"playwright-codegen": "playwright codegen http://localhost:5000",
"lint": "standard",
"lint:fix": "standard --fix"
"lint": "standard --ignore=src/views/common/smartlook.js",
"lint:fix": "standard --fix --ignore=src/views/common/smartlook.js"
},
"engines": {
"node": ">=18.0.0 <20.0.0"
Expand Down Expand Up @@ -72,7 +72,6 @@
"hmpo-form-wizard": "^13.0.0",
"hmpo-i18n": "^6.0.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"maplibre-gl": "^4.1.0",
"multer": "^1.4.5-lts.1",
"notifications-node-client": "^8.2.0",
Expand Down
5 changes: 5 additions & 0 deletions src/serverSetup/nunjucks.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export function setupNunjucks ({ app, dataSubjects }) {
feedbackLink: config.feedbackLink
}

if ('smartlook' in config) {
globalValues.smartlookKey = config.smartlook.key
globalValues.smartlookRegion = config.smartlook.region
}

Object.keys(globalValues).forEach((key) => {
nunjucksEnv.addGlobal(key, globalValues[key])
})
Expand Down
7 changes: 7 additions & 0 deletions src/views/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@

{% block head %}
<link rel="stylesheet" href="/public/stylesheets/index.css">
{% if smartlookKey %}
{% block smartlook %}
<script type='text/javascript'>
{% include "common/smartlook.js" %}
</script>
{% endblock %}
{% endif %}
{% endblock %}

{% block header %}
Expand Down

0 comments on commit 3ca80b8

Please sign in to comment.