Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

Google Analyticsを入れる #151

Merged
merged 3 commits into from
Apr 18, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VUE_APP_ACCOUNTS_BASE_URL=http://localhost:3000
VUE_APP_GOOGLE_ANALYTICS_ID=UA-00000000-0
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VUE_APP_ACCOUNTS_BASE_URL=https://accounts.prolab.club
VUE_APP_GOOGLE_ANALYTICS_ID=UA-00000000-0
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ language: node_js
node_js:
- 'stable'

before_install:
- echo $GOOGLE_ANALYTICS_ID > .env.production.local

script:
- npm run build && npm run lint

Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"axios": "^0.18.0",
"rxjs": "^6.4.0",
"vue": "^2.6.10",
"vue-analytics": "^5.16.4",
"vue-meta": "^1.6.0",
"vue-multiselect": "^2.1.4",
"vue-router": "^3.0.5",
Expand Down
7 changes: 7 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import Vue from 'vue';
import Meta from 'vue-meta';
import VueRx from 'vue-rx';
import VueAnalytics from 'vue-analytics';
import App from './App.vue';
import router from './router';
import store from './store';

Vue.config.productionTip = false;
Vue.use(Meta);
Vue.use(VueRx);
Vue.use(
VueAnalytics, {
id: process.env.VUE_APP_GOOGLE_ANALYTICS_ID,
router,
},
);

new Vue({
router,
Expand Down
4 changes: 2 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const router = new Router({
router.beforeEach(async (to, from, next) => {
store.commit('criticalError/clearError');
if (to.matched.length === 0) {
store.commit('criticalError/createError', {
store.dispatch('criticalError/createError', {
response: {
status: 404,
data: {
Expand All @@ -116,7 +116,7 @@ router.beforeEach(async (to, from, next) => {
}

if (to.matched.some(record => record.meta.requiresAdmin) && !store.getters['user/isAdmin']) {
store.commit('criticalError/createError', {
store.dispatch('criticalError/createError', {
response: {
status: 404,
data: {
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/achievement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export default {
},
/* eslint-enable no-param-reassign */
actions: {
async getAchievements({ commit }, sessionID) {
async getAchievements({ commit, dispatch }, sessionID) {
try {
commit('setAchievements', await achievementClient.getAchievements(sessionID));
} catch (e) {
commit('criticalError/createError', e, { root: true });
dispatch('criticalError/createError', e, { root: true });
}
},
async saveAchievement({ commit, dispatch }, { sessionID, achievement, image }) {
Expand Down
31 changes: 23 additions & 8 deletions src/store/modules/criticalError/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { exception } from 'vue-analytics';

export default {
namespaced: true,
state: {
Expand All @@ -6,14 +8,9 @@ export default {
},
/* eslint-disable no-param-reassign */
mutations: {
createError(state, error) {
if (!error.response) {
state.number = '';
state.message = 'Connection refused';
return;
}
state.number = error.response.status;
state.message = error.response.data.message || error.response.statusText;
setError(state, { number, message }) {
state.number = number;
state.message = message;
},
clearError(state) {
state.number = null;
Expand All @@ -26,4 +23,22 @@ export default {
return state.number !== null || state.message !== null;
},
},
actions: {
createError({ commit }, error) {
if (!error.response) {
const number = '';
const message = 'Connection refused';
exception(message);
commit('setError', { number, message });
return;
}

const number = error.response.status;
const message = error.response.data.message || error.response.statusText;
if (number >= 500 && number < 600) {
exception(error);
}
commit('setError', { number, message });
},
},
};
4 changes: 2 additions & 2 deletions src/store/modules/invitation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default {
},
/* eslint-enable no-param-reassign */
actions: {
async listInvitations({ commit }, sessionID) {
async listInvitations({ commit, dispatch }, sessionID) {
try {
commit('setInvitations', await invitationClient.listInvitations(sessionID));
} catch (e) {
commit('criticalError/createError', e, { root: true });
dispatch('criticalError/createError', e, { root: true });
}
},
async invite({ commit, dispatch }, { sessionID, rawEmails }) {
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ export default {
}
},

async logout({ commit }, sessionID) {
async logout({ commit, dispatch }, sessionID) {
try {
await sessionClient.deleteSession(sessionID);
commit('clearSessionID');
} catch (e) {
commit('criticalError/createError', e);
dispatch('criticalError/createError', e);
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/views/ConfirmEmail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</template>

<script>
import { mapMutations, mapActions, mapState } from 'vuex';
import { mapActions, mapState } from 'vuex';

export default {
name: 'confirmEmail',
Expand All @@ -37,7 +37,7 @@ export default {
}
},
methods: {
...mapMutations('criticalError', [
...mapActions('criticalError', [
'createError',
]),
...mapActions('emailConfirmations', [
Expand Down
4 changes: 2 additions & 2 deletions src/views/Registration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</template>

<script>
import { mapMutations, mapActions, mapState } from 'vuex';
import { mapActions, mapState } from 'vuex';
import ErrorMessage from '@/components/ErrorMessage.vue';

export default {
Expand Down Expand Up @@ -81,7 +81,7 @@ export default {
}
},
methods: {
...mapMutations('criticalError', [
...mapActions('criticalError', [
'createError',
]),
...mapActions('user', [
Expand Down
4 changes: 2 additions & 2 deletions src/views/memberIntroduction/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ dd.small {
</style>

<script>
import { mapMutations, mapActions, mapState } from 'vuex';
import { mapActions, mapState } from 'vuex';
import utils from '@/utils';

const { IdToURLHelper } = utils;
Expand Down Expand Up @@ -110,7 +110,7 @@ export default {
}
},
methods: {
...mapMutations('criticalError', [
...mapActions('criticalError', [
'createError',
]),
...mapActions('memberIntroduction/memberProfile', [
Expand Down