library pulse-bundle
Basic analytics event tracking in Symfony
prezent/pulse-bundle
Basic analytics event tracking in Symfony
- Tuesday, November 29, 2016
- by prezent
- Repository
- 4 Watchers
- 0 Stars
- 333 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 3 Versions
- 0 % Grown
prezent/pulse-bundle
Basic analytics event tracking in Symfony, (*1)
The full documentation can be found in Resources/doc, (*2)
Quickstart example
namespace AppBundle\Controller;
use Prezent\PulseBundle\Event\PulseEvent;
use Prezent\PulseBundle\Query\Query;
use Symfony\Bundle\FrameworkBundle\Controller\Controller
class AppController extends Controller
{
public function trackableAction()
{
$this->get('event_dispatcher')->dispatch(PulseEvent::EVENT, new PulseEvent('some.action', [
'user' => $this->getUser()->getId(),
]));
}
public function analyticsAction()
{
$query = new Query();
$query
->setTypes(['some.action', 'other.action'])
->setStartDate(new \DateTime('-7 days'))
->setEndDate(new \DateTime())
;
return $this->render('AppBundle:App:analytics.html.twig', [
'result' => $this->get('prezent_pulse.repository')->query($query),
]);
}
}
{% extends '::base.html.twig' %}
{% block body %}
|
{% for column in result.columns %}
{{ column }} |
{% endfor %}
Total |
{% for row in result %}
| {{ row.key }}: {{ row.id }} |
{% for value in row %}
{{ value }} |
{% endfor %}
{{ row.total }} |
{% endfor %}
| Total |
{% for value in result.columnTotals %}
{{ value }} |
{% endfor %}
{{ result.total }} |
{% endblock %}