Report touch input status in rageshakes, analytics

This reports whether the device has touch input as a primary input mechanism in
rageshakes and analytics.

For analytics, this replaces the identity server (which ends up being reported
as "<redacted>" by default anyway) because Matomo only supports a limited number
of custom variables.
pull/21833/head
J. Ryan Stinnett 2020-02-14 17:36:14 +00:00
parent ca4f591cb6
commit ca28f83841
4 changed files with 21 additions and 7 deletions

View File

@ -57,6 +57,8 @@ function getRedactedUrl() {
} }
const customVariables = { const customVariables = {
// The Matomo installation at https://matomo.riot.im is currently configured
// with a limit of 10 custom variables.
'App Platform': { 'App Platform': {
id: 1, id: 1,
expl: _td('The platform you\'re on'), expl: _td('The platform you\'re on'),
@ -92,10 +94,10 @@ const customVariables = {
expl: _td('Your homeserver\'s URL'), expl: _td('Your homeserver\'s URL'),
example: 'https://matrix.org', example: 'https://matrix.org',
}, },
'Identity Server URL': { 'Touch Input': {
id: 8, id: 8,
expl: _td('Your identity server\'s URL'), expl: _td("Whether you're using Riot on a device where touch is the primary input mechanism"),
example: 'https://vector.im', example: 'false',
}, },
'Breadcrumbs': { 'Breadcrumbs': {
id: 9, id: 9,
@ -202,6 +204,13 @@ class Analytics {
} catch (e) { } } catch (e) { }
this._setVisitVariable('Installed PWA', installedPWA); this._setVisitVariable('Installed PWA', installedPWA);
let touchInput = "unknown";
try {
// MDN claims broad support across browsers
touchInput = window.matchMedia('(pointer: coarse)').matches;
} catch (e) { }
this._setVisitVariable('Touch Input', touchInput);
// start heartbeat // start heartbeat
this._heartbeatIntervalID = window.setInterval(this.ping.bind(this), HEARTBEAT_INTERVAL); this._heartbeatIntervalID = window.setInterval(this.ping.bind(this), HEARTBEAT_INTERVAL);
} }
@ -303,11 +312,9 @@ class Analytics {
if (!config.piwik) return; if (!config.piwik) return;
const whitelistedHSUrls = config.piwik.whitelistedHSUrls || []; const whitelistedHSUrls = config.piwik.whitelistedHSUrls || [];
const whitelistedISUrls = config.piwik.whitelistedISUrls || [];
this._setVisitVariable('User Type', isGuest ? 'Guest' : 'Logged In'); this._setVisitVariable('User Type', isGuest ? 'Guest' : 'Logged In');
this._setVisitVariable('Homeserver URL', whitelistRedact(whitelistedHSUrls, homeserverUrl)); this._setVisitVariable('Homeserver URL', whitelistRedact(whitelistedHSUrls, homeserverUrl));
this._setVisitVariable('Identity Server URL', whitelistRedact(whitelistedISUrls, identityServerUrl));
} }
setBreadcrumbs(state) { setBreadcrumbs(state) {

View File

@ -435,7 +435,7 @@ async function _doSetLoggedIn(credentials, clearStorage) {
} }
} }
Analytics.setLoggedIn(credentials.guest, credentials.homeserverUrl, credentials.identityServerUrl); Analytics.setLoggedIn(credentials.guest, credentials.homeserverUrl);
if (localStorage) { if (localStorage) {
try { try {

View File

@ -11,7 +11,7 @@
"Which officially provided instance you are using, if any": "Which officially provided instance you are using, if any", "Which officially provided instance you are using, if any": "Which officially provided instance you are using, if any",
"Whether or not you're using the Richtext mode of the Rich Text Editor": "Whether or not you're using the Richtext mode of the Rich Text Editor", "Whether or not you're using the Richtext mode of the Rich Text Editor": "Whether or not you're using the Richtext mode of the Rich Text Editor",
"Your homeserver's URL": "Your homeserver's URL", "Your homeserver's URL": "Your homeserver's URL",
"Your identity server's URL": "Your identity server's URL", "Whether you're using Riot on a device where touch is the primary input mechanism": "Whether you're using Riot on a device where touch is the primary input mechanism",
"Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)": "Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)", "Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)": "Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)",
"Whether you're using Riot as an installed Progressive Web App": "Whether you're using Riot as an installed Progressive Web App", "Whether you're using Riot as an installed Progressive Web App": "Whether you're using Riot as an installed Progressive Web App",
"e.g. %(exampleValue)s": "e.g. %(exampleValue)s", "e.g. %(exampleValue)s": "e.g. %(exampleValue)s",

View File

@ -73,6 +73,12 @@ export default async function sendBugReport(bugReportEndpoint, opts) {
installedPWA = window.matchMedia('(display-mode: standalone)').matches; installedPWA = window.matchMedia('(display-mode: standalone)').matches;
} catch (e) { } } catch (e) { }
let touchInput = "UNKNOWN";
try {
// MDN claims broad support across browsers
touchInput = window.matchMedia('(pointer: coarse)').matches;
} catch (e) { }
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
console.log("Sending bug report."); console.log("Sending bug report.");
@ -83,6 +89,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) {
body.append('version', version); body.append('version', version);
body.append('user_agent', userAgent); body.append('user_agent', userAgent);
body.append('installed_pwa', installedPWA); body.append('installed_pwa', installedPWA);
body.append('touch_input', touchInput);
if (client) { if (client) {
body.append('user_id', client.credentials.userId); body.append('user_id', client.credentials.userId);