initial piwik stuff

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-05-27 20:39:52 +01:00
parent 09adfbd6d6
commit 61a67c52c5
2 changed files with 31 additions and 8 deletions

View File

@ -22,6 +22,7 @@ import sdk from 'matrix-react-sdk';
import Matrix from "matrix-js-sdk";
import dis from 'matrix-react-sdk/lib/dispatcher';
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
import Analytics from 'matrix-react-sdk/lib/Analytics';
import rate_limited_func from 'matrix-react-sdk/lib/ratelimitedfunc';
import Modal from 'matrix-react-sdk/lib/Modal';
import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton';
@ -61,24 +62,26 @@ module.exports = React.createClass({
return {
phase: this.Phase.MemberInfo,
member: member,
}
}
else {
};
} else {
return {
phase: this.Phase.MemberList
}
};
}
},
onMemberListButtonClick: function() {
Analytics.trackEvent('RightPanel', 'memberListButtonClick');
this.setState({ phase: this.Phase.MemberList });
},
onFileListButtonClick: function() {
Analytics.trackEvent('RightPanel', 'fileListButtonClick');
this.setState({ phase: this.Phase.FilePanel });
},
onNotificationListButtonClick: function() {
Analytics.trackEvent('RightPanel', 'notificationListButtonClick');
this.setState({ phase: this.Phase.NotificationPanel });
},

View File

@ -56,7 +56,8 @@ if (process.env.NODE_ENV !== 'production') {
var RunModernizrTests = require("./modernizr"); // this side-effects a global
var ReactDOM = require("react-dom");
var sdk = require("matrix-react-sdk");
var PlatformPeg = require("matrix-react-sdk/lib/PlatformPeg");
const PlatformPeg = require("matrix-react-sdk/lib/PlatformPeg");
const Analytics = require("matrix-react-sdk/lib/Analytics");
sdk.loadSkin(require('../component-index'));
var VectorConferenceHandler = require('../VectorConferenceHandler');
var UpdateChecker = require("./updater");
@ -143,7 +144,7 @@ var onNewScreen = function(screen) {
var hash = '#/' + screen;
lastLocationHashSet = hash;
window.location.hash = hash;
}
};
// We use this to work out what URL the SDK should
// pass through when registering to allow the user to
@ -279,6 +280,26 @@ async function loadApp() {
} else if (validBrowser) {
UpdateChecker.start();
let doNotTrack = navigator.doNotTrack;
if (typeof navigator.doNotTrack === 'string') {
doNotTrack = navigator.doNotTrack === 'yes';
}
if (!doNotTrack && configJson.piwik && configJson.piwik.url && configJson.piwik.siteId) {
(function() {
const g = document.createElement('script');
const s = document.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=configJson.piwik.url+'piwik.js';
g.onload = function() {
const tracker = window.Piwik.getTracker(configJson.piwik.url+'piwik.php', configJson.piwik.siteId);
console.log('Initialised anonymous analytics');
Analytics.set(tracker);
};
s.parentNode.insertBefore(g, s);
})();
}
const MatrixChat = sdk.getComponent('structures.MatrixChat');
window.matrixChat = ReactDOM.render(
<MatrixChat
@ -295,8 +316,7 @@ async function loadApp() {
/>,
document.getElementById('matrixchat')
);
}
else {
} else {
console.error("Browser is missing required features.");
// take to a different landing page to AWOOOOOGA at the user
var CompatibilityPage = sdk.getComponent("structures.CompatibilityPage");