Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #296 from multinet-app/waxlamp/google-analytics
Browse files Browse the repository at this point in the history
Add Google Analytics infrastructure
  • Loading branch information
waxlamp committed Feb 4, 2020
2 parents 235c36e + c0d2a9c commit 5bde2bb
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ yarn-error.log*

# Deployment files
git-sha
ga-tag
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"material-design-icons-iconfont": "^5.0.1",
"multinet": "0.7.0",
"vue": "^2.6.10",
"vue-gtag": "^1.2.1",
"vue-router": "^3.0.2",
"vuetify": "^2.1.5"
},
Expand Down
1 change: 1 addition & 0 deletions client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Vue from 'vue';
import App from './App.vue';
import vuetify from './vuetify';
import router from './router';
import './vuegtag';

Vue.config.productionTip = false;

Expand Down
14 changes: 14 additions & 0 deletions client/src/vuegtag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Vue from 'vue';
import VueGtag from 'vue-gtag';

import router from '@/router';

declare const GA_TAG: string;

if (GA_TAG) {
Vue.use(VueGtag, {
config: {
id: GA_TAG,
},
}, router);
}
18 changes: 14 additions & 4 deletions client/vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,33 @@ const webpack = require('webpack');

const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');

function fileToJsonString(filename) {
let result = null;
if (fs.existsSync(filename)) {
result = JSON.stringify(fs.readFileSync(filename).toString().trim());
}

return result;
}

// Read in .env file.
const env = dotenv.parse(fs.readFileSync(path.resolve('..', '.env')));
process.env.FLASK_SERVE_PORT = process.env.FLASK_SERVE_PORT || env.FLASK_SERVE_PORT || 5000;

// Look for a git-sha file; if found, inject the value found in it into the
// application.
let GIT_SHA = null;
if (fs.existsSync('git-sha')) {
GIT_SHA = JSON.stringify(fs.readFileSync('git-sha').toString().trim());
}
const GIT_SHA = fileToJsonString('git-sha');

// Inject a value for gaTag (google analytics) if present as well.
const GA_TAG = fileToJsonString('ga-tag');

module.exports = {
configureWebpack: {
plugins: [
new VuetifyLoaderPlugin(),
new webpack.DefinePlugin({
GIT_SHA,
GA_TAG,
}),
],
},
Expand Down
5 changes: 5 additions & 0 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8551,6 +8551,11 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==

vue-gtag@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/vue-gtag/-/vue-gtag-1.2.1.tgz#3291d451455395ef3a2c7e37d2d504ee0c343605"
integrity sha512-Qz7pr+7oAoqDOhAz7l/sPVQByHhPOptaIuK5T+nhl3PqC+ewzPFsGQvBGjwgHxYN/k1iQMX0ZbZcyCbgusZ4rg==

vue-hot-reload-api@^2.3.0:
version "2.3.4"
resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz#532955cc1eb208a3d990b3a9f9a70574657e08f2"
Expand Down

0 comments on commit 5bde2bb

Please sign in to comment.