Skip to content

Commit 64453a7

Browse files
authored
Merge branch 'develop' into staging-env-setup
2 parents db48bbe + 829cf8a commit 64453a7

File tree

11 files changed

+94
-34
lines changed

11 files changed

+94
-34
lines changed

.circleci/config.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,7 @@ workflows:
202202
filters:
203203
branches:
204204
only:
205-
- develop
206-
- notifications-analytics
205+
- hot-fix-hall-of-fame
207206
# This is alternate dev env for parallel testing
208207
- "build-test":
209208
context : org-global
@@ -218,8 +217,7 @@ workflows:
218217
branches:
219218
only:
220219
- develop
221-
- notifications-analytics
222-
# This is beta env for production soft releases
220+
# This is stage env for production QA releases
223221
- "build-prod-staging":
224222
context : org-global
225223
filters:

__tests__/shared/components/Header/__snapshots__/index.jsx.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,26 @@ exports[`Default render 1`] = `
182182
"title": "Switch to BUSINESS",
183183
}
184184
}
185+
tracking={
186+
Object {
187+
"default": undefined,
188+
"event": [Function],
189+
"init": [Function],
190+
"pageView": [Function],
191+
}
192+
}
185193
/>
186194
}
187195
setOpenMore={[Function]}
188196
theme="light"
197+
tracking={
198+
Object {
199+
"default": undefined,
200+
"event": [Function],
201+
"init": [Function],
202+
"pageView": [Function],
203+
}
204+
}
189205
/>
190206
</div>
191207
`;

config/default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ module.exports = {
9696

9797
SWIFT_PROGRAM_ID: 3445,
9898

99+
/* Google Analytics tracking ID */
100+
GOOGLE_ANALYTICS_ID: 'UA-161803421-1',
101+
99102
/* Various URLs. Most of them lead to different segments of Topcoder
100103
* platform. */
101104
URL: {

config/production.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ module.exports = {
99
DOMAIN: 'topcoder.auth0.com',
1010
},
1111
CDN: {
12-
PUBLIC: 'https://d2nl5eqipnb33q.cloudfront.net',
12+
PUBLIC: 'https://dlxczxztayxv6.cloudfront.net',
1313
},
1414
COOKIES: {
1515
MAXAGE: 7,
1616
SECURE: true,
1717
},
1818
LOG_ENTRIES_TOKEN: '',
1919
SERVER_API_KEY: 'aa9ccf36-3936-450c-9983-097ddba51bef',
20+
GOOGLE_ANALYTICS_ID: 'UA-6340959-1',
2021
URL: {
2122
ARENA: 'https://arena.topcoder.com',
2223
APP: 'https://community-app.topcoder.com',

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"test": "npm run lint && npm run --runInBand jest",
1919
"commitlint": "commitlint -E HUSKY_GIT_PARAMS",
2020
"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"
2222
},
2323
"repository": {
2424
"type": "git",
@@ -62,6 +62,7 @@
6262
"filestack-react": "^2.0.0",
6363
"flag-icon-css": "^3.3.0",
6464
"focus-trap-react": "^6.0.0",
65+
"react-ga": "^2.7.0",
6566
"helmet": "^3.12.1",
6667
"highlight.js": "^9.18.1",
6768
"html-to-text": "^5.1.1",
@@ -133,7 +134,7 @@
133134
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
134135
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
135136
"tc-ui": "^1.0.12",
136-
"topcoder-react-lib": "v0.17.0",
137+
"topcoder-react-lib": "v1000.16.0",
137138
"topcoder-react-ui-kit": "^1.0.11",
138139
"topcoder-react-utils": "0.7.8",
139140
"turndown": "^4.0.2",

src/shared/actions/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
import { actions } from 'topcoder-react-lib';
88
import pageActions from './page';
9+
import * as tracking from './tracking';
10+
11+
export { tracking };
912

1013
export default {
1114
...pageActions,

src/shared/actions/tracking.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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;

src/shared/components/Header/index.jsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import _ from 'lodash';
22
import React, { useState, useEffect } from 'react';
33
import PT from 'prop-types';
44
import { config } from 'topcoder-react-utils';
5-
import { tracking } from 'topcoder-react-lib';
65
import Logo from 'assets/images/tc-logo.svg';
6+
import { tracking } from '../../actions';
77

88
let TopNavRef;
99
let LoginNavRef;
@@ -54,23 +54,18 @@ const Header = ({
5454
}, []);
5555

5656
/*
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
6858
*/
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+
}, []);
7469

7570
if (TopNavRef) {
7671
return (
@@ -95,6 +90,7 @@ const Header = ({
9590
auth={auth}
9691
profile={normalizedProfile}
9792
authURLs={config.HEADER_AUTH_URLS}
93+
tracking={tracking}
9894
/>
9995
)}
10096
logo={<Logo />}
@@ -106,6 +102,7 @@ const Header = ({
106102
setOpenMore={handleChangeOpenMore}
107103
loggedIn={!_.isEmpty(profile)}
108104
profileHandle={profile ? profile.handle : ''}
105+
tracking={tracking}
109106
/>
110107
</div>
111108
);

src/shared/components/Notifications/TabsPanel/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import cn from 'classnames';
4-
import { tracking } from 'topcoder-react-lib';
54
import styles from './style.scss';
65

76

@@ -21,7 +20,7 @@ export default class TabsPanel extends React.Component {
2120

2221

2322
render() {
24-
const { changeTab } = this.props;
23+
const { changeTab, tracking } = this.props;
2524
const { tab } = this.state;
2625
return (
2726
<div className={styles.container}>
@@ -106,4 +105,5 @@ export default class TabsPanel extends React.Component {
106105

107106
TabsPanel.propTypes = {
108107
changeTab: PropTypes.func.isRequired,
108+
tracking: PropTypes.shape().isRequired,
109109
};

src/shared/components/Notifications/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import cn from 'classnames';
44
import _ from 'lodash';
55
import moment from 'moment';
66
import { Link } from 'topcoder-react-utils';
7-
import { tracking } from 'topcoder-react-lib';
87
import IconArrow from 'assets/images/notifications/arrow.svg';
8+
import { tracking } from '../../actions';
99
import styles from './style.scss';
1010
import TabsPanel from './TabsPanel';
1111

@@ -184,6 +184,7 @@ export default class NotificationList extends React.Component {
184184
<div className={styles['notifications-panel']}>
185185
<TabsPanel
186186
changeTab={tab => this.setState({ activeTab: tab })}
187+
tracking={tracking}
187188
/>
188189
<div className={styles['noti-body']}>
189190
<Fragment key="nonComplete">

src/shared/routes/HallOfFame.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/**
22
* The loader/router for TCO Hall of Fame
33
*/
4-
import path from 'path';
54
import React from 'react';
65

76
import LoadingPagePlaceholder from 'components/LoadingPagePlaceholder';
8-
import { AppChunk, webpack } from 'topcoder-react-utils';
7+
import { AppChunk } from 'topcoder-react-utils';
98

109
export default function HallOfFameRouter(props) {
1110
return (
@@ -17,11 +16,6 @@ export default function HallOfFameRouter(props) {
1716
))
1817
}
1918
renderPlaceholder={() => <LoadingPagePlaceholder />}
20-
renderServer={() => {
21-
const p = webpack.resolveWeak('components/HallOfFamePage');
22-
const HallOfFameContainer = webpack.requireWeak(path.resolve(__dirname, p));
23-
return <HallOfFameContainer {...props} />;
24-
}}
2519
/>
2620
);
2721
}

0 commit comments

Comments
 (0)