Skip to content

Commit

Permalink
Merge pull request #433 from Kitware/google-analytics
Browse files Browse the repository at this point in the history
Add Google analytics infrastructure to Resonant Lab build
  • Loading branch information
Roni Choudhury committed Oct 10, 2016
2 parents 4d5e562 + 949cdd0 commit 462f868
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/resonantlab/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ web_client/lib/
*.pdf
.vagrant
ansible/playbook*.retry
ga.js
6 changes: 5 additions & 1 deletion app/resonantlab/ansible/playbook-trusty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

girder_revision: 12e12f17a7a8ec99330c16234e19a14435b1a034
database_assetstore_revision: a530c9546d3ac4f50ec4519ef6c7bb348e2b4bc7
candela_revision: e1988c2391cf3da9b54812149976bf1b2629cac3
candela_revision: f823873ab1c11feba09779f82fcb4325b72d33ff
girder_client_revision: 6bda1a7b65bea1c11187cdeb136877739693f466

google_analytics_key: ""

tasks:
- name: Add Mongo repository key
become: yes
Expand Down Expand Up @@ -126,6 +128,8 @@
command: ./node_modules/.bin/grunt
args:
chdir: "{{ storage }}/girder"
environment:
GOOGLE_ANALYTICS_KEY: "{{ google_analytics_key }}"

- name: Start MongoDB
service:
Expand Down
7 changes: 7 additions & 0 deletions app/resonantlab/gaTemplate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', '${GOOGLE_ANALYTICS_KEY}', 'auto');
ga('send', 'pageview');
17 changes: 16 additions & 1 deletion app/resonantlab/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
var fs = require('fs');
var webpack = require('webpack');
var GruntWatchPlugin = require('./grunt-watch-plugin.js');

var entry = ['./mainPage.js'];

var gaKey = process.env.GOOGLE_ANALYTICS_KEY;
if (gaKey) {
var gaTemplate = fs.readFileSync('gaTemplate.js', {
encoding: 'utf-8'
});

var gaText = gaTemplate.replace('${GOOGLE_ANALYTICS_KEY}', gaKey);
fs.writeFileSync('ga.js', gaText);

entry.push('./ga.js');
}

/*globals module*/
module.exports = {
entry: './mainPage.js',
entry: entry,
output: {
path: 'web_client/lib',
filename: 'webpack_bundle.js'
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"ignore": [
"config",
"src/external",
"app/resonantlab/gaTemplate.js",
"app/resonantlab/ga.js",
"app/resonantlab/web_client/lib",
"dist",
"built",
Expand Down

0 comments on commit 462f868

Please sign in to comment.