Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Move analytics to a module #454

Merged
merged 1 commit into from Mar 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/login.jsx
Expand Up @@ -4,7 +4,7 @@ var Link = Router.Link;

var config = require('../lib/config');
var TeachAPIClientMixin = require('../mixins/teach-api-client');
var ga = require('../lib/googleanalytics.js');
var ga = require('react-ga');

var Login = React.createClass({
mixins: [TeachAPIClientMixin],
Expand Down
95 changes: 0 additions & 95 deletions lib/googleanalytics.js

This file was deleted.

6 changes: 4 additions & 2 deletions lib/routes.jsx
Expand Up @@ -4,9 +4,10 @@ var Route = Router.Route;
var Link = Router.Link;
var DefaultRoute = Router.DefaultRoute;

var ga = require('./googleanalytics.js');
var ga = require('react-ga');
var Page = require('../components/page.jsx');

var GA_ACCOUNT = process.env.GA_ACCOUNT || 'UA-49796218-20';
var urls = [];

var routes = (
Expand Down Expand Up @@ -50,7 +51,8 @@ exports.generateStatic = function(url, cb) {
};

exports.run = function(location, el) {
ga.initialize();
var options = { debug: false };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually set debug to process.env.NODE_ENV != 'production' here, yay!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, that debug thing is quite verbose. Perhaps we should just add a GA_DEBUG env var, and if it is on then we set that flag to true.

ga.initialize(GA_ACCOUNT, options);
Router.run(routes, location, function(Handler, state) {
ga.pageview(state.pathname);
React.render(<Handler/>, el);
Expand Down
2 changes: 1 addition & 1 deletion lib/teach-api.js
Expand Up @@ -3,7 +3,7 @@ var util = require('util');
var urlResolve = require('url').resolve;
var _ = require('underscore');
var request = require('superagent');
var ga = require('../lib/googleanalytics.js');
var ga = require('react-ga');

var STORAGE_KEY = 'TEACH_API_LOGIN_INFO';

Expand Down
2 changes: 1 addition & 1 deletion mixins/modal-manager.js
@@ -1,5 +1,5 @@
var React = require('react');
var ga = require('../lib/googleanalytics.js');
var ga = require('react-ga');

module.exports = {
contextTypes: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -37,6 +37,7 @@
"react": "^0.12.2",
"react-a11y": "0.0.6",
"react-bootstrap": "^0.13.1",
"react-ga": "^1.0.7",
"react-router": "^0.12.4",
"react-select": "^0.4.2",
"should": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion pages/clubs.jsx
Expand Up @@ -14,7 +14,7 @@ var PageEndCTA = require('../components/page-end-cta.jsx');
var Modal = require('../components/modal.jsx');
var ModalManagerMixin = require('../mixins/modal-manager');
var TeachAPIClientMixin = require('../mixins/teach-api-client');
var ga = require('../lib/googleanalytics.js');
var ga = require('react-ga');

var ClubListItem = React.createClass({
propTypes: {
Expand Down