From 6f77b8ae26bc939822e75f9bb448d5d257c645e7 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 24 May 2018 12:46:06 +0100 Subject: [PATCH 1/2] Modify showDetailsModal to give examples if analytics is not enabled --- src/Analytics.js | 25 ++++++++++++++++++++++--- src/i18n/strings/en_EN.json | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Analytics.js b/src/Analytics.js index ec8234eb83..8ffce7077f 100644 --- a/src/Analytics.js +++ b/src/Analytics.js @@ -49,34 +49,42 @@ const customVariables = { 'App Platform': { id: 1, expl: _td('The platform you\'re on'), + example: 'Electron Platform', }, 'App Version': { id: 2, expl: _td('The version of Riot.im'), + example: '15.0.0', }, 'User Type': { id: 3, expl: _td('Whether or not you\'re logged in (we don\'t record your user name)'), + example: 'Logged In', }, 'Chosen Language': { id: 4, expl: _td('Your language of choice'), + example: 'en', }, 'Instance': { id: 5, expl: _td('Which officially provided instance you are using, if any'), + example: 'app', }, 'RTE: Uses Richtext Mode': { id: 6, expl: _td('Whether or not you\'re using the Richtext mode of the Rich Text Editor'), + example: 'off', }, 'Homeserver URL': { id: 7, expl: _td('Your homeserver\'s URL'), + example: 'https://matrix.org', }, 'Identity Server URL': { id: 8, expl: _td('Your identity server\'s URL'), + example: 'https://vector.im', }, }; @@ -218,8 +226,19 @@ class Analytics { } showDetailsModal() { - const Tracker = window.Piwik.getAsyncTracker(); - const rows = Object.values(customVariables).map((v) => Tracker.getCustomVariable(v.id)).filter(Boolean); + let rows = []; + if (window.Piwik) { + const Tracker = window.Piwik.getAsyncTracker(); + rows = Object.values(customVariables).map((v) => Tracker.getCustomVariable(v.id)).filter(Boolean); + } else { + // Piwik may not have been enabled, so show example values + rows = Object.keys(customVariables).map( + (k) => [ + k, + _t('e.g. %(exampleValue)s', { exampleValue: customVariables[k].example }), + ], + ); + } const resolution = `${window.screen.width}x${window.screen.height}`; const otherVariables = [ @@ -247,7 +266,7 @@ class Analytics { { rows.map((row) => - + { row[1] !== undefined && } ) } { otherVariables.map((item, index) => diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8dc5b8e630..8bacc3557e 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -10,6 +10,7 @@ "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", + "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", From aae89efa017c41a5728d09366cf19ea8712c0ef0 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 24 May 2018 12:47:27 +0100 Subject: [PATCH 2/2] Add usage data link to cookie bar this opens the analytics modal --- src/components/views/globals/CookieBar.js | 14 +++++++++++++- src/i18n/strings/en_EN.json | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/views/globals/CookieBar.js b/src/components/views/globals/CookieBar.js index 8fab64be67..ad00884dd2 100644 --- a/src/components/views/globals/CookieBar.js +++ b/src/components/views/globals/CookieBar.js @@ -19,6 +19,7 @@ import PropTypes from 'prop-types'; import dis from '../../../dispatcher'; import { _t } from '../../../languageHandler'; import sdk from '../../../index'; +import Analytics from '../../../Analytics'; export default class CookieBar extends React.Component { static propTypes = { @@ -29,6 +30,10 @@ export default class CookieBar extends React.Component { super(); } + onUsageDataClicked() { + Analytics.showDetailsModal(); + } + onAccept() { dis.dispatch({ action: 'accept_cookies', @@ -49,11 +54,18 @@ export default class CookieBar extends React.Component { Warning
{ this.props.policyUrl ? _t( - "Help improve Riot by sending usage data? " + + "Help improve Riot by sending usage data? " + "This will use a cookie. " + "(See our cookie and privacy policies).", {}, { + 'UsageDataLink': (sub) => + { sub } + , // XXX: We need to link to the page that explains our cookies 'PolicyLink': (sub) => cookie and privacy policies).": "Help improve Riot by sending usage data? This will use a cookie. (See our cookie and privacy policies).", + "Help improve Riot by sending usage data? This will use a cookie. (See our cookie and privacy policies).": "Help improve Riot by sending usage data? This will use a cookie. (See our cookie and privacy policies).", "Help improve Riot by sending usage data? This will use a cookie.": "Help improve Riot by sending usage data? This will use a cookie.", "Yes please": "Yes please", "You are not receiving desktop notifications": "You are not receiving desktop notifications",
{ _t(customVariables[row[0]].expl) }{ row[1] }{ row[1] }