Giter Site home page Giter Site logo

statisticapp's Introduction

Javascript instalation

Put below code befor </body> tag

<script>
    (function(i){var d=document;var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='http://inz.tums.pl/js/statisticapp.js';var w=window; w.statisticApp=i;var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);
    })({
        appId: "your app id",
        userKey: "unique user key", // Uniq user identificator (email or id)
    });
</script>

PHP instalation

Instal script via composer

composer require emsoft/statisticapp dev-master

Create instance of StatisticApp

use Emsoft\StatisticAppBundle\StatisticApp;
// ...
$statisticApp = new StatisticApp('your app id');

Before each request run below code

use Emsoft\StatisticAppBundle\StatisticMessage;
// ...
$message = new StatisticMessage("unique user key"); // Uniq user identificator (email or id)
$statisticApp->send($message);

Symfony instalation

Instal script via composer

composer require emsoft/statisticapp dev-master

Put app id into config parameters

parameters:
    locale: pl
    statisticAppId: asd

Create statistic event listener

<?php
namespace AppBundle\EventListener;

use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Emsoft\StatisticAppBundle\StatisticApp;
use Emsoft\StatisticAppBundle\StatisticMessage;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController;

class StatisticListener
{

    /**
     * @var ContainerInterface
     */
    private $container;
    private $statisticApp;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
        $this->statisticApp = new StatisticApp($container->getParameter('statisticAppId'));
    }
    public function onKernelController(FilterControllerEvent $event)
    {
        $controller = $event->getController();
        if (!is_array($controller)) {
            return;
        }

        foreach ($controller as $co)
        {
            if ($co instanceof ProfilerController) {
                return;
            }
        }
        $user = $this->container->get('security.token_storage')->getToken()->getUser();
        
        $message = new StatisticMessage($user->getId());
        $this->statisticApp->send($message);
    }

}

Add event listener to service config

app.statistic.action_listener:
    class: AppBundle\EventListener\StatisticListener
    arguments: [ @service_container ]
    tags:
        - { name: kernel.event_listener, event: kernel.controller, method: onKernelController }

statisticapp's People

Contributors

mateusz-suchowiecki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.