From 5da62c6ad9db044d0e7c4de555239005719c8718 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 26 Apr 2018 15:18:29 +0100 Subject: [PATCH] Fix bug that caused crash when analytics HS/IS whitelists not specified --- src/Analytics.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Analytics.js b/src/Analytics.js index d48372afd7..8b55bdfd64 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -190,6 +190,7 @@ class Analytics { } _setVisitVariable(key, value) { + if (this.disabled) return; this._paq.push(['setCustomVariable', customVariables[key].id, key, value, 'visit']); } @@ -199,8 +200,8 @@ class Analytics { const config = SdkConfig.get(); if (!config.piwik) return; - const whitelistedHSUrls = config.piwik.whitelistedHSUrls; - const whitelistedISUrls = config.piwik.whitelistedISUrls; + const whitelistedHSUrls = config.piwik.whitelistedHSUrls || []; + const whitelistedISUrls = config.piwik.whitelistedISUrls || []; this._setVisitVariable('User Type', isGuest ? 'Guest' : 'Logged In'); this._setVisitVariable('Homeserver URL', whitelistRedact(whitelistedHSUrls, homeserverUrl));