zima/yii2-metrica

Metrica component for Yii2.

This package's canonical repository appears to be gone and the package has been frozen as a result.

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Type:yii2-extension

0.0.2 2020-03-11 04:46 UTC

This package is auto-updated.

Last update: 2022-01-11 11:20:41 UTC


README

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist zima/yii2-metrica "*"

or add

"zima/yii2-metrica": "*"

to the require section of your composer.json file.

.env

YANDEX_METRICA_API_URL=https://api-metrika.yandex.net/stat/v1/data
YANDEX_METRICA_OAUTH=AgAAAAA2j7uwAAYq5Dg1zhTwvkgElJzgcpC1Swg
YANDEX_METRICA_COUNTER=44147844

common

'container' => [
    'definitions' => [
            \zima\metrica\interfaces\SourceAdapterInterface::class => function () {
                $client = new \yii\httpclient\Client([
                    'transport' => \yii\httpclient\CurlTransport::class,
                    'baseUrl' => 'https://api-metrika.yandex.net/stat/v1/data',
                    'responseConfig' => [
                        'format' => \yii\httpclient\Client::FORMAT_JSON,
                    ],
                    'requestConfig' => [
                        'options' => [
                            'timeout' => 5,
                        ],
                    ],
                ]);

                $token = 'AgAAAAA2j7uwAAYq5Dg1zhTwvkgElJzgcpC1Swg';
                $counter = '44147844';

                return new \zima\metrica\adapters\source\YandexAdapter($client, $token, $counter);
            },
/* //Pseudo source
             \zima\metrica\interfaces\SourceAdapterInterface::class => function () {
                return Yii::createObject(\zima\metrica\adapters\source\PseudoJsonAdapter::class,
                    [Yii::getAlias('@app/modules/metrica/data')]);
            },
*/            
            \zima\metrica\interfaces\MetricaComponentInterface::class => \zima\metrica\components\MetricaComponent::class,
    ],
],