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
Send email if no tracked data within N days. #13363
Changes from 14 commits
620816a
7c49031
6a9bf34
b1f2d9d
12577df
cb56089
a5510bb
185aafc
35837ab
87d8d72
b2b06ab
96684fb
f1cfb1e
f5e3c79
f8059cf
c1013e0
ff5a0f4
89f6cbc
e1aca7b
916efa9
8ed1f32
9fc74bf
9217388
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace Piwik\Email; | ||
|
||
use Piwik\View; | ||
use Piwik\View\HtmlReportEmailHeaderView; | ||
|
||
class ContentGenerator | ||
{ | ||
public function generateHtmlContent(View $body) | ||
{ | ||
HtmlReportEmailHeaderView::assignCommonParameters($body); | ||
$bodyHtml = $body->render(); | ||
|
||
$header = new View("@CoreHome/_htmlEmailHeader.twig"); | ||
HtmlReportEmailHeaderView::assignCommonParameters($header); | ||
$headerHtml = $header->render(); | ||
|
||
$footer = new View("@CoreHome/_htmlEmailFooter.twig"); | ||
HtmlReportEmailHeaderView::assignCommonParameters($footer); | ||
$footerHtml = $footer->render(); | ||
|
||
return $headerHtml . $bodyHtml . $footerHtml; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -636,4 +636,15 @@ public static function getExcludedQueryParametersFor($idsite) | |
{ | ||
return self::getFor($idsite, 'excluded_parameters'); | ||
} | ||
|
||
/** | ||
* Returns the user that created this site. | ||
* | ||
* @param int $idsite The site ID. | ||
* @return string|null If null, the site was created before the creation user was tracked. | ||
*/ | ||
public static function getCreatorLoginFor($idsite) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add the |
||
{ | ||
return self::getFor($idsite, 'creator_login'); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace Piwik\Updates; | ||
|
||
use Piwik\Common; | ||
use Piwik\Updater\Migration\Factory as MigrationFactory; | ||
use Piwik\Updates; | ||
use Piwik\Updater; | ||
|
||
/** | ||
* Update for version 3.6.1-b2. | ||
*/ | ||
class Updates_3_6_1_b2 extends Updates | ||
{ | ||
/** | ||
* @var MigrationFactory | ||
*/ | ||
private $migration; | ||
|
||
public function __construct(MigrationFactory $factory) | ||
{ | ||
$this->migration = $factory; | ||
} | ||
|
||
public function getMigrations(Updater $updater) | ||
{ | ||
return array( | ||
$this->migration->db->addColumn('site', 'creator_login', ' VARCHAR(100) NULL'), | ||
); | ||
} | ||
|
||
public function doUpdate(Updater $updater) | ||
{ | ||
$updater->executeMigrations(__FILE__, $this->getMigrations($updater)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* Piwik - free/libre analytics platform | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace Piwik\Plugins\CoreAdminHome\Emails; | ||
|
||
use Piwik\Mail; | ||
use Piwik\Piwik; | ||
use Piwik\Site; | ||
use Piwik\View; | ||
|
||
class JsTrackingCodeMissingEmail extends Mail | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $login; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $emailAddress; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $idSite; | ||
|
||
public function __construct($login, $emailAddress, $idSite) | ||
{ | ||
parent::__construct(); | ||
|
||
$this->login = $login; | ||
$this->emailAddress = $emailAddress; | ||
$this->idSite = $idSite; | ||
|
||
$this->setUpEmail(); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getLogin() | ||
{ | ||
return $this->login; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEmailAddress() | ||
{ | ||
return $this->emailAddress; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getIdSite() | ||
{ | ||
return $this->idSite; | ||
} | ||
|
||
private function setUpEmail() | ||
{ | ||
$this->setDefaultFromPiwik(); | ||
$this->addTo($this->emailAddress); | ||
$this->setSubject($this->getDefaultSubject()); | ||
$this->setReplyTo($this->getFrom()); | ||
$this->setWrappedHtmlBody($this->getDefaultBodyView()); | ||
} | ||
|
||
private function getDefaultSubject() | ||
{ | ||
return Piwik::translate('CoreAdminHome_MissingTrackingCodeEmailSubject', [Site::getMainUrlFor($this->idSite)]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the name instead of the URL? AFAIK a URL is optional (eg not needed for mobile apps) and also reads better maybe. I was wondering if we can incorporate "analytics" or "Matomo" somehow into the subject but I can see it is tricky. |
||
} | ||
|
||
private function getDefaultBodyView() | ||
{ | ||
$view = new View('@CoreAdminHome/_jsTrackingCodeMissingEmail.twig'); | ||
$view->login = $this->login; | ||
$view->emailAddress = $this->emailAddress; | ||
$view->idSite = $this->idSite; | ||
$view->siteUrl = Site::getMainUrlFor($this->idSite); | ||
return $view; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering... should this be maybe in a new class which can be injected etc? Then we could also replace it through DI etc... I'd say the class does otherwise maybe too many things like formatting plus setting mail etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's here so derived classes can use it.
The idea in this PR is that future emails will create their own class that derived from Mail, then in event handlers plugins can detect exactly which email is about to be sent. The derived class would call this method to set the HTML body. So the methods in this class should done one of two things: configure the email to be sent, or send the email.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more thinking if it was a class, we could overwrite the wrap globally for all emails. For example on Cloud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, overwrite just the wrapping logic, gotcha.