From ca4f591cb6079ae3f69f8c500442153d96e782f8 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 14 Feb 2020 14:58:37 +0000 Subject: [PATCH 1/2] Report installed PWA status in rageshakes, analytics This adds installed PWA status reporting to rageshakes and analytics, as well as cleaning up some related strings. --- src/Analytics.js | 28 ++++++++++++++++++++-------- src/i18n/strings/en_EN.json | 9 +++++---- src/rageshake/submit-rageshake.js | 7 +++++++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/Analytics.js b/src/Analytics.js index 39731a0e7d..9f540e46b3 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -64,7 +64,7 @@ const customVariables = { }, 'App Version': { id: 2, - expl: _td('The version of Riot.im'), + expl: _td('The version of Riot'), example: '15.0.0', }, 'User Type': { @@ -87,11 +87,6 @@ const customVariables = { expl: _td('Whether or not you\'re using the Richtext mode of the Rich Text Editor'), example: 'off', }, - 'Breadcrumbs': { - id: 9, - expl: _td("Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)"), - example: 'disabled', - }, 'Homeserver URL': { id: 7, expl: _td('Your homeserver\'s URL'), @@ -102,6 +97,16 @@ const customVariables = { expl: _td('Your identity server\'s URL'), example: 'https://vector.im', }, + 'Breadcrumbs': { + id: 9, + expl: _td("Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)"), + example: 'disabled', + }, + 'Installed PWA': { + id: 10, + expl: _td("Whether you're using Riot as an installed Progressive Web App"), + example: 'false', + }, }; function whitelistRedact(whitelist, str) { @@ -190,6 +195,13 @@ class Analytics { this._setVisitVariable('Instance', window.location.pathname); } + let installedPWA = "unknown"; + try { + // Known to work at least for desktop Chrome + installedPWA = window.matchMedia('(display-mode: standalone)').matches; + } catch (e) { } + this._setVisitVariable('Installed PWA', installedPWA); + // start heartbeat this._heartbeatIntervalID = window.setInterval(this.ping.bind(this), HEARTBEAT_INTERVAL); } @@ -328,7 +340,7 @@ class Analytics { }, ), }, - { expl: _td('Your User Agent'), value: navigator.userAgent }, + { expl: _td('Your user agent'), value: navigator.userAgent }, { expl: _td('Your device resolution'), value: resolution }, ]; @@ -337,7 +349,7 @@ class Analytics { title: _t('Analytics'), description:
- { _t('The information being sent to us to help make Riot.im better includes:') } + { _t('The information being sent to us to help make Riot better includes:') }
{ rows.map((row) => diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7a8642be95..7ac9f131d3 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -5,21 +5,22 @@ "Failed to verify email address: make sure you clicked the link in the email": "Failed to verify email address: make sure you clicked the link in the email", "Add Phone Number": "Add Phone Number", "The platform you're on": "The platform you're on", - "The version of Riot.im": "The version of Riot.im", + "The version of Riot": "The version of Riot", "Whether or not you're logged in (we don't record your username)": "Whether or not you're logged in (we don't record your username)", "Your language of choice": "Your language of choice", "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 'breadcrumbs' feature (avatars above the room list)": "Whether or not you're using the 'breadcrumbs' feature (avatars above the room list)", "Your homeserver's URL": "Your homeserver's URL", "Your identity server's URL": "Your identity server's URL", + "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", "e.g. %(exampleValue)s": "e.g. %(exampleValue)s", "Every page you use in the app": "Every page you use in the app", "e.g. ": "e.g. ", - "Your User Agent": "Your User Agent", + "Your user agent": "Your user agent", "Your device resolution": "Your device resolution", "Analytics": "Analytics", - "The information being sent to us to help make Riot.im better includes:": "The information being sent to us to help make Riot.im better includes:", + "The information being sent to us to help make Riot better includes:": "The information being sent to us to help make Riot better includes:", "Where this page includes identifiable information, such as a room, user or group ID, that data is removed before being sent to the server.": "Where this page includes identifiable information, such as a room, user or group ID, that data is removed before being sent to the server.", "Error": "Error", "Unable to load! Check your network connectivity and try again.": "Unable to load! Check your network connectivity and try again.", diff --git a/src/rageshake/submit-rageshake.js b/src/rageshake/submit-rageshake.js index ed5a9e5946..659a56dffb 100644 --- a/src/rageshake/submit-rageshake.js +++ b/src/rageshake/submit-rageshake.js @@ -67,6 +67,12 @@ export default async function sendBugReport(bugReportEndpoint, opts) { userAgent = window.navigator.userAgent; } + let installedPWA = "UNKNOWN"; + try { + // Known to work at least for desktop Chrome + installedPWA = window.matchMedia('(display-mode: standalone)').matches; + } catch (e) { } + const client = MatrixClientPeg.get(); console.log("Sending bug report."); @@ -76,6 +82,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) { body.append('app', 'riot-web'); body.append('version', version); body.append('user_agent', userAgent); + body.append('installed_pwa', installedPWA); if (client) { body.append('user_id', client.credentials.userId); From ca28f83841fc6e4d4f858707a7c8e7b217bb81d9 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 14 Feb 2020 17:36:14 +0000 Subject: [PATCH 2/2] 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 "" by default anyway) because Matomo only supports a limited number of custom variables. --- src/Analytics.js | 17 ++++++++++++----- src/Lifecycle.js | 2 +- src/i18n/strings/en_EN.json | 2 +- src/rageshake/submit-rageshake.js | 7 +++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Analytics.js b/src/Analytics.js index 9f540e46b3..8eea47ea89 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -57,6 +57,8 @@ function getRedactedUrl() { } const customVariables = { + // The Matomo installation at https://matomo.riot.im is currently configured + // with a limit of 10 custom variables. 'App Platform': { id: 1, expl: _td('The platform you\'re on'), @@ -92,10 +94,10 @@ const customVariables = { expl: _td('Your homeserver\'s URL'), example: 'https://matrix.org', }, - 'Identity Server URL': { + 'Touch Input': { id: 8, - expl: _td('Your identity server\'s URL'), - example: 'https://vector.im', + expl: _td("Whether you're using Riot on a device where touch is the primary input mechanism"), + example: 'false', }, 'Breadcrumbs': { id: 9, @@ -202,6 +204,13 @@ class Analytics { } catch (e) { } 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 this._heartbeatIntervalID = window.setInterval(this.ping.bind(this), HEARTBEAT_INTERVAL); } @@ -303,11 +312,9 @@ class Analytics { if (!config.piwik) return; 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)); - this._setVisitVariable('Identity Server URL', whitelistRedact(whitelistedISUrls, identityServerUrl)); } setBreadcrumbs(state) { diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 24bf99ed24..72cd84bfd9 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -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) { try { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 7ac9f131d3..c1ac0b1434 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -11,7 +11,7 @@ "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", "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 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", diff --git a/src/rageshake/submit-rageshake.js b/src/rageshake/submit-rageshake.js index 659a56dffb..091f64bf93 100644 --- a/src/rageshake/submit-rageshake.js +++ b/src/rageshake/submit-rageshake.js @@ -73,6 +73,12 @@ export default async function sendBugReport(bugReportEndpoint, opts) { installedPWA = window.matchMedia('(display-mode: standalone)').matches; } catch (e) { } + let touchInput = "UNKNOWN"; + try { + // MDN claims broad support across browsers + touchInput = window.matchMedia('(pointer: coarse)').matches; + } catch (e) { } + const client = MatrixClientPeg.get(); console.log("Sending bug report."); @@ -83,6 +89,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) { body.append('version', version); body.append('user_agent', userAgent); body.append('installed_pwa', installedPWA); + body.append('touch_input', touchInput); if (client) { body.append('user_id', client.credentials.userId);