Vue analytics and bug fixes

This commit is contained in:
Roman Cervantes 2018-11-04 19:28:29 -07:00
parent b2654d4bf0
commit f1790de781
11 changed files with 54 additions and 20 deletions

View file

@ -4,13 +4,14 @@ const axios = require('axios');
axios.defaults.headers.common['user-key'] = functions.config().igdb.key;
const igdbUrl = 'https://api-endpoint.igdb.com';
const igdbFields = 'id,name,slug,created_at,updated_at,summary,rating,category,player_perspectives,release_dates,name,cover,platforms,screenshots,videos,websites,esrb,pegi,themes.name,game.name&expand=game,themes,developers,publishers,game_engines,game_modes,genres,platforms,player_perspectives';
exports.search = functions.https.onRequest((req, res) => {
res.set('Access-Control-Allow-Origin', "*")
const { searchText, platformId } = req.query;
axios.get(`${igdbUrl}/games/?search=${searchText}&fields=id,name,slug,created_at,updated_at,summary,rating,category,player_perspectives,release_dates,name,cover,platforms,screenshots,videos,websites,esrb,pegi,themes.name,game.name&expand=game,themes,developers,publishers,game_engines,game_modes,genres,platforms,player_perspectives&filter[platforms][eq]=${platformId}&limit=20&order=popularity:desc`)
axios.get(`${igdbUrl}/games/?search=${searchText}&fields=${igdbFields}&filter[platforms][eq]=${platformId}&limit=20&order=popularity:desc`)
.then(({ data }) => { res.status(200).send(data) })
.catch(() => { res.send(400) });
});
@ -20,7 +21,7 @@ exports.games = functions.https.onRequest((req, res) => {
const { games, platformId } = req.query;
axios.get(`${igdbUrl}/games/${games}/?fields=id,name,slug,created_at,updated_at,summary,rating,category,player_perspectives,release_dates,name,cover,platforms,screenshots,videos,websites,esrb,pegi,themes.name,game.name&expand=game,themes,developers,publishers,game_engines,game_modes,genres,platforms,player_perspectives`)
axios.get(`${igdbUrl}/games/${games}/?fields=${igdbFields}`)
.then(({ data }) => { res.status(200).send(data) })
.catch(() => { res.send(400) });
});

View file

@ -1,16 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-120053966-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-120053966-1');
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
@ -32,8 +22,7 @@
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="static/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<title>GAMEBRARY</title>
<title>Gamebrary</title>
</head>
<body>
<div id="app" />

View file

@ -28,6 +28,7 @@
"sw-precache-webpack-plugin": "^0.11.5",
"v-tooltip": "^2.0.0-rc.33",
"vue": "^2.5.2",
"vue-analytics": "^5.16.0",
"vue-axios": "^2.1.1",
"vue-content-placeholders": "^0.2.1",
"vue-dragscroll": "^1.5.0",

View file

@ -10,9 +10,20 @@
<script>
import NavHeader from '@/components/NavHeader/NavHeader';
import firebase from 'firebase';
import firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/firestore';
import { mapState } from 'vuex';
firebase.initializeApp({
apiKey: 'AIzaSyA6MsmnLtqT4b11r-j15wwreRypO3AodcA',
authDomain: 'gamebrary.com',
databaseURL: 'https://gamebrary-8c736.firebaseio.com',
projectId: 'gamebrary-8c736',
storageBucket: 'gamebrary-8c736.appspot.com',
messagingSenderId: '324529217902',
});
const db = firebase.firestore();
db.settings({

View file

@ -78,7 +78,8 @@ import ListNameEdit from '@/components/GameBoard/ListNameEdit';
import GameCard from '@/components/GameCard/GameCard';
import GameSearch from '@/components/GameSearch/GameSearch';
import { mapState } from 'vuex';
import firebase from 'firebase';
import firebase from 'firebase/app';
import 'firebase/firestore';
import toasts from '@/mixins/toasts';
const db = firebase.firestore();

View file

@ -55,8 +55,9 @@
<script>
import GameRating from '@/components/GameDetail/GameRating';
import { mapState } from 'vuex';
import firebase from 'firebase';
import toasts from '@/mixins/toasts';
import firebase from 'firebase/app';
import 'firebase/firestore';
const db = firebase.firestore();
@ -111,6 +112,13 @@ export default {
this.$emit('added');
this.$store.commit('ADD_GAME', data);
this.$ga.event({
eventCategory: 'game',
eventAction: 'add',
eventLabel: 'addGame',
eventValue: data,
});
db.collection('lists').doc(this.user.uid).set(this.gameLists, { merge: true })
.then(() => {
this.$success('List saved');

View file

@ -96,6 +96,14 @@ export default {
addList() {
this.$store.commit('ADD_LIST', this.newListName);
this.$ga.event({
eventCategory: 'list',
eventAction: 'add',
eventLabel: 'listAdded',
eventValue: this.newListName,
});
this.$emit('update');
this.$emit('scroll');
this.reset();

View file

@ -1,5 +1,5 @@
<template lang="html">
<nav :style="navStyle" :class="{ dark: settings.nightMode }" v-if="user">
<nav :style="navStyle" :class="{ dark: settings && settings.nightMode }" v-if="user">
<router-link
:to="{ name: 'platforms' }"
tag="button"

View file

@ -7,8 +7,7 @@ import VueFire from 'vuefire';
import VueI18n from 'vue-i18n';
import VueSweetalert2 from 'vue-sweetalert2';
import axios from 'axios';
import '@/shared/firebase';
import VueAnalytics from 'vue-analytics';
import App from './App';
import messages from './i18n';
import router from './router';
@ -30,6 +29,11 @@ Object.defineProperties(Vue.prototype, {
},
});
Vue.use(VueAnalytics, {
id: 'UA-120053966-1',
router,
});
Vue.use(VTooltip);
Vue.use(VueAxios, axios);
Vue.use(VueContentPlaceholders);

View file

@ -66,6 +66,13 @@ export default {
mounted() {
this.$store.commit('SET_ACTIVE_GAME', this.$route.params.id);
document.title = `${this.platform.name} - ${this.game.name} - Gamebrary`;
this.$ga.event({
eventCategory: 'game',
eventAction: 'view',
eventLabel: 'gameViewed',
eventValue: `${this.platform.name} - ${this.game.name}`,
});
},
destroyed() {

View file

@ -9158,6 +9158,10 @@ void-elements@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec"
vue-analytics@^5.16.0:
version "5.16.0"
resolved "https://registry.yarnpkg.com/vue-analytics/-/vue-analytics-5.16.0.tgz#82e88703a0678cba076d51acacd6569bc8f7d54c"
vue-axios@^2.1.1:
version "2.1.4"
resolved "https://registry.yarnpkg.com/vue-axios/-/vue-axios-2.1.4.tgz#a9d298f7e876f9a87feb336b37adcbce34ff9f9f"