Skip to content

Commit 13bc261

Browse files
committed
Merge branch 'feature-contentful' of https://github.com/topcoder-platform/community-app into feature-contentful
2 parents 10774e0 + ff9f642 commit 13bc261

File tree

11 files changed

+129
-25
lines changed

11 files changed

+129
-25
lines changed

.circleci/config.yml

+37-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,35 @@ jobs:
119119
source awsenvconf
120120
source buildenvvar
121121
./master_deploy.sh -d ECS -e PROD -t latest -s beta_communityapp_taskvar, -i communityapp
122-
122+
123+
# Build & Deploy against prod api backend
124+
"build-prod-staging":
125+
<<: *defaults
126+
steps:
127+
# Initialization.
128+
- checkout
129+
- setup_remote_docker
130+
- run: *install_dependency
131+
- run: *install_deploysuite
132+
# Restoration of node_modules from cache.
133+
- restore_cache: *restore_cache_settings_for_build
134+
- run:
135+
name: "configuring environment"
136+
command: |
137+
./awsconfiguration.sh PROD
138+
./buildenv.sh -e PROD -b staging_communityapp_buildvar,staging_communityapp_deployvar
139+
# Build of Docker image.
140+
- run: *build_docker_image
141+
# Caching node modules.
142+
- save_cache: *save_cache_settings
143+
# Deployment.
144+
- deploy:
145+
name: Running MasterScript
146+
command: |
147+
source awsenvconf
148+
source buildenvvar
149+
./master_deploy.sh -d ECS -e PROD -t latest -s staging_communityapp_taskvar, -i communityapp
150+
123151
# Build & Deploy against production backend
124152
"build-prod":
125153
<<: *defaults
@@ -174,7 +202,7 @@ workflows:
174202
filters:
175203
branches:
176204
only:
177-
- hot-fix-hall-of-fame
205+
- develop
178206
# This is alternate dev env for parallel testing
179207
- "build-test":
180208
context : org-global
@@ -189,8 +217,14 @@ workflows:
189217
filters:
190218
branches:
191219
only:
192-
- hot-fix-hall-of-fame
193220
- develop
221+
# This is stage env for production QA releases
222+
- "build-prod-staging":
223+
context : org-global
224+
filters:
225+
branches:
226+
only:
227+
- staging-env-setup
194228
# Production builds are exectuted
195229
# when PR is merged to the master
196230
# Don't change anything in this configuration

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

+16
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

+3
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

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
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',

deploy.sh

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ make_task_def(){
8585
NODE_CONFIG_ENV=production
8686
elif [ "$ENV" = "PRODBETA" ]; then
8787
NODE_CONFIG_ENV=production
88+
elif [ "$ENV" = "PRODSTAGING" ]; then
89+
NODE_CONFIG_ENV=production
8890
elif [ "$ENV" = "DEV" ]; then
8991
NODE_CONFIG_ENV=development
9092
elif [ "$ENV" = "TEST" ]; then

package.json

+3-2
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": "0.17.2",
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

+3
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

+46
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

+14-17
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

+2-2
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

+2-1
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">

0 commit comments

Comments
 (0)