@@ -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 ;
@@ -54,23 +54,18 @@ const Header = ({
54
54
} , [ ] ) ;
55
55
56
56
/*
57
- * Reload notificaitons if token was changed
58
- * This prevent to use expired token in API call
59
- */
60
- if ( auth ) {
61
- useEffect ( ( ) => {
62
- loadNotifications ( auth . tokenV3 ) ;
63
- } , [ auth . tokenV3 ] ) ;
64
- }
65
-
66
- /*
67
- * Init Google Analytics
57
+ * Load Notifications and Init Google Analytics
68
58
*/
69
- if ( auth && auth . user ) {
70
- useEffect ( ( ) => {
71
- tracking . init ( auth . user . handle ) ;
72
- } , [ auth . user . handle ] ) ;
73
- }
59
+ useEffect ( ( ) => {
60
+ if ( auth ) {
61
+ if ( auth . tokenV3 ) {
62
+ loadNotifications ( auth . tokenV3 ) ;
63
+ }
64
+ if ( auth . user ) {
65
+ tracking . init ( auth . user . handle ) ;
66
+ }
67
+ }
68
+ } , [ ] ) ;
74
69
75
70
if ( TopNavRef ) {
76
71
return (
@@ -95,6 +90,7 @@ const Header = ({
95
90
auth = { auth }
96
91
profile = { normalizedProfile }
97
92
authURLs = { config . HEADER_AUTH_URLS }
93
+ tracking = { tracking }
98
94
/>
99
95
) }
100
96
logo = { < Logo /> }
@@ -106,6 +102,7 @@ const Header = ({
106
102
setOpenMore = { handleChangeOpenMore }
107
103
loggedIn = { ! _ . isEmpty ( profile ) }
108
104
profileHandle = { profile ? profile . handle : '' }
105
+ tracking = { tracking }
109
106
/>
110
107
</ div >
111
108
) ;
0 commit comments