<?php
/**
 * Created by PhpStorm.
 * User: JCastro
 * Date: 05/04/16
 * Time: 4:56 PM
 */

namespace AnalyticsForAMP;


class FrontendAMP
{
    public function __construct()
    {
        $this->addFilters();
    }

    public function addFilters()
    {
        add_filter( 'amp_post_template_analytics', array( $this, 'analytics' ) );
        return $this;
    }

    public function analytics()
    {
        $UA = new Analytics();

        $analytics['octopus-googleanalytics'] = array(
            'type'        => 'googleanalytics',
            'attributes'  => array(),
            'config_data' => array(
                'vars'     => array(
                    'account' => $UA->getOptionValue('analytics')
                ),
                'triggers' => array(
                    'trackPageview' => array(
                        'on'      => 'visible',
                        'request' => 'pageview',
                    ),
                ),
            ),
        );

        return $analytics;
    }
}