diff --git a/package-lock.json b/package-lock.json index 25716861b..8ce550068 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,6 +38,19 @@ "regenerator-runtime": "^0.13.2" } }, + "@datapunt/matomo-tracker-js": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@datapunt/matomo-tracker-js/-/matomo-tracker-js-0.2.1.tgz", + "integrity": "sha512-XI4xXpBS4S3BKl9wO6uda7GM/LUreS2N5Ep1cAtpIrKm4pZXTwF5Du/Qpv1HyBWoEjjCpRM7jIvyfrcVzEAQqg==" + }, + "@datapunt/matomo-tracker-react": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@datapunt/matomo-tracker-react/-/matomo-tracker-react-0.2.1.tgz", + "integrity": "sha512-7PN+IsjF5rL85U52dSbY1tsdrBIkAp/qRS3eLWZSK2seLk4KoluuKUoVZRH/FvVX/nv43GKtjooYErui3UPH4Q==", + "requires": { + "@datapunt/matomo-tracker-js": "^0.2.1" + } + }, "@develar/schema-utils": { "version": "2.6.5", "resolved": "https://registry.npmjs.org/@develar/schema-utils/-/schema-utils-2.6.5.tgz", diff --git a/package.json b/package.json index 9844f261b..eb4ab03d0 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ }, "homepage": "https://github.com/ubilabs/esa-climate-from-space#readme", "dependencies": { + "@datapunt/matomo-tracker-react": "^0.2.1", "@types/react-router-dom": "^5.1.3", "@types/redux-logger": "^3.0.7", "cesium": "^1.73.0", diff --git a/src/scripts/components/main/app/app.tsx b/src/scripts/components/main/app/app.tsx index 9456c23b6..a30c6641f 100644 --- a/src/scripts/components/main/app/app.tsx +++ b/src/scripts/components/main/app/app.tsx @@ -1,7 +1,12 @@ -import React, {FunctionComponent} from 'react'; +import React, {FunctionComponent, useEffect} from 'react'; import {Provider as StoreProvider, useSelector} from 'react-redux'; import {IntlProvider} from 'react-intl'; import {HashRouter as Router, Switch, Route} from 'react-router-dom'; +import { + MatomoProvider, + createInstance, + useMatomo +} from '@datapunt/matomo-tracker-react'; import {languageSelector} from '../../../selectors/language'; import UrlSync from '../url-sync/url-sync'; @@ -28,15 +33,45 @@ import styles from './app.styl'; // create redux store const store = createReduxStore(); +const instance = createInstance({ + urlBase: 'https://maltemodrow.matomo.cloud/', + siteId: 1, // optional, default value: `1` + // userId: 'UID76903202', // optional, default value: `undefined`. + trackerUrl: 'https://maltemodrow.matomo.cloud/matomo.php', // optional, default value: `${urlBase}matomo.php` + srcUrl: 'https://cdn.matomo.cloud/maltemodrow.matomo.cloud/matomo.js', // optional, default value: `${urlBase}matomo.js` + disabled: false, // optional, false by default. Makes all tracking calls no-ops if set to true. + linkTracking: false // optional, default value: true +}); + const App: FunctionComponent = () => ( - - - + + + + + ); const TranslatedApp: FunctionComponent = () => { const markers = useStoryMarkers(); const language = useSelector(languageSelector); + const {pushInstruction, trackPageView} = useMatomo(); + + useEffect(() => { + console.log('should track'); + + pushInstruction('requireConsent'); + pushInstruction('requireCookieConsent'); + + // setTimeout(() => { + // pushInstruction('rememberConsentGiven'); + // pushInstruction('rememberCookieConsentGiven'); + // }, 10000); + + trackPageView({ + documentTitle: 'moin moin', // optional + href: 'https://LINK.TO.PAGE' // optional + }); + }, []); return (