Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add newsletter signup button to user settings page #14466

Merged
merged 24 commits into from Aug 13, 2019
Merged

Add newsletter signup button to user settings page #14466

merged 24 commits into from Aug 13, 2019

Conversation

katebutler
Copy link

@katebutler katebutler commented May 20, 2019

Fixes #14118

@katebutler katebutler added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label May 20, 2019
@katebutler katebutler added this to the 3.12.0 milestone May 20, 2019
@mattab mattab modified the milestones: 3.12.0, 3.11.0 Jun 16, 2019
@katebutler katebutler added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Jun 19, 2019
@katebutler
Copy link
Author

Ready for review/merge

Copy link
Member

@diosmosis diosmosis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments on the code, otherwise seems to work when tested locally.

plugins/UsersManager/API.php Outdated Show resolved Hide resolved
ng-click="personalSettings.signupForNewsletter()"
>{{ 'General_Yes'|translate }}</button>
</div>
{% endif %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattab Should there be any specific copy in this new section? The screenshot makes the section look a bit bare.

plugins/UsersManager/tests/UI/UserSettings_spec.js Outdated Show resolved Hide resolved
plugins/Installation/Controller.php Outdated Show resolved Hide resolved
plugins/UsersManager/Controller.php Outdated Show resolved Hide resolved
plugins/UsersManager/Controller.php Outdated Show resolved Hide resolved
@tsteur
Copy link
Member

tsteur commented Jul 5, 2019

In the personal settings page, should we mention this block maybe very first?
image

and I suppose we need to maybe show a privacy notice, similar to on our website https://matomo.org/newsletter :
image

@tsteur
Copy link
Member

tsteur commented Jul 5, 2019

fyi @katebutler see previous comment

@tsteur
Copy link
Member

tsteur commented Jul 5, 2019

Actually, I reckon by the time we show the privacy notice it'll take too much space.

Also to be safe re GDPR it might be good to show an unchecked checkbox and the button be disabled initially (disabled=true|false attribute should do this in angular). Clicking on the checkbox would enable the Yes button. Not sure if checkbox is needed though @Findus23 any thoughts?

@katebutler
Copy link
Author

Have added a short privacy notice and a checkbox.

@mattab mattab modified the milestones: 3.11.0, 3.12.0 Jul 23, 2019
public static function signupForNewsletter($userLogin, $email, $matomoOrg = false, $professionalServices = false)
{
// Don't bother if they aren't signing up for at least one newsletter
if (! ($matomoOrg || $professionalServices)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also need to return if Piwik\SettingsPiwik::isInternetEnabled() is disabled

Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katebutler I left a few comments and also converted the PR to use angular instead of jquery, and our built-in form components and notification component see 8d83f66 Can show you what it does tmrw. Now also when the checkbox is disabled, the confirm button will be disabled.

@@ -183,6 +185,9 @@ public function userSettings()
$view->userTokenAuth = Piwik::getCurrentUserTokenAuth();
$view->ignoreSalt = $this->getIgnoreCookieSalt();

$newsletterSignupOptionKey = 'UsersManager.newsletterSignup.' . $userLogin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be good to use a constant for this value 'UsersManager.newsletterSignup.'

@@ -183,6 +185,9 @@ public function userSettings()
$view->userTokenAuth = Piwik::getCurrentUserTokenAuth();
$view->ignoreSalt = $this->getIgnoreCookieSalt();

$newsletterSignupOptionKey = 'UsersManager.newsletterSignup.' . $userLogin;
$view->showNewsletterSignup = Option::get($newsletterSignupOptionKey) === false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also not show the box if Piwik\SettingsPiwik::isInternetEnabled() is disabled

@@ -405,6 +410,24 @@ public function recordUserSettings()
return $toReturn;
}

public function newsletterSignup()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katebutler ideally we would put this into an API so we could implement for example the same action in the mobile app or somewhere else. (of course the mobile API would also need an API method whether it has been submitted already or not but that's not needed for now).

Once this is in the API, it'll be simply return true/false and it should simplify things. Only need to slightly adjust the JavaScript that calls it like {module: 'API', method: 'UsersManager.signupNewsletter'}

@tsteur
Copy link
Member

tsteur commented Jul 29, 2019

BTW there's also a merge conflict

@tsteur
Copy link
Member

tsteur commented Aug 5, 2019

@tsteur
Copy link
Member

tsteur commented Aug 7, 2019

@katebutler there's still a failing test BTW: https://builds-artifacts.matomo.org/matomo-org/matomo/3.x-dev/35326/UserSettings_signup_success.png

The expected message is no longer showing as the success message is now shown in a success notification. We can usually take a screnshot of that using #notificationcontainer or something similar (don't remember the ID of the notifications container).

@tsteur tsteur merged commit 5f96a27 into 3.x-dev Aug 13, 2019
@tsteur tsteur deleted the 14188 branch August 13, 2019 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let any user in Matomo signup to our Matomo newsletter
4 participants