File tree Expand file tree Collapse file tree 8 files changed +76
-4
lines changed Expand file tree Collapse file tree 8 files changed +76
-4
lines changed Original file line number Diff line number Diff line change @@ -182,10 +182,26 @@ exports[`Default render 1`] = `
182
182
" title" : " Switch to BUSINESS" ,
183
183
}
184
184
}
185
+ tracking = {
186
+ Object {
187
+ " default" : undefined ,
188
+ " event" : [Function ],
189
+ " init" : [Function ],
190
+ " pageView" : [Function ],
191
+ }
192
+ }
185
193
/>
186
194
}
187
195
setOpenMore = { [Function ]}
188
196
theme = " light"
197
+ tracking = {
198
+ Object {
199
+ " default" : undefined ,
200
+ " event" : [Function ],
201
+ " init" : [Function ],
202
+ " pageView" : [Function ],
203
+ }
204
+ }
189
205
/>
190
206
</div >
191
207
` ;
Original file line number Diff line number Diff line change @@ -96,6 +96,9 @@ module.exports = {
96
96
97
97
SWIFT_PROGRAM_ID : 3445 ,
98
98
99
+ /* Google Analytics tracking ID */
100
+ GOOGLE_ANALYTICS_ID : 'UA-161803421-1' ,
101
+
99
102
/* Various URLs. Most of them lead to different segments of Topcoder
100
103
* platform. */
101
104
URL : {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ module.exports = {
17
17
} ,
18
18
LOG_ENTRIES_TOKEN : '' ,
19
19
SERVER_API_KEY : 'aa9ccf36-3936-450c-9983-097ddba51bef' ,
20
+ GOOGLE_ANALYTICS_ID : 'UA-6340959-1' ,
20
21
URL : {
21
22
ARENA : 'https://arena.topcoder.com' ,
22
23
APP : 'https://community-app.topcoder.com' ,
Original file line number Diff line number Diff line change 18
18
"test" : " npm run lint && npm run --runInBand jest" ,
19
19
"commitlint" : " commitlint -E HUSKY_GIT_PARAMS" ,
20
20
"release:changelog" : " npm run conventional-changelog -- -p angular -i CHANGELOG.md -s" ,
21
- "postinstall" : " rimraf node_modules/navigation-component/node_modules/topcoder-react-utils && rimraf node_modules/navigation-component/node_modules/topcoder-react-lib && rimraf node_modules/ topcoder-react-ui-kit/node_modules/topcoder-react-utils"
21
+ "postinstall" : " rimraf node_modules/navigation-component/node_modules/topcoder-react-utils && rimraf node_modules/topcoder-react-ui-kit/node_modules/topcoder-react-utils"
22
22
},
23
23
"repository" : {
24
24
"type" : " git" ,
62
62
"filestack-react" : " ^2.0.0" ,
63
63
"flag-icon-css" : " ^3.3.0" ,
64
64
"focus-trap-react" : " ^6.0.0" ,
65
+ "react-ga" : " ^2.7.0" ,
65
66
"helmet" : " ^3.12.1" ,
66
67
"highlight.js" : " ^9.18.1" ,
67
68
"html-to-text" : " ^5.1.1" ,
81
82
"moment-timezone" : " ^0.5.21" ,
82
83
"money" : " ^0.2.0" ,
83
84
"morgan" : " ^1.9.0" ,
84
- "navigation-component" : " topcoder-platform/navigation-component#develop " ,
85
+ "navigation-component" : " topcoder-platform/navigation-component#ga-hotfix " ,
85
86
"node-forge" : " ^0.7.5" ,
86
87
"nuka-carousel" : " ^4.5.3" ,
87
88
"postcss" : " ^6.0.23" ,
Original file line number Diff line number Diff line change 6
6
7
7
import { actions } from 'topcoder-react-lib' ;
8
8
import pageActions from './page' ;
9
+ import * as tracking from './tracking' ;
10
+
11
+ export { tracking } ;
9
12
10
13
export default {
11
14
...pageActions ,
Original file line number Diff line number Diff line change
1
+ /* global window */
2
+
3
+ import ReactGA from 'react-ga' ;
4
+ import { config } from 'topcoder-react-utils' ;
5
+
6
+ const TRACKING_NAME = 'tracking' ;
7
+
8
+ /**
9
+ * init - Init Google Analytics tracking
10
+ * @param {string } userId
11
+ */
12
+ export const init = ( userId ) => {
13
+ ReactGA . initialize ( [ {
14
+ trackingId : config . GOOGLE_ANALYTICS_ID ,
15
+ gaOptions : {
16
+ name : TRACKING_NAME ,
17
+ userId,
18
+ } ,
19
+ } ] , {
20
+ alwaysSendToDefaultTracker : false ,
21
+ } ) ;
22
+ } ;
23
+
24
+ /**
25
+ * pageView - Track page view
26
+ */
27
+ export const pageView = ( ) => {
28
+ ReactGA . pageview ( window . location . pathname
29
+ + window . location . search , [ TRACKING_NAME ] ) ;
30
+ } ;
31
+
32
+ /**
33
+ * event - Add custom tracking event.
34
+ * @param {string } category
35
+ * @param {string } action
36
+ * @param {string } label
37
+ */
38
+ export const event = ( category , action , label ) => {
39
+ ReactGA . event ( {
40
+ category,
41
+ action,
42
+ label,
43
+ } , [ TRACKING_NAME ] ) ;
44
+ } ;
45
+
46
+ export default undefined ;
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ import _ from 'lodash';
2
2
import React , { useState , useEffect } from 'react' ;
3
3
import PT from 'prop-types' ;
4
4
import { config } from 'topcoder-react-utils' ;
5
- import { tracking } from 'topcoder-react-lib' ;
6
5
import Logo from 'assets/images/tc-logo.svg' ;
6
+ import { tracking } from '../../actions' ;
7
7
8
8
let TopNavRef ;
9
9
let LoginNavRef ;
@@ -95,6 +95,7 @@ const Header = ({
95
95
auth = { auth }
96
96
profile = { normalizedProfile }
97
97
authURLs = { config . HEADER_AUTH_URLS }
98
+ tracking = { tracking }
98
99
/>
99
100
) }
100
101
logo = { < Logo /> }
@@ -106,6 +107,7 @@ const Header = ({
106
107
setOpenMore = { handleChangeOpenMore }
107
108
loggedIn = { ! _ . isEmpty ( profile ) }
108
109
profileHandle = { profile ? profile . handle : '' }
110
+ tracking = { tracking }
109
111
/>
110
112
</ div >
111
113
) ;
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ import cn from 'classnames';
4
4
import _ from 'lodash' ;
5
5
import moment from 'moment' ;
6
6
import { Link } from 'topcoder-react-utils' ;
7
- import { tracking } from 'topcoder-react-lib' ;
8
7
import IconArrow from 'assets/images/notifications/arrow.svg' ;
8
+ import { tracking } from '../../actions' ;
9
9
import styles from './style.scss' ;
10
10
import TabsPanel from './TabsPanel' ;
11
11
You can’t perform that action at this time.
0 commit comments