File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
components/MatomoTracking Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change
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 ;
Original file line number Diff line number Diff line change @@ -3,12 +3,14 @@ import { Routes, Route } from 'react-router-dom';
3
3
import Header from '../../components/Header' ;
4
4
import SharedProof from '../../components/SharedProof' ;
5
5
import FileDrop from '../FileDrop' ;
6
+ import MatomoTracking from '../../components/MatomoTracking' ;
6
7
import './index.scss' ;
7
8
8
9
export default function App ( ) : ReactElement {
9
10
return (
10
11
< div className = "app flex flex-col gap-4" >
11
12
< Header />
13
+ < MatomoTracking />
12
14
< Routes >
13
15
< Route path = "/" element = { < FileDrop /> } />
14
16
< Route path = "/ipfs/:cid" element = { < SharedProof /> } />
Original file line number Diff line number Diff line change 1
1
import { ThunkDispatch } from 'redux-thunk' ;
2
2
import { AppRootState } from './index' ;
3
- import type { Proof } from 'tlsn-js-v5/build/types' ;
4
3
import { useSelector } from 'react-redux' ;
5
4
import deepEqual from 'fast-deep-equal' ;
6
5
import { EXPLORER_URL } from '../utils/constants' ;
You can’t perform that action at this time.
0 commit comments