Skip to content

Commit b01a6bc

Browse files
authored
Merge pull request #157 from topcoder-platform/notifications-analytics
Fix CircleCI: Added 'npm install' to release job
2 parents de55694 + 74e49d6 commit b01a6bc

File tree

10 files changed

+68
-6
lines changed

10 files changed

+68
-6
lines changed

.circleci/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
paths:
1717
- node_modules
1818
- run: npm test
19-
- run: npm run build
19+
- run: npm run build --tag=test=release
2020
- persist_to_workspace:
2121
root: .
2222
paths:
@@ -28,6 +28,7 @@ jobs:
2828
- attach_workspace:
2929
at: .
3030
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
31+
- run: npm install
3132
- run: npm publish
3233
# dont change anything
3334
workflows:

__tests__/__snapshots__/index.js.snap

+6
Original file line numberDiff line numberDiff line change
@@ -387,5 +387,11 @@ Object {
387387
"delay": [Function],
388388
"formatDuration": [Function],
389389
},
390+
"tracking": Object {
391+
"default": undefined,
392+
"event": [Function],
393+
"init": [Function],
394+
"pageView": [Function],
395+
},
390396
}
391397
`;

config/default.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "",
33
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "",
44
"PAGE_SIZE": 50,
5-
"REVIEW_OPPORTUNITY_PAGE_SIZE": 1000
5+
"REVIEW_OPPORTUNITY_PAGE_SIZE": 1000,
6+
"GOOGLE_ANALYTICS_ID": ""
67
}

config/development.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "68c5a381-c8ab-48af-92a7-7a869a4ee6c3",
3-
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "52c91e85-745f-4e62-b592-9879a2dfe9fd"
3+
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "52c91e85-745f-4e62-b592-9879a2dfe9fd",
4+
"GOOGLE_ANALYTICS_ID": "UA-161803421-1"
45
}

config/production.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "55bbb17d-aac2-45a6-89c3-a8d102863d05",
3-
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "df51ca7d-fb0a-4147-9569-992fcf5aae48"
3+
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "df51ca7d-fb0a-4147-9569-992fcf5aae48",
4+
"GOOGLE_ANALYTICS_ID": "UA-6340959-1"
45
}

config/webpack/default.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
'moment-duration-format',
2020
'react',
2121
'react-dom',
22+
'react-ga',
2223
'redux',
2324
'redux-actions',
2425
'isomorphic-fetch',

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"url": "git+https://github.com/topcoder-platform/topcoder-react-lib.git"
2222
},
2323
"scripts": {
24+
"prepare": "npm run build",
2425
"build": "npm run clean && npm run build:dev && npm run build:prod",
2526
"build:dev": "./node_modules/.bin/webpack --env=development --progress --profile --colors --display-optimization-bailout",
2627
"build:dev:watch": "npm run clean && ./node_modules/.bin/webpack --env=development --progress --profile --colors --watch --display-optimization-bailout",
@@ -31,7 +32,7 @@
3132
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
3233
"test": "npm run lint && npm run jest"
3334
},
34-
"version": "0.15.0",
35+
"version": "1000.13.3",
3536
"dependencies": {
3637
"auth0-js": "^6.8.4",
3738
"config": "^3.2.0",
@@ -44,6 +45,7 @@
4445
"qs": "^6.5.2",
4546
"react": "^16.4.1",
4647
"react-dom": "^16.4.1",
48+
"react-ga": "^2.7.0",
4749
"react-redux": "^6.0.1",
4850
"redux": "^3.7.2",
4951
"redux-actions": "^2.4.0",

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export { actions } from './actions';
1212
export { services } from './services';
1313

1414
export {
15-
challenge, logger, errors, tc, time, mock, submission,
15+
challenge, logger, errors, tc, time, mock, submission, tracking,
1616
} from './utils';

src/utils/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as mock from './mock';
88
import * as errors from './errors';
99
import * as filter from './challenge/filter';
1010
import * as submission from './submission';
11+
import * as tracking from './tracking';
1112

1213
const challenge = {
1314
filter,
@@ -21,4 +22,5 @@ export {
2122
mock,
2223
errors,
2324
submission,
25+
tracking,
2426
};

src/utils/tracking.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* global window */
2+
/* global CONFIG */
3+
4+
import ReactGA from 'react-ga';
5+
6+
const { GOOGLE_ANALYTICS_ID } = CONFIG;
7+
const TRACKING_NAME = 'tracking';
8+
9+
/**
10+
* init - Init Google Analytics tracking
11+
* @param {string} userId
12+
*/
13+
export const init = (userId) => {
14+
ReactGA.initialize([{
15+
trackingId: GOOGLE_ANALYTICS_ID,
16+
gaOptions: {
17+
name: TRACKING_NAME,
18+
userId,
19+
},
20+
}], {
21+
alwaysSendToDefaultTracker: false,
22+
});
23+
};
24+
25+
/**
26+
* pageView - Track page view
27+
*/
28+
export const pageView = () => {
29+
ReactGA.pageview(window.location.pathname
30+
+ window.location.search, [TRACKING_NAME]);
31+
};
32+
33+
/**
34+
* event - Add custom tracking event.
35+
* @param {string} category
36+
* @param {string} action
37+
* @param {string} label
38+
*/
39+
export const event = (category, action, label) => {
40+
ReactGA.event({
41+
category,
42+
action,
43+
label,
44+
}, [TRACKING_NAME]);
45+
};
46+
47+
export default undefined;

0 commit comments

Comments
 (0)