Skip to content

Commit 7642caa

Browse files
authored
Merge pull request #4303 from topcoder-platform/develop
Notifications Analytics
2 parents b4ecb67 + cffb032 commit 7642caa

File tree

9 files changed

+3234
-3433
lines changed

9 files changed

+3234
-3433
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ workflows:
175175
branches:
176176
only:
177177
- develop
178+
- notifications-analytics
178179
# This is alternate dev env for parallel testing
179180
- "build-test":
180181
context : org-global
@@ -189,6 +190,7 @@ workflows:
189190
branches:
190191
only:
191192
- develop
193+
- notifications-analytics
192194
# Production builds are exectuted
193195
# when PR is merged to the master
194196
# Don't change anything in this configuration

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
__coverage__/
22
.git/
3+
node_modules/

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ ENV CONTENTFUL_EDU_PREVIEW_API_KEY=$CONTENTFUL_EDU_PREVIEW_API_KEY
119119
################################################################################
120120
# Testing and build of the application inside the container.
121121

122+
RUN npm config set unsafe-perm true
122123
RUN npm install
123124
RUN npm test
124125
RUN npm run build

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,4 @@ exports[`Default render 1`] = `
188188
theme="light"
189189
/>
190190
</div>
191-
`;
191+
`;

package-lock.json

Lines changed: 3188 additions & 3427 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
"lint": "npm run lint:js && npm run lint:scss",
1414
"lint:js": "eslint --ext .js,.jsx .",
1515
"lint:scss": "stylelint **/*.scss --syntax scss",
16+
"update-tests": "npm run jest -- -u",
1617
"start": "cross-env BABEL_ENV=production NODE_ENV=production node ./bin/www",
17-
"test": "npm run lint && npm run jest",
18+
"test": "npm run lint && npm run --runInBand jest",
1819
"commitlint": "commitlint -E HUSKY_GIT_PARAMS",
1920
"release:changelog": "npm run conventional-changelog -- -p angular -i CHANGELOG.md -s",
20-
"postinstall": "rimraf node_modules/navigation-component/node_modules/topcoder-react-utils && 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/navigation-component/node_modules/topcoder-react-lib && rimraf node_modules/topcoder-react-ui-kit/node_modules/topcoder-react-utils"
2122
},
2223
"repository": {
2324
"type": "git",
@@ -80,7 +81,7 @@
8081
"moment-timezone": "^0.5.21",
8182
"money": "^0.2.0",
8283
"morgan": "^1.9.0",
83-
"navigation-component": "git+https://github.com/topcoder-platform/navigation-component.git#develop",
84+
"navigation-component": "topcoder-platform/navigation-component#develop",
8485
"node-forge": "^0.7.5",
8586
"nuka-carousel": "^4.5.3",
8687
"postcss": "^6.0.23",
@@ -132,7 +133,7 @@
132133
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
133134
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
134135
"tc-ui": "^1.0.12",
135-
"topcoder-react-lib": "0.15.0",
136+
"topcoder-react-lib": "v0.17.0",
136137
"topcoder-react-ui-kit": "^1.0.11",
137138
"topcoder-react-utils": "0.7.8",
138139
"turndown": "^4.0.2",

src/shared/components/Header/index.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ 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';
56
import Logo from 'assets/images/tc-logo.svg';
67

78
let TopNavRef;
@@ -62,6 +63,15 @@ const Header = ({
6263
}, [auth.tokenV3]);
6364
}
6465

66+
/*
67+
* Init Google Analytics
68+
*/
69+
if (auth && auth.user) {
70+
useEffect(() => {
71+
tracking.init(auth.user.handle);
72+
}, [auth.user.handle]);
73+
}
74+
6575
if (TopNavRef) {
6676
return (
6777
<div>

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

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

67

@@ -33,12 +34,14 @@ export default class TabsPanel extends React.Component {
3334
() => {
3435
this.setState({ tab: TABS.ACTIVE });
3536
changeTab(TABS.ACTIVE);
37+
tracking.event('Click', 'Change Tab', 'Active Challenges');
3638
}
3739
}
3840
onKeyPress={
3941
() => {
4042
this.setState({ tab: TABS.ACTIVE });
4143
changeTab(TABS.ACTIVE);
44+
tracking.event('Click', 'Change Tab', 'Active Challenges');
4245
}
4346
}
4447
>CHALLENGES
@@ -51,12 +54,14 @@ export default class TabsPanel extends React.Component {
5154
() => {
5255
this.setState({ tab: TABS.BROADCAST });
5356
changeTab(TABS.BROADCAST);
57+
tracking.event('Click', 'Change Tab', 'Notifications');
5458
}
5559
}
5660
onKeyPress={
5761
() => {
5862
this.setState({ tab: TABS.BROADCAST });
5963
changeTab(TABS.BROADCAST);
64+
tracking.event('Click', 'Change Tab', 'Notifications');
6065
}
6166
}
6267
>NOTIFICATIONS
@@ -72,12 +77,14 @@ export default class TabsPanel extends React.Component {
7277
() => {
7378
this.setState({ tab: TABS.COMPLETED });
7479
changeTab(TABS.COMPLETED);
80+
tracking.event('Click', 'Change Tab', 'Completed Challenges');
7581
}
7682
}
7783
onKeyPress={
7884
() => {
7985
this.setState({ tab: TABS.COMPLETED });
8086
changeTab(TABS.COMPLETED);
87+
tracking.event('Click', 'Change Tab', 'Completed Challenges');
8188
}
8289
}
8390
>COMPLETED CHALLENGES

src/shared/components/Notifications/index.jsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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';
78
import IconArrow from 'assets/images/notifications/arrow.svg';
89
import styles from './style.scss';
910
import TabsPanel from './TabsPanel';
@@ -36,7 +37,13 @@ const Item = ({
3637
<Link
3738
to={`/challenges/${item.sourceId}`}
3839
className={styles['noti-item']}
39-
onClick={() => !item.isRead && markNotificationAsRead(item, auth.tokenV3)}
40+
onClick={() => {
41+
if (!item.isRead) {
42+
markNotificationAsRead(item, auth.tokenV3);
43+
tracking.event('Click', 'Mark Notification As Read', 'Details Page');
44+
}
45+
tracking.event('Click', 'Notification Event', String(item.sourceId));
46+
}}
4047
>
4148
{children}
4249
</Link>
@@ -70,9 +77,11 @@ const Item = ({
7077
e.stopPropagation();
7178
e.nativeEvent.stopImmediatePropagation();
7279
markNotificationAsRead(item, auth.tokenV3);
80+
tracking.event('Click', 'Mark Notification As Read', 'Details Page');
7381
}}
7482
onKeyPress={() => {
7583
markNotificationAsRead(item, auth.tokenV3);
84+
tracking.event('Press Key', 'Mark Notification As Read', 'Details Page');
7685
}}
7786
tabIndex="0"
7887
/>
@@ -110,6 +119,11 @@ export default class NotificationList extends React.Component {
110119
};
111120
}
112121

122+
componentDidMount() {
123+
// Report page view
124+
tracking.pageView();
125+
}
126+
113127
componentWillUnmount() {
114128
// mark all notifications as seen when go to another page
115129
const {
@@ -119,6 +133,7 @@ export default class NotificationList extends React.Component {
119133
const result = _.map(notificationsList, 'id').join('-');
120134
if (result) {
121135
markAllNotificationAsSeen(result, auth.tokenV3);
136+
tracking.event('Auto Action', 'Mark All Notifications As Seen', 'Details Page');
122137
}
123138
}
124139

@@ -152,6 +167,7 @@ export default class NotificationList extends React.Component {
152167
} = this.props;
153168
const { collapsedChallenges, activeTab } = this.state;
154169
let challengesList = [];
170+
155171
if (activeTab === 'active') {
156172
challengesList = _.filter((notifications || []),
157173
t => eventTypes.PROJECT.ACTIVE.includes(t.eventType));
@@ -190,11 +206,13 @@ export default class NotificationList extends React.Component {
190206
onClick={() => {
191207
if (challegeId) {
192208
dismissChallengeNotifications(challegeId, auth.tokenV3);
209+
tracking.event('Click', 'Dismiss Challenge', 'Details Page');
193210
}
194211
}}
195212
onKeyPress={() => {
196213
if (challegeId) {
197214
dismissChallengeNotifications(challegeId, auth.tokenV3);
215+
tracking.event('Click', 'Dismiss Challenge', 'Details Page');
198216
}
199217
}}
200218
>&times;

0 commit comments

Comments
 (0)