Skip to content

Commit 1ae4191

Browse files
Codetraumaheeckhau
andauthored
Matomo tracking (#41)
* feat: adding matomo tracking to explorer * Avoid build problem --------- Co-authored-by: Hendrik Eeckhaut <[email protected]>
1 parent b6294a2 commit 1ae4191

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { useEffect } from 'react';
2+
import { useLocation } from 'react-router-dom';
3+
4+
declare global {
5+
interface Window {
6+
_paq?: any[];
7+
}
8+
}
9+
10+
const MatomoTracking = () => {
11+
const location = useLocation();
12+
13+
useEffect(() => {
14+
if (typeof window !== 'undefined') {
15+
var _paq = (window._paq = window._paq || []);
16+
_paq.push(['setTrackerUrl', 'https://psedev.matomo.cloud/matomo.php']);
17+
_paq.push(['setSiteId', '16']);
18+
let script = document.createElement('script');
19+
script.async = true;
20+
script.src = 'https://cdn.matomo.cloud/psedev.matomo.cloud/matomo.js';
21+
document.head.appendChild(script);
22+
}
23+
}, []);
24+
25+
useEffect(() => {
26+
27+
if (typeof window !== 'undefined' && window._paq) {
28+
window._paq.push(['setCustomUrl', window.location.pathname]);
29+
window._paq.push(['trackPageView']);
30+
}
31+
}, [location.pathname]);
32+
return null;
33+
};
34+
35+
export default MatomoTracking;

web/pages/App/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { Routes, Route } from 'react-router-dom';
33
import Header from '../../components/Header';
44
import SharedProof from '../../components/SharedProof';
55
import FileDrop from '../FileDrop';
6+
import MatomoTracking from '../../components/MatomoTracking';
67
import './index.scss';
78

89
export default function App(): ReactElement {
910
return (
1011
<div className="app flex flex-col gap-4">
1112
<Header />
13+
<MatomoTracking />
1214
<Routes>
1315
<Route path="/" element={<FileDrop />} />
1416
<Route path="/ipfs/:cid" element={<SharedProof />} />

web/store/proofs.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ThunkDispatch } from 'redux-thunk';
22
import { AppRootState } from './index';
3-
import type { Proof } from 'tlsn-js-v5/build/types';
43
import { useSelector } from 'react-redux';
54
import deepEqual from 'fast-deep-equal';
65
import { EXPLORER_URL } from '../utils/constants';

0 commit comments

Comments
 (0)