Skip to content
This repository was archived by the owner on Mar 14, 2022. It is now read-only.

Feat/add matomo #1

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
# incubateur-territoires


## Deploy to Prod

`make deploy` will generate static files to _/docs_ dir and
do a couple of required things for deployment.
It pushes the `/docs/` directory that is served by Github
and should be pushed for deploying an update.

## Environment variables

| name | description | default value |
| --- | --- | --- |
| MATOMO_URL | Url to matomo installation | `http://localhost:8080` |
| MATOMO_SITE_ID | Matomo site id | `1` |
| MATOMO_CONSENT_REQUIRED | If true, Matomo will not start tracking until the user has given consent | `true` |
| MATOMO_DO_NOT_TRACK | If true, dont track users who have set Mozilla's Do Not Track setting | `true` |

## Matomo configuration

Matomo is configured thanks to (a dedicated nuxt module)[https://github.com/pimlie/nuxt-matomo]. Current configuration is set to behave as:
- User consent and Do not track options are set to `true` by default
- In dev environment, debug and verbose mode are active

__Warning: due to some (caveats[https://github.com/pimlie/nuxt-matomo#caveats]) we use onMetaChange option which requires pages to have a (head)[https://nuxtjs.org/docs/components-glossary/head/] property__


## Build Setup

Expand Down
23 changes: 22 additions & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
const IS_DEV_ENVIRONMENT = process.env.NODE_ENV === 'development';
const isUndefined = (environmentVariable) => typeof environmentVariable === 'undefined'

const {
MATOMO_URL, MATOMO_SITE_ID, MATOMO_CONSENT_REQUIRED, MATOMO_DO_NOT_TRACK
} = process.env;

export default {
// Target: https://go.nuxtjs.dev/config-target
target: 'static',
Expand All @@ -6,6 +13,8 @@ export default {
dir: 'docs'
},

telemetry: false,

// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'Incubateur des Territoires',
Expand Down Expand Up @@ -46,7 +55,19 @@ export default {

// Modules: https://go.nuxtjs.dev/config-modules
modules: [
'@nuxt/http'
'@nuxt/http',
[
'nuxt-matomo',
{
matomoUrl: MATOMO_URL || 'http://localhost:8080',
siteId: MATOMO_SITE_ID || 1,
onMetaChange: true,
consentRequired: isUndefined(MATOMO_CONSENT_REQUIRED) || !!MATOMO_CONSENT_REQUIRED,
doNotTrack: isUndefined(MATOMO_DO_NOT_TRACK) || !!MATOMO_DO_NOT_TRACK,
debug: IS_DEV_ENVIRONMENT,
verbose: IS_DEV_ENVIRONMENT
},
],
],

// Build Configuration: https://go.nuxtjs.dev/config-build
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@nuxt/http": "^0.6.4",
"core-js": "^3.19.3",
"nuxt": "^2.15.8",
"nuxt-matomo": "^1.2.4",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
Expand Down
6 changes: 6 additions & 0 deletions pages/catalogue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@

<script>
export default {
head() {
return {
title: 'Incubateur des territoires - Catalogue'
}
},

created() {
this.$store.dispatch('services/init')
},
Expand Down
9 changes: 8 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@

<script>
export default {
layout: 'raw'
layout: 'raw',

head() {
return {
title: 'Incubateur des territoires - Accueil'
}
}
}

</script>

<style>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5538,6 +5538,11 @@ num2fraction@^1.2.2:
resolved "https://registry.yarnpkg.com/num2fraction/-/num2fraction-1.2.2.tgz#6f682b6a027a4e9ddfa4564cd2589d1d4e669ede"
integrity sha1-b2gragJ6Tp3fpFZM0lidHU5mnt4=

nuxt-matomo@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/nuxt-matomo/-/nuxt-matomo-1.2.4.tgz#2cd3f212996e0c35ade08f23563987438608e469"
integrity sha512-09cIWnj6v58CMbEDS+mVTnJ97BaO/fJaQDPk31sa27jejcD80bIvNowkAJMj4OcVWMeeIVTljClMHE6249cFtw==

nuxt@^2.15.8:
version "2.15.8"
resolved "https://registry.yarnpkg.com/nuxt/-/nuxt-2.15.8.tgz#946cba46bdaaf0e3918aa27fd9ea0fed8ed303b0"
Expand Down