Skip to content
Snippets Groups Projects
Commit 3892c0d8 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Merge branch 'feature/99-add-rudimentary-matomo-tracker-to-the-website' into 'main'

Resolve "Add rudimentary matomo tracker to the website"

Closes #99

See merge request !96
parents 546d2485 494e6626
No related branches found
No related tags found
1 merge request!96Resolve "Add rudimentary matomo tracker to the website"
Pipeline #47699 passed
...@@ -6,10 +6,10 @@ This is the Frontend to manage your S3 Buckets and start Workflows. ...@@ -6,10 +6,10 @@ This is the Frontend to manage your S3 Buckets and start Workflows.
## Environment Variables ## Environment Variables
The docker container replaces them in the `env.template.js` file and moves that file to the same location as the `index.html`. The docker container replaces them in the `env.template.js` file and moves that file to the same location as
the `index.html`.
When accessing the website, these variables will be loaded dynamically into the application. When accessing the website, these variables will be loaded dynamically into the application.
| Variable | Default | Value | Description | | Variable | Default | Value | Description |
|-------------------------|---------|----------|--------------------------------------------------| |-------------------------|---------|----------|--------------------------------------------------|
| `AUTH_API_BASE_URL` | unset | HTTP URL | Base URL for the Auth Service API | | `AUTH_API_BASE_URL` | unset | HTTP URL | Base URL for the Auth Service API |
...@@ -18,7 +18,10 @@ When accessing the website, these variables will be loaded dynamically into the ...@@ -18,7 +18,10 @@ When accessing the website, these variables will be loaded dynamically into the
| `S3PROXY_API_BASE_URL` | unset | HTTP URL | Base URL for the S3Proxy Service API | | `S3PROXY_API_BASE_URL` | unset | HTTP URL | Base URL for the S3Proxy Service API |
| `S3_URL` | unset | HTTP URL | URL of the S3 storage to interact with | | `S3_URL` | unset | HTTP URL | URL of the S3 storage to interact with |
| `DEV_SYSTEM` | `false` | boolean | Flag if the service is installed on a Dev system | | `DEV_SYSTEM` | `false` | boolean | Flag if the service is installed on a Dev system |
| `MATOMO_HOST` | unset | HTTP URL | URL to a Matomo instance to enable tracking |
| `MATOMO_SITE_ID` | unset | integer | Site id of the website on the Matomo instance |
## License ## License
The API is licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) license. See the [License](LICENSE) file for more information The API is licensed under the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) license. See
the [License](LICENSE) file for more information.
This diff is collapsed.
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
"showdown": "~2.1.0", "showdown": "~2.1.0",
"sortablejs": "^1.15.2", "sortablejs": "^1.15.2",
"vue": "~3.4.0", "vue": "~3.4.0",
"vue-matomo": "^4.2.0",
"vue-router": "~4.2.0", "vue-router": "~4.2.0",
"vue3-cookies": "~1.0.0" "vue3-cookies": "~1.0.0"
}, },
......
...@@ -47,6 +47,18 @@ onBeforeMount(() => { ...@@ -47,6 +47,18 @@ onBeforeMount(() => {
}, },
); );
store.setToken(cookies.get("bearer")); store.setToken(cookies.get("bearer"));
router.afterEach((to, from) => {
window._paq.push(["setReferrerUrl", from.path]);
window._paq.push(["deleteCustomVariables", "page"]);
window._paq.push(["deleteCustomDimension", 1]);
window._paq.push(["setCustomUrl", to.path]);
window._paq.push(["setDocumentTitle", to.name]);
if (store.currentUID.length > 0) {
window._paq.push(["setUserId", store.currentUID]);
}
window._paq.push(["trackPageView"]);
window._paq.push(["enableLinkTracking"]);
});
router.beforeEach(async (to) => { router.beforeEach(async (to) => {
// make sure the user is authenticated // make sure the user is authenticated
if ( if (
......
...@@ -8,4 +8,6 @@ ...@@ -8,4 +8,6 @@
window["env"]["authApiUrl"] = "${AUTH_API_BASE_URL}"; window["env"]["authApiUrl"] = "${AUTH_API_BASE_URL}";
window["env"]["resourceApiUrl"] = "${RESOURCE_API_BASE_URL}"; window["env"]["resourceApiUrl"] = "${RESOURCE_API_BASE_URL}";
window["env"]["devSystem"] = "${DEV_SYSTEM}"; window["env"]["devSystem"] = "${DEV_SYSTEM}";
window["env"]["matomoHost"] = "${MATOMO_HOST}";
window["env"]["matomoSiteId"] = "${MATOMO_SITE_ID}";
})(this); })(this);
...@@ -4,9 +4,22 @@ ...@@ -4,9 +4,22 @@
<footer <footer
class="navbar navbar-expand-lg bd-navbar w-100 border-top border-secondary mt-auto p-2" class="navbar navbar-expand-lg bd-navbar w-100 border-top border-secondary mt-auto p-2"
> >
<nav <nav class="container-xxl bd-gutter text-light justify-content-end">
class="container-xxl bd-gutter flex-wrap flex-lg-nowrap text-light" <ul class="m-0 p-0">
></nav> <li>
<router-link :to="{ name: 'imprint' }">Imprint</router-link>
</li>
<li>
<router-link :to="{ name: 'privacy' }">Privacy</router-link>
</li>
<li>
<router-link :to="{ name: 'terms' }">Terms</router-link>
</li>
<li>
<a href="https://gitlab.ub.uni-bielefeld.de/cmg/clowm">GitLab</a>
</li>
</ul>
</nav>
</footer> </footer>
</template> </template>
...@@ -14,4 +27,25 @@ ...@@ -14,4 +27,25 @@
footer { footer {
background: rgb(255, 177, 45); background: rgb(255, 177, 45);
} }
li {
display: inline;
margin-right: 0.5rem !important;
}
li:not(:first-child):before {
content: "·";
margin-right: 0.5rem !important;
color: var(--bs-dark);
}
a {
text-decoration: none;
color: var(--bs-dark);
}
a:hover {
text-decoration: underline;
color: white;
}
</style> </style>
...@@ -17,6 +17,15 @@ const modalSizeClass = computed<string>(() => { ...@@ -17,6 +17,15 @@ const modalSizeClass = computed<string>(() => {
} }
return "modal-" + props.sizeModifier; return "modal-" + props.sizeModifier;
}); });
function trackModalShow() {
window._paq.push([
"trackEvent",
"Modal",
"Show " + props.modalLabel,
props.trackModalValue,
]);
}
</script> </script>
<template> <template>
...@@ -27,6 +36,7 @@ const modalSizeClass = computed<string>(() => { ...@@ -27,6 +36,7 @@ const modalSizeClass = computed<string>(() => {
:aria-labelledby="modalLabel" :aria-labelledby="modalLabel"
aria-hidden="true" aria-hidden="true"
:data-bs-backdrop="staticBackdrop ? 'static' : null" :data-bs-backdrop="staticBackdrop ? 'static' : null"
v-on="{ 'show.bs.modal': trackModalShow }"
> >
<div <div
class="modal-dialog modal-dialog-centered modal-dialog-scrollable" class="modal-dialog modal-dialog-centered modal-dialog-scrollable"
......
...@@ -7,6 +7,8 @@ export const environment: env = { ...@@ -7,6 +7,8 @@ export const environment: env = {
AUTH_API_BASE_URL: windowEnv["authApiUrl"], AUTH_API_BASE_URL: windowEnv["authApiUrl"],
WORKFLOW_API_BASE_URL: windowEnv["workflowApiUrl"], WORKFLOW_API_BASE_URL: windowEnv["workflowApiUrl"],
RESOURCE_API_BASE_URL: windowEnv["resourceApiUrl"], RESOURCE_API_BASE_URL: windowEnv["resourceApiUrl"],
MATOMO_SITE_ID: parseInt(windowEnv["matomoSiteId"]),
MATOMO_HOST: windowEnv["matomoHost"],
DEV_SYSTEM: windowEnv["devSystem"].toLowerCase() === "true", DEV_SYSTEM: windowEnv["devSystem"].toLowerCase() === "true",
}; };
...@@ -15,6 +17,8 @@ type env = { ...@@ -15,6 +17,8 @@ type env = {
S3PROXY_API_BASE_URL: string; S3PROXY_API_BASE_URL: string;
AUTH_API_BASE_URL: string; AUTH_API_BASE_URL: string;
WORKFLOW_API_BASE_URL: string; WORKFLOW_API_BASE_URL: string;
MATOMO_SITE_ID: number;
MATOMO_HOST: string;
RESOURCE_API_BASE_URL: string; RESOURCE_API_BASE_URL: string;
DEV_SYSTEM: boolean; DEV_SYSTEM: boolean;
}; };
...@@ -5,6 +5,8 @@ import App from "./App.vue"; ...@@ -5,6 +5,8 @@ import App from "./App.vue";
import router from "./router"; import router from "./router";
import { Chart, Colors } from "chart.js"; import { Chart, Colors } from "chart.js";
import zoomPlugin from "chartjs-plugin-zoom"; import zoomPlugin from "chartjs-plugin-zoom";
import VueMatomo from "vue-matomo";
import { environment } from "@/environment";
Chart.register(zoomPlugin, Colors); Chart.register(zoomPlugin, Colors);
...@@ -37,6 +39,22 @@ globalCookiesConfig({ ...@@ -37,6 +39,22 @@ globalCookiesConfig({
const app = createApp(App); const app = createApp(App);
declare global {
// tslint:disable-next-line:interface-name
interface Window {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_paq: any[];
}
}
if (environment.MATOMO_HOST && environment.MATOMO_SITE_ID) {
app.use(VueMatomo, {
host: environment.MATOMO_HOST,
siteId: environment.MATOMO_SITE_ID,
disableCookies: true,
});
}
app.use(createPinia()); app.use(createPinia());
app.use(router); app.use(router);
......
...@@ -38,6 +38,30 @@ const router = createRouter({ ...@@ -38,6 +38,30 @@ const router = createRouter({
name: "buckets", name: "buckets",
}, },
}, },
{
path: "/privacy",
name: "privacy",
meta: {
title: "Privacy Policy",
},
component: import("../views/PrivacyPolicyView.vue"),
},
{
path: "/terms",
name: "terms",
meta: {
title: "Terms of Usage",
},
component: import("../views/TermsOfUsageView.vue"),
},
{
path: "/imprint",
name: "imprint",
meta: {
title: "Imprint",
},
component: import("../views/ImprintView.vue"),
},
{ {
path: "/:pathMatch(.*)", path: "/:pathMatch(.*)",
meta: { meta: {
......
...@@ -112,6 +112,7 @@ export const useAuthStore = defineStore({ ...@@ -112,6 +112,7 @@ export const useAuthStore = defineStore({
useNameStore().addNameToMapping(user.uid, user.display_name); useNameStore().addNameToMapping(user.uid, user.display_name);
}, },
logout() { logout() {
window._paq.push(["resetUserId"]);
S3ProxyOpenAPI.TOKEN = undefined; S3ProxyOpenAPI.TOKEN = undefined;
AuthOpenAPI.TOKEN = undefined; AuthOpenAPI.TOKEN = undefined;
WorkflowOpenAPI.TOKEN = undefined; WorkflowOpenAPI.TOKEN = undefined;
......
declare module "vue-matomo";
<script setup lang="ts"></script>
<template>
<h2>Impressum</h2>
<p>TBD</p>
</template>
<style scoped></style>
<script setup lang="ts"></script>
<template>
<h2>Privacy Policy</h2>
<p>TBD</p>
</template>
<style scoped></style>
<script setup lang="ts"></script>
<template>
<h2>Terms of Usage</h2>
<p>TBD</p>
</template>
<style scoped></style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment