Skip to content

Commit 0053e67

Browse files
committed
WIP UA
1 parent 1923615 commit 0053e67

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@
221221
"react-jss": "^10.6.0",
222222
"react-router-dom": "^5.2.0",
223223
"regenerator-runtime": "^0.13.5",
224-
"source-map-support": "^0.5.19"
224+
"source-map-support": "^0.5.19",
225+
"universal-analytics": "^0.4.23"
225226
},
226227
"devEngines": {
227228
"node": ">=10.x",

src/screens/Main.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
import React from 'react';
2-
import { Route, Switch, Link, Redirect } from 'react-router-dom';
1+
import React, { useEffect } from 'react';
2+
import { Route, Switch, Link, Redirect, useLocation } from 'react-router-dom';
33
import { Layout } from 'antd';
44

55
import ProjectsScreen from './projects/ProjectsScreen';
66
import TaskControl from '../components/TaskControl/TaskControl';
77
import HeaderMenu from '../components/HeaderMenu/HeaderMenu';
88
import HoursScreen from './hours/HoursScreen';
99
import Dashboard from './dashboard/Dashboard';
10+
import analytics from '../services/GaService';
1011

1112
const { Header } = Layout;
1213

1314
const Main = () => {
15+
const location = useLocation();
16+
17+
useEffect(() => {
18+
analytics?.pageview(location.pathname);
19+
}, [location.pathname]);
20+
1421
return (
1522
<Layout className="layout">
1623
<Header>

src/services/GaService.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import ua from 'universal-analytics';
2+
3+
const gaCode = process.env.GA_GCODE;
4+
let analytics: any | null = null;
5+
console.log(gaCode);
6+
if (gaCode) {
7+
debugger;
8+
analytics = ua(gaCode);
9+
}
10+
11+
export default analytics;

src/types/Types.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare module 'universal-analytics' {
2+
const ua: (code: string) => any;
3+
4+
export default ua;
5+
}

yarn.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10451,6 +10451,15 @@ unique-string@^2.0.0:
1045110451
dependencies:
1045210452
crypto-random-string "^2.0.0"
1045310453

10454+
universal-analytics@^0.4.23:
10455+
version "0.4.23"
10456+
resolved "https://registry.yarnpkg.com/universal-analytics/-/universal-analytics-0.4.23.tgz#d915e676850c25c4156762471bdd7cf2eaaca8ac"
10457+
integrity sha512-lgMIH7XBI6OgYn1woDEmxhGdj8yDefMKg7GkWdeATAlQZFrMrNyxSkpDzY57iY0/6fdlzTbBV03OawvvzG+q7A==
10458+
dependencies:
10459+
debug "^4.1.1"
10460+
request "^2.88.2"
10461+
uuid "^3.0.0"
10462+
1045410463
universalify@^0.1.0:
1045510464
version "0.1.2"
1045610465
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
@@ -10586,7 +10595,7 @@ utils-merge@1.0.1:
1058610595
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
1058710596
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=
1058810597

10589-
uuid@^3.3.2, uuid@^3.4.0:
10598+
uuid@^3.0.0, uuid@^3.3.2, uuid@^3.4.0:
1059010599
version "3.4.0"
1059110600
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
1059210601
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

0 commit comments

Comments
 (0)