diff options
author | Ben Burgess <88810029+bx80@users.noreply.github.com> | 2021-11-16 01:49:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-16 01:49:33 +0300 |
commit | bd3e66993262f795a194386979cb56fe41ff6497 (patch) | |
tree | 27b74641573b538c747381efa67b511daa468b43 /plugins/Feedback/API.php | |
parent | 33132937abf4cbfd7824a4b385c37e6e03fb0ec7 (diff) |
Improvements to the in-app feature rating mechanism (#18280)
* Changes to in-app feedback mechanism
* Fix for dialog close issue
* Update plugins/Feedback/API.php
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Update plugins/Feedback/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Added UI tests
* UI improvements, shorter questions text, autofocus text field
* Layout tweaks
* Added custom questions for like choices
* Fix for UI tests, added UI screenshot
* Updated UI test screenshots
* Updated UI test screenshots
* Build vue
* built vue files
* Update plugins/Feedback/lang/en.json
Co-authored-by: Stefan Giehl <stefan@matomo.org>
* Tidied message validation, text fixes, added privacy policy link
* built vue files
* Update plugins/Feedback/API.php
* Update plugins/Feedback/API.php
* built vue files
* Added missing selection.json
* Restored deleted ReviewLinks which is to be displayed after a positive Rate Feature
* built vue files
* Added null check for javascript focus call
* built vue files
* Remove unnecessary inline test check for rate feature feedback mail
* Updated UI test screenshot
Co-authored-by: Stefan Giehl <stefan@matomo.org>
Co-authored-by: bx80 <bx80@users.noreply.github.com>
Co-authored-by: sgiehl <sgiehl@users.noreply.github.com>
Diffstat (limited to 'plugins/Feedback/API.php')
-rw-r--r-- | plugins/Feedback/API.php | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/plugins/Feedback/API.php b/plugins/Feedback/API.php index 1619d46544..1ab2b6c6da 100644 --- a/plugins/Feedback/API.php +++ b/plugins/Feedback/API.php @@ -15,6 +15,7 @@ use Piwik\Date; use Piwik\IP; use Piwik\Mail; use Piwik\Piwik; +use Piwik\SettingsServer; use Piwik\Url; use Piwik\Version; @@ -29,15 +30,20 @@ class API extends \Piwik\Plugin\API * Sends feedback for a specific feature to the Matomo team or alternatively to the email address configured in the * config: "feedback_email_address". * - * @param string $featureName The name of a feature you want to give feedback to. - * @param bool|int $like Whether you like the feature or not - * @param string|bool $message A message containing the actual feedback + * @param string|null $featureName The name of a feature you want to give feedback to. + * @param int $like Whether you like the feature or not + * @param string|null $choice Multiple choice option chosen + * @param string|null $message A message containing the actual feedback */ - public function sendFeedbackForFeature($featureName, $like, $message = false) + public function sendFeedbackForFeature(?string $featureName, int $like, ?string $choice, ?string $message = null) { Piwik::checkUserIsNotAnonymous(); Piwik::checkUserHasSomeViewAccess(); + if (empty($message) || $message === 'undefined' || strlen($message) < 4) { + return Piwik::translate("Feedback_FormNotEnoughFeedbackText"); + } + $featureName = $this->getEnglishTranslationForFeatureName($featureName); $likeText = 'Yes'; @@ -47,19 +53,30 @@ class API extends \Piwik\Plugin\API $body = sprintf("Feature: %s\nLike: %s\n", $featureName, $likeText); - $feedbackMessage = ""; - if (!empty($message) && $message != 'undefined') { - $feedbackMessage = sprintf("Feedback:\n%s\n", trim($message)); + if (!empty($choice) && $choice !== 'undefined') { + $body .= "Choice: ".$choice."\n"; } - $body .= $feedbackMessage ? $feedbackMessage : " \n"; - $subject = sprintf("%s for %s %s", + $body .= sprintf("Feedback:\n%s\n", trim($message)); + + $subject = sprintf("%s for %s", empty($like) ? "-1" : "+1", - $featureName, - empty($feedbackMessage) ? "" : "(w/ feedback)" + $featureName ); + // Determine where Matomo is running and add as source + if (Config::getHostname() === 'demo.matomo.cloud') { + $source = 'Demo'; + } else if (SettingsServer::isMatomoForWordPress()) { + $source = 'Wordpress'; + } else { + $source = 'On-Premise'; + } + $body .= "Source: ".$source."\n"; + $this->sendMail($subject, $body); + + return 'success'; } /** |