File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ changes.
1212
1313### Added
1414
15- -
15+ - Integrate matomo analytics
1616
1717### Fixed
1818
Original file line number Diff line number Diff line change @@ -39,8 +39,10 @@ import {
3939import { PublicRoute } from "./pages/PublicRoute" ;
4040import { TopBanners } from "./components/organisms/TopBanners" ;
4141import { DashboardHome } from "./pages/DashboardHome" ;
42+ import { useMatomo } from "./hooks/useMatomo" ;
4243
4344export default ( ) => {
45+ useMatomo ( ) ;
4446 const { isProposalDiscussionForumEnabled } = useFeatureFlag ( ) ;
4547 const { enable, isEnabled } = useCardano ( ) ;
4648 const navigate = useNavigate ( ) ;
Original file line number Diff line number Diff line change 1+ /* eslint-disable func-names */
2+ /* eslint-disable no-multi-assign */
3+ /* eslint-disable prefer-template */
4+ /* eslint-disable no-underscore-dangle */
5+ /* eslint-disable wrap-iife */
6+ import { useEffect } from "react" ;
7+
8+ export const useMatomo = ( ) => {
9+ useEffect ( ( ) => {
10+ const env = import . meta. env . VITE_APP_ENV ;
11+ if ( env !== "prodction" || env !== "staging" ) {
12+ return ;
13+ }
14+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15+ // @ts -expect-error
16+ const _paq = ( window . _paq = window . _pag || [ ] ) ;
17+ _paq . push ( [ "trackPageView" ] ) ;
18+ _paq . push ( [ "enableLinkTracking" ] ) ;
19+ ( function ( ) {
20+ const u = "//analytics.gov.tools/" ;
21+ _paq . push ( [ "setTrackerUrl" , u + "matomo.php" ] ) ;
22+ _paq . push ( [ "setSiteId" , env === "production" ? "1" : "2" ] ) ;
23+ const d = document ;
24+ const g = d . createElement ( "script" ) ;
25+ const s = d . getElementsByTagName ( "script" ) [ 0 ] ;
26+ g . async = true ;
27+ g . src = u + "matomo.js" ;
28+ s . parentNode ?. insertBefore ( g , s ) ;
29+ } ) ( ) ;
30+ } , [ ] ) ;
31+ } ;
You can’t perform that action at this time.
0 commit comments