<commit_before><?php

class CMService_KissMetrics_Client implements CM_Service_Tracking_ClientInterface {

    /** @var string */
    protected $_code;

    /** @var int|null */
    protected $_userId;

    /**
     * @param string $code
     */
    public function __construct($code) {
        $this->_code = (string) $code;
    }

    /**
     * @return boolean
     */
    public function enabled() {
        return '' !== $this->getCode();
    }

    /**
     * @return string
     */
    public function getCode() {
        return $this->_code;
    }

    public function getHtml() {
        if (!$this->enabled()) {
            return '';
        }
        $html = '<script type="text/javascript">';
        $html .= 'var _kmq = _kmq || [];';
        $html .= "var _kmk = _kmk || '" . $this->getCode() . "';";
        $html .= <<<EOF
function _kms(u) {
  setTimeout(function() {
    var d = document, f = d.getElementsByTagName('script')[0], s = d.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.src = u;
    f.parentNode.insertBefore(s, f);
  }, 1);
}
_kms('//i.kissmetrics.com/i.js');
_kms('//doug1izaerwt3.cloudfront.net/' + _kmk + '.1.js');
EOF;
        $html .= $this->getJs();
        $html .= '</script>';
        return $html;
    }

    /**
     * @return string
     */
    public function getJs() {
        if (!$this->enabled()) {
            return '';
        }
        $js = '';
        if (null !== $this->getUserId()) {
            $js .= "_kmq.push(['identify', " . $this->getUserId() . "]);";
        }
        return $js;
    }

    /**
     * @return int|null
     */
    public function getUserId() {
        return $this->_userId;
    }

    /**
     * @param int|null $userId
     */
    public function setUserId($userId) {
        if (null !== $userId) {
            $userId = (int) $userId;
        }
        $this->_userId = $userId;
    }

    /**
     * @param CM_Action_Abstract $action
     */
    public function trackAction(CM_Action_Abstract $action) {
        if (!$this->enabled()) {
            return;
        }
        if (null === $this->getUserId()) {
            if ($actor = $action->getActor()) {
                $this->setUserId($actor->getId());
            } else {
                return;
            }
        }
        $trackEventJob = new CMService_KissMetrics_TrackEventJob();
        $trackEventJob->queue(array(
            'code'         => $this->getCode(),
            'userId'       => $this->getUserId(),
            'event'        => $action->getLabel(),
            'propertyList' => $action->getTrackingPropertyList(),
        ));
    }

    public function trackPageView(CM_Frontend_Environment $environment) {
        if ($viewer = $environment->getViewer()) {
            $this->setUserId($viewer->getId());
        }
    }
}<commit_msg>Adjusted methods visibility in CMService_KissMetrics_Client<commit_after><?php

class CMService_KissMetrics_Client implements CM_Service_Tracking_ClientInterface {

    /** @var string */
    protected $_code;

    /** @var int|null */
    protected $_userId;

    /**
     * @param string $code
     */
    public function __construct($code) {
        $this->_code = (string) $code;
    }

    public function getHtml() {
        if (!$this->_enabled()) {
            return '';
        }
        $html = '<script type="text/javascript">';
        $html .= 'var _kmq = _kmq || [];';
        $html .= "var _kmk = _kmk || '" . $this->_getCode() . "';";
        $html .= <<<EOF
function _kms(u) {
  setTimeout(function() {
    var d = document, f = d.getElementsByTagName('script')[0], s = d.createElement('script');
    s.type = 'text/javascript';
    s.async = true;
    s.src = u;
    f.parentNode.insertBefore(s, f);
  }, 1);
}
_kms('//i.kissmetrics.com/i.js');
_kms('//doug1izaerwt3.cloudfront.net/' + _kmk + '.1.js');
EOF;
        $html .= $this->getJs();
        $html .= '</script>';
        return $html;
    }

    /**
     * @return string
     */
    public function getJs() {
        if (!$this->_enabled()) {
            return '';
        }
        $js = '';
        if (null !== $this->_getUserId()) {
            $js .= "_kmq.push(['identify', " . $this->_getUserId() . "]);";
        }
        return $js;
    }

    /**
     * @param CM_Action_Abstract $action
     */
    public function trackAction(CM_Action_Abstract $action) {
        if (!$this->_enabled()) {
            return;
        }
        if (null === $this->_getUserId()) {
            if ($actor = $action->getActor()) {
                $this->_setUserId($actor->getId());
            } else {
                return;
            }
        }
        $trackEventJob = new CMService_KissMetrics_TrackEventJob();
        $trackEventJob->queue(array(
            'code'         => $this->_getCode(),
            'userId'       => $this->_getUserId(),
            'event'        => $action->getLabel(),
            'propertyList' => $action->getTrackingPropertyList(),
        ));
    }

    public function trackPageView(CM_Frontend_Environment $environment) {
        if ($viewer = $environment->getViewer()) {
            $this->_setUserId($viewer->getId());
        }
    }

    /**
     * @return boolean
     */
    protected function _enabled() {
        return '' !== $this->_getCode();
    }

    /**
     * @return string
     */
    protected function _getCode() {
        return $this->_code;
    }

    /**
     * @return int|null
     */
    protected function _getUserId() {
        return $this->_userId;
    }

    /**
     * @param int|null $userId
     */
    protected function _setUserId($userId) {
        if (null !== $userId) {
            $userId = (int) $userId;
        }
        $this->_userId = $userId;
    }
}
{'fraction_non_alphanumeric': 0.17459215550156196, 'fraction_numerical': 0.0017355085039916696, 'mean_word_length': 1.7854035766070566, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5094985', 'n_tokens_mistral': 1769, 'n_tokens_neox': 1789, 'n_words': 330}