From 9abb2df5b296d36da22d895d4dfd490015035d7a Mon Sep 17 00:00:00 2001 From: Robert Raposa Date: Fri, 1 Mar 2019 14:52:35 -0500 Subject: [PATCH] Refactor analytics code into folder. --- .eslintignore | 2 +- config/webpack.common.config.js | 2 +- config/webpack.dev.config.js | 2 +- src/{ => analytics}/analytics.js | 4 ++-- src/{ => analytics}/segment.js | 2 +- src/components/App.jsx | 2 +- src/components/ProfilePage.jsx | 2 +- src/components/ProfilePage.test.jsx | 2 +- src/index.jsx | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) rename src/{ => analytics}/analytics.js (91%) rename src/{ => analytics}/segment.js (98%) diff --git a/.eslintignore b/.eslintignore index 65588a7..7194296 100755 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ coverage/* dist/ node_modules/ -src/segment.js +src/analytics/segment.js diff --git a/config/webpack.common.config.js b/config/webpack.common.config.js index 4a19aa6..72abff5 100755 --- a/config/webpack.common.config.js +++ b/config/webpack.common.config.js @@ -4,7 +4,7 @@ const path = require('path'); module.exports = { entry: { - segment: path.resolve(__dirname, '../src/segment.js'), + segment: path.resolve(__dirname, '../src/analytics/segment.js'), app: path.resolve(__dirname, '../src/index.jsx'), }, output: { diff --git a/config/webpack.dev.config.js b/config/webpack.dev.config.js index a51870b..80a08ce 100755 --- a/config/webpack.dev.config.js +++ b/config/webpack.dev.config.js @@ -13,7 +13,7 @@ module.exports = Merge.smart(commonConfig, { entry: [ // enable react's custom hot dev client so we get errors reported in the browser require.resolve('react-dev-utils/webpackHotDevClient'), - path.resolve(__dirname, '../src/segment.js'), + path.resolve(__dirname, '../src/analytics/segment.js'), path.resolve(__dirname, '../src/index.jsx'), ], module: { diff --git a/src/analytics.js b/src/analytics/analytics.js similarity index 91% rename from src/analytics.js rename to src/analytics/analytics.js index f987044..43cde4f 100755 --- a/src/analytics.js +++ b/src/analytics/analytics.js @@ -1,6 +1,6 @@ import snakecaseKeys from 'snakecase-keys'; -import apiClient from './config/apiClient'; -import { configuration } from './config/environment'; +import apiClient from '../config/apiClient'; +import { configuration } from '../config/environment'; const eventLogApiBaseUrl = `${configuration.LMS_BASE_URL}/event`; diff --git a/src/segment.js b/src/analytics/segment.js similarity index 98% rename from src/segment.js rename to src/analytics/segment.js index 963ae71..fd42f02 100644 --- a/src/segment.js +++ b/src/analytics/segment.js @@ -1,7 +1,7 @@ // The code in this file is from Segment's website, with the following update: // - Pulls the segment key from configuration. // https://segment.com/docs/sources/website/analytics.js/quickstart/ -import { configuration } from './config/environment'; +import { configuration } from '../config/environment'; (function(){ diff --git a/src/components/App.jsx b/src/components/App.jsx index fe307cf..04af70e 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -8,7 +8,7 @@ import SiteFooter from '@edx/frontend-component-footer'; import { fetchUserAccount, UserAccountApiService } from '@edx/frontend-auth'; import apiClient from '../config/apiClient'; -import { handleTrackEvents } from '../analytics'; +import { handleTrackEvents } from '../analytics/analytics'; import { getLocale, getMessages } from '../i18n/i18n-loader'; import SiteHeader from './/SiteHeader'; import ConnectedProfilePage from './ProfilePage'; diff --git a/src/components/ProfilePage.jsx b/src/components/ProfilePage.jsx index 1f5c998..79bafec 100644 --- a/src/components/ProfilePage.jsx +++ b/src/components/ProfilePage.jsx @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Container, Row, Col } from 'reactstrap'; import { connect } from 'react-redux'; -import { logEvent } from '../analytics'; +import { logEvent } from '../analytics/analytics'; // Actions import { diff --git a/src/components/ProfilePage.test.jsx b/src/components/ProfilePage.test.jsx index 16283ed..c7ed1bf 100644 --- a/src/components/ProfilePage.test.jsx +++ b/src/components/ProfilePage.test.jsx @@ -4,7 +4,7 @@ import { Provider } from 'react-redux'; import configureMockStore from 'redux-mock-store'; import { IntlProvider } from 'react-intl'; -import * as analytics from '../analytics'; +import * as analytics from '../analytics/analytics'; import ConnectedProfilePage from './ProfilePage'; import { initialState as initialProfilePageState } from '../reducers/ProfilePageReducer'; diff --git a/src/index.jsx b/src/index.jsx index 8bef45b..93e192f 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -5,7 +5,7 @@ import ReactDOM from 'react-dom'; import configureStore from './config/configureStore'; import apiClient from './config/apiClient'; -import { identifyUser } from './analytics'; +import { identifyUser } from './analytics/analytics'; import './index.scss';