Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
paths:
- node_modules
- run: npm test
- run: npm run build
- run: npm run build --tag=test=release
- persist_to_workspace:
root: .
paths:
Expand All @@ -28,6 +28,7 @@ jobs:
- attach_workspace:
at: .
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run: npm install
- run: npm publish
# dont change anything
workflows:
Expand Down
6 changes: 6 additions & 0 deletions __tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,11 @@ Object {
"delay": [Function],
"formatDuration": [Function],
},
"tracking": Object {
"default": undefined,
"event": [Function],
"init": [Function],
"pageView": [Function],
},
}
`;
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "",
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "",
"PAGE_SIZE": 50,
"REVIEW_OPPORTUNITY_PAGE_SIZE": 1000
"REVIEW_OPPORTUNITY_PAGE_SIZE": 1000,
"GOOGLE_ANALYTICS_ID": ""
}
3 changes: 2 additions & 1 deletion config/development.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "68c5a381-c8ab-48af-92a7-7a869a4ee6c3",
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "52c91e85-745f-4e62-b592-9879a2dfe9fd"
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "52c91e85-745f-4e62-b592-9879a2dfe9fd",
"GOOGLE_ANALYTICS_ID": "UA-161803421-1"
}
3 changes: 2 additions & 1 deletion config/production.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"AV_SCAN_SCORER_REVIEW_TYPE_ID": "55bbb17d-aac2-45a6-89c3-a8d102863d05",
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "df51ca7d-fb0a-4147-9569-992fcf5aae48"
"PROVISIONAL_SCORING_COMPLETED_REVIEW_TYPE_ID": "df51ca7d-fb0a-4147-9569-992fcf5aae48",
"GOOGLE_ANALYTICS_ID": "UA-6340959-1"
}
1 change: 1 addition & 0 deletions config/webpack/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
'moment-duration-format',
'react',
'react-dom',
'react-ga',
'redux',
'redux-actions',
'isomorphic-fetch',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"url": "git+https://github.com/topcoder-platform/topcoder-react-lib.git"
},
"scripts": {
"prepare": "npm run build",
"build": "npm run clean && npm run build:dev && npm run build:prod",
"build:dev": "./node_modules/.bin/webpack --env=development --progress --profile --colors --display-optimization-bailout",
"build:dev:watch": "npm run clean && ./node_modules/.bin/webpack --env=development --progress --profile --colors --watch --display-optimization-bailout",
Expand All @@ -31,7 +32,7 @@
"lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .",
"test": "npm run lint && npm run jest"
},
"version": "0.15.0",
"version": "1000.13.3",
"dependencies": {
"auth0-js": "^6.8.4",
"config": "^3.2.0",
Expand All @@ -44,6 +45,7 @@
"qs": "^6.5.2",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-ga": "^2.7.0",
"react-redux": "^6.0.1",
"redux": "^3.7.2",
"redux-actions": "^2.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export { actions } from './actions';
export { services } from './services';

export {
challenge, logger, errors, tc, time, mock, submission,
challenge, logger, errors, tc, time, mock, submission, tracking,
} from './utils';
2 changes: 2 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as mock from './mock';
import * as errors from './errors';
import * as filter from './challenge/filter';
import * as submission from './submission';
import * as tracking from './tracking';

const challenge = {
filter,
Expand All @@ -21,4 +22,5 @@ export {
mock,
errors,
submission,
tracking,
};
47 changes: 47 additions & 0 deletions src/utils/tracking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* global window */
/* global CONFIG */

import ReactGA from 'react-ga';

const { GOOGLE_ANALYTICS_ID } = CONFIG;
const TRACKING_NAME = 'tracking';

/**
* init - Init Google Analytics tracking
* @param {string} userId
*/
export const init = (userId) => {
ReactGA.initialize([{
trackingId: GOOGLE_ANALYTICS_ID,
gaOptions: {
name: TRACKING_NAME,
userId,
},
}], {
alwaysSendToDefaultTracker: false,
});
};

/**
* pageView - Track page view
*/
export const pageView = () => {
ReactGA.pageview(window.location.pathname
+ window.location.search, [TRACKING_NAME]);
};

/**
* event - Add custom tracking event.
* @param {string} category
* @param {string} action
* @param {string} label
*/
export const event = (category, action, label) => {
ReactGA.event({
category,
action,
label,
}, [TRACKING_NAME]);
};

export default undefined;