From 507133c76e6c78f6d9c2e6e469296bacc52c59c0 Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Mon, 11 Dec 2017 11:07:16 -0600 Subject: [PATCH] Added client side logging (#9643) --- config.json.example | 1 + webpack/config/prod.env.js | 2 +- website/client/index.html | 1 + website/client/libs/logging.js | 9 +++++++++ website/client/main.js | 2 ++ 5 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 website/client/libs/logging.js diff --git a/config.json.example b/config.json.example index c217657c43..f2274ce940 100644 --- a/config.json.example +++ b/config.json.example @@ -71,6 +71,7 @@ }, "IAP_GOOGLE_KEYDIR": "/path/to/google/public/key/dir/", "LOGGLY_TOKEN": "token", + "LOGGLY_CLIENT_TOKEN": "token", "LOGGLY_ACCOUNT": "account", "PUSH_CONFIGS": { "GCM_SERVER_API_KEY": "", diff --git a/webpack/config/prod.env.js b/webpack/config/prod.env.js index 079252b8b8..ca5c502e1d 100644 --- a/webpack/config/prod.env.js +++ b/webpack/config/prod.env.js @@ -34,7 +34,7 @@ let env = { }, }; -'NODE_ENV BASE_URL GA_ID STRIPE_PUB_KEY FACEBOOK_KEY GOOGLE_CLIENT_ID AMPLITUDE_KEY PUSHER:KEY PUSHER:ENABLED' +'NODE_ENV BASE_URL GA_ID STRIPE_PUB_KEY FACEBOOK_KEY GOOGLE_CLIENT_ID AMPLITUDE_KEY PUSHER:KEY PUSHER:ENABLED LOGGLY_CLIENT_TOKEN' .split(' ') .forEach(key => { env[key] = `"${nconf.get(key)}"`; diff --git a/website/client/index.html b/website/client/index.html index 1b2cb7813f..14b019fe4a 100644 --- a/website/client/index.html +++ b/website/client/index.html @@ -20,6 +20,7 @@
+ diff --git a/website/client/libs/logging.js b/website/client/libs/logging.js new file mode 100644 index 0000000000..32b7132a53 --- /dev/null +++ b/website/client/libs/logging.js @@ -0,0 +1,9 @@ +export function setUpLogging () { + let _LTracker = window._LTracker || []; // eslint-disable-line + _LTracker.push({ // eslint-disable-line + logglyKey: process.env.LOGGLY_CLIENT_TOKEN, // eslint-disable-line no-process-env + sendConsoleErrors: true, + tag: 'ClientJS', + json: true, + }); +} diff --git a/website/client/main.js b/website/client/main.js index 6feee90679..4f4c9f24e5 100644 --- a/website/client/main.js +++ b/website/client/main.js @@ -7,6 +7,7 @@ import AppComponent from './app'; import { setup as setupAnalytics, } from 'client/libs/analytics'; +import { setUpLogging } from 'client/libs/logging'; import router from './router'; import getStore from './store'; import StoreModule from './libs/store'; @@ -32,6 +33,7 @@ Vue.use(i18n, {i18nData: window && window['habitica-i18n']}); Vue.use(StoreModule); Vue.use(BootstrapVue); +setUpLogging(); setupAnalytics(); // just create queues for analytics, no scripts loaded at this time const store = getStore();