Skip to content

Commit

Permalink
Matomo tracking (#41)
Browse files Browse the repository at this point in the history
* feat: adding matomo tracking to explorer

* Avoid build problem

---------

Co-authored-by: Hendrik Eeckhaut <[email protected]>
  • Loading branch information
Codetrauma and heeckhau authored Mar 6, 2025
1 parent b6294a2 commit 1ae4191
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions web/components/MatomoTracking/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

declare global {
interface Window {
_paq?: any[];
}
}

const MatomoTracking = () => {
const location = useLocation();

useEffect(() => {
if (typeof window !== 'undefined') {
var _paq = (window._paq = window._paq || []);
_paq.push(['setTrackerUrl', 'https://psedev.matomo.cloud/matomo.php']);
_paq.push(['setSiteId', '16']);
let script = document.createElement('script');
script.async = true;
script.src = 'https://cdn.matomo.cloud/psedev.matomo.cloud/matomo.js';
document.head.appendChild(script);
}
}, []);

useEffect(() => {

if (typeof window !== 'undefined' && window._paq) {
window._paq.push(['setCustomUrl', window.location.pathname]);
window._paq.push(['trackPageView']);
}
}, [location.pathname]);
return null;
};

export default MatomoTracking;
2 changes: 2 additions & 0 deletions web/pages/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { Routes, Route } from 'react-router-dom';
import Header from '../../components/Header';
import SharedProof from '../../components/SharedProof';
import FileDrop from '../FileDrop';
import MatomoTracking from '../../components/MatomoTracking';
import './index.scss';

export default function App(): ReactElement {
return (
<div className="app flex flex-col gap-4">
<Header />
<MatomoTracking />
<Routes>
<Route path="/" element={<FileDrop />} />
<Route path="/ipfs/:cid" element={<SharedProof />} />
Expand Down
1 change: 0 additions & 1 deletion web/store/proofs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ThunkDispatch } from 'redux-thunk';
import { AppRootState } from './index';
import type { Proof } from 'tlsn-js-v5/build/types';
import { useSelector } from 'react-redux';
import deepEqual from 'fast-deep-equal';
import { EXPLORER_URL } from '../utils/constants';
Expand Down

0 comments on commit 1ae4191

Please sign in to comment.