diff --git a/CHANGELOG b/CHANGELOG index d88a916bee84dfa62f970d2f3d4fe15dbf262af2..8d971a9d8505802386fce2b25cfa29dedee661dd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +minerva-front (19.0.0~alpha.0) stable; urgency=medium + * Feature: support for matomo (#289) + + -- Piotr Gawron <piotr.gawron@uni.lu> Thu, 19 Sep 2024 13:00:00 +0200 + minerva-front (18.0.0~beta.2) stable; urgency=medium * Feature: minerva frontend - first version * Bugfix: when opening overlay provide loading info (#285) diff --git a/src/redux/configuration/configuration.constants.ts b/src/redux/configuration/configuration.constants.ts index 59ef10da2e7defa1753613d5b185ad0d6d454439..c6084ddf6c5aee1da7ec1cb6c98938ff3dd8aed4 100644 --- a/src/redux/configuration/configuration.constants.ts +++ b/src/redux/configuration/configuration.constants.ts @@ -5,6 +5,7 @@ export const NEUTRAL_COLOR_VAL_NAME_ID = 'NEUTRAL_COLOR_VAL'; export const OVERLAY_OPACITY_NAME_ID = 'OVERLAY_OPACITY'; export const SEARCH_DISTANCE_NAME_ID = 'SEARCH_DISTANCE'; export const REQUEST_ACCOUNT_EMAIL = 'REQUEST_ACCOUNT_EMAIL'; +export const MATOMO_URL = 'MATOMO_URL'; export const LEGEND_FILE_NAMES_IDS = [ 'LEGEND_FILE_1', diff --git a/src/redux/root/init.thunks.ts b/src/redux/root/init.thunks.ts index 4e161b6e786697a53f445b4b880fcafab26c3b7b..41fa48fabdf9d984e8117917b4f01c338ab0d1b2 100644 --- a/src/redux/root/init.thunks.ts +++ b/src/redux/root/init.thunks.ts @@ -1,6 +1,6 @@ import { PROJECT_ID } from '@/constants'; import { openOverlaysDrawer, openSearchDrawerWithSelectedTab } from '@/redux/drawer/drawer.slice'; -import { AppDispatch } from '@/redux/store'; +import { AppDispatch, store } from '@/redux/store'; import { QueryData } from '@/types/query'; import { getDefaultSearchTab } from '@/components/FunctionalArea/TopBar/SearchBar/SearchBar.utils'; import { PluginsManager } from '@/services/pluginsManager'; @@ -16,6 +16,7 @@ import { openSelectProjectModal } from '@/redux/modal/modal.slice'; import { getProjects } from '@/redux/projects/projects.thunks'; import { getSubmapConnectionsBioEntity } from '@/redux/bioEntity/thunks/getSubmapConnectionsBioEntity'; import { getShapes } from '@/redux/shapes/shapes.thunks'; +import { MATOMO_URL } from '@/redux/configuration/configuration.constants'; import { getAllBackgroundsByProjectId } from '../backgrounds/backgrounds.thunks'; import { getConfiguration, getConfigurationOptions } from '../configuration/configuration.thunks'; import { @@ -62,6 +63,39 @@ export const fetchInitialAppData = createAsyncThunk< dispatch(getShapes()), ]); + try { + const configuration = store.getState().configuration.main.data; + + if (configuration) { + const options = configuration.options.filter(option => option.type === MATOMO_URL); + let url = ''; + if (options.length > ZERO) { + url = options[ZERO].value ? options[ZERO].value : ''; + } + if (!url.startsWith('http')) { + url = ''; + } + if (url !== '') { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + // eslint-disable-next-line no-underscore-dangle,no-multi-assign + const _mtm = (window._mtm = window._mtm || []); + _mtm.push({ 'mtm.startTime': new Date().getTime(), event: 'mtm.Start' }); + const d = document; + const g = d.createElement('script'); + const s = d.getElementsByTagName('script')[ZERO]; + g.async = true; + g.src = url; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + s.parentNode.insertBefore(g, s); + } + } + } catch (e) { + // eslint-disable-next-line no-console + console.log(e); + } + if (queryData.pluginsId) { await dispatch( getInitPlugins({