Merge pull request #1046 from matrix-org/t3chguy/piwik_fixes_1

Various Analytics changes/fixes/improvements
pull/21833/head
David Baker 2017-06-07 17:17:47 +01:00 committed by GitHub
commit bfa095184d
1 changed files with 8 additions and 2 deletions

View File

@ -20,9 +20,9 @@ import PlatformPeg from './PlatformPeg';
import SdkConfig from './SdkConfig';
function getRedactedUrl() {
const base = window.location.pathname.split('/').slice(-2).join('/');
const redactedHash = window.location.hash.replace(/#\/(room|user)\/(.+)/, "#/$1/<redacted>");
return base + redactedHash;
// hardcoded url to make piwik happy
return 'https://riot.im/app/' + redactedHash;
}
const customVariables = {
@ -30,6 +30,7 @@ const customVariables = {
'App Version': 2,
'User Type': 3,
'Chosen Language': 4,
'Instance': 5,
};
@ -55,6 +56,7 @@ class Analytics {
* but this is second best, Piwik should not pull anything implicitly.
*/
disable() {
this.trackEvent('Analytics', 'opt-out');
this.disabled = true;
}
@ -86,6 +88,10 @@ class Analytics {
this._setVisitVariable('Chosen Language', getCurrentLanguage());
if (window.location.hostname === 'riot.im') {
this._setVisitVariable('Instance', window.location.pathname);
}
(function() {
const g = document.createElement('script');
const s = document.getElementsByTagName('script')[0];