From c3e7ddc3a99d744d2c7cb7fefc9cecffb544057f Mon Sep 17 00:00:00 2001 From: ell Date: Thu, 23 Jun 2016 22:55:16 +0300 Subject: [PATCH] More meta files added. Automatic code style fixer added. --- .gitignore | 4 ++ .php_cs | 64 +++++++++++++++++++++++++++++ CODE_OF_CONDUCT.md | 74 ++++++++++++++++++++++++++++++++++ CONTRIBUTING.md | 38 +++++++++++++++++ LICENSE | 4 +- README.md | 64 +++++++++++++---------------- composer.json | 49 +++++++++++----------- src/widgets/GATracking.php | 18 ++++----- src/widgets/views/tracking.php | 3 +- 9 files changed, 245 insertions(+), 73 deletions(-) create mode 100644 .gitignore create mode 100644 .php_cs create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c5583d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/vendor +composer.phar +composer.lock +.php_cs.cache diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..3f43753 --- /dev/null +++ b/.php_cs @@ -0,0 +1,64 @@ +notPath('bootstrap/cache') + ->notPath('storage') + ->notPath('vendor') + ->in(__DIR__) + ->name('*.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +$fixers = [ + '-psr0', + '-php_closing_tag', + 'blankline_after_open_tag', + '-concat_without_spaces', + 'double_arrow_multiline_whitespaces', + 'duplicate_semicolon', + 'empty_return', + 'extra_empty_lines', + 'include', + 'join_function', + 'list_commas', + 'multiline_array_trailing_comma', + 'namespace_no_leading_whitespace', + 'newline_after_open_tag', + 'no_blank_lines_after_class_opening', + 'no_empty_lines_after_phpdocs', + 'object_operator', + 'operators_spaces', + 'phpdoc_indent', + 'phpdoc_no_access', + '-phpdoc_no_package', + 'phpdoc_scalar', + 'phpdoc_short_description', + 'phpdoc_to_comment', + 'phpdoc_trim', + 'phpdoc_type_to_var', + '-phpdoc_var_without_name', + 'remove_leading_slash_use', + 'remove_lines_between_uses', + 'return', + 'self_accessor', + 'single_array_no_trailing_comma', + 'single_blank_line_before_namespace', + 'single_quote', + 'spaces_before_semicolon', + 'spaces_cast', + 'standardize_not_equal', + 'ternary_spaces', + 'trim_array_spaces', + 'unalign_equals', + 'unary_operators_spaces', + 'whitespacy_lines', + 'multiline_spaces_before_semicolon', + 'short_array_syntax', + '-short_echo_tag', +]; + +return Symfony\CS\Config\Config::create() + ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->fixers($fixers) + ->finder($finder) + ->setUsingCache(true); diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..31dc1af --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at support@cybercog.su. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b35a33d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,38 @@ +# Contributing to Yii2 Google Analytics Tracking + +Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. + +## Workflow + +- Fork the project. +- Make your bug fix or feature addition. +- Add tests for it. This is important so we don't break it in a future version unintentionally. +- Send a pull request. Bonus points for topic branches. + +Please make sure that you have [set up your user name and email address](http://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. + +Pull requests for bug fixes must be based on the current stable branch. + +We are trying to keep backwards compatibility breaks in Yii2 Google Analytics Widget to an absolute minimum. Please take this into account when proposing changes. + +Due to time constraints, we are not always able to respond as quickly as we would like. Please do not take delays personal and feel free to remind us if you feel that we forgot to respond. + +## Coding Guidelines + +This project comes with a configuration file for php-cs-fixer (.php_cs) that you can use to (re)format your sourcecode for compliance with this project's coding guidelines: + +```sh +vendor/bin/php-cs-fixer fix +``` + +## PHPUnit tests + +The phpunit script can be used to invoke the PHPUnit test runner: + +```sh +phpunit +``` + +## Reporting issues + +- [General problems](https://github.com/cybercog/yii2-google-analytics/issues) diff --git a/LICENSE b/LICENSE index 16ae8a0..bc408f7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ Google Analytics extension for the Yii framework is free software. It is released under the terms of the following BSD License. -Copyright © 2015, CyberCog LLC (http://cybercog.ru) All rights reserved. +Copyright © 2016, CyberCog LLC (http://cybercog.ru) All rights reserved. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,4 +27,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 7f4b0ce..ba570b1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ -# Google Analytics for Yii2 +# Yii2 Google Analytics Tracking -[![Join the chat at https://gitter.im/cybercog/yii2-google-analytics](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cybercog/yii2-google-analytics?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Gitter chat at https://gitter.im/cybercog/yii2-google-analytics](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cybercog/yii2-google-analytics?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Latest Stable Version](https://poser.pugx.org/cybercog/yii2-google-analytics/version)](https://packagist.org/packages/cybercog/yii2-google-analytics) +[![License](https://poser.pugx.org/cybercog/yii2-google-analytics/license)](https://github.com/cybercog/yii2-google-analytics/blob/master/LICENSE) This extension provides easy way to add Universal Analytics tracking in your Yii2 application. @@ -8,20 +10,12 @@ This extension provides easy way to add Universal Analytics tracking in your Yii The preferred way to install this extension is through [composer](http://getcomposer.org/download/). -Either run +Run in console ```bash -$ php composer.phar require cybercog/yii2-google-analytics "~0.2" +php composer.phar require cybercog/yii2-google-analytics ``` -or add - -```json -"cybercog/yii2-google-analytics": "~0.2" -``` - -to the require section of your `composer.json` file. - ## Usage In your `/views/layouts/main.php` add @@ -33,11 +27,9 @@ use cybercog\yii\googleanalytics\widgets\GATracking; Then before `` add following code ```php - 'UA-XXXXXXXX-X' - ] -) ?> + 'UA-XXXXXXXX-X', +]) ?> ``` ## Advanced usage @@ -64,7 +56,7 @@ But sometimes we need the output without `script` tag to combined with `register registerJs( GATracking::widget([ 'trackingId' => 'UA-XXXXXXXX-X', - 'omitScriptTag' => true + 'omitScriptTag' => true, ]), \yii\web\View::POS_END ); ?> ``` @@ -74,26 +66,24 @@ But sometimes we need the output without `script` tag to combined with `register You can configure tracking script for your needs: ```php - 'UA-XXXXXXXX-X', - 'trackingConfig' => [ - 'name' => 'myTracker', - 'allowAnchor' => false + 'UA-XXXXXXXX-X', + 'trackingConfig' => [ + 'name' => 'myTracker', + 'allowAnchor' => false, + ], + 'omitScriptTag' => false, + 'debug' => true, + 'debugTrace' => true, + 'anonymizeIp' => true, + 'plugins' => [ + 'linkid' => [ + 'cookieName' => '_ccli', + 'duration' => 45, + 'levels' => 5, ], - 'omitScriptTag' => false, - 'debug' => true, - 'debugTrace' => true, - 'anonymizeIp' => true, - 'plugins' => [ - 'linkid' => [ - 'cookieName' => '_ccli', - 'duration' => 45, - 'levels' => 5 - ] - ] - ] -) ?> + ], +]) ?> ``` ## Available fields (parameters) diff --git a/composer.json b/composer.json index 22b9bfb..a7655dc 100644 --- a/composer.json +++ b/composer.json @@ -1,25 +1,28 @@ { - "name": "cybercog/yii2-google-analytics", - "description": "Google Analytics extension for the Yii2 framework", - "keywords": [ - "yii2", - "google", - "analytics" - ], - "type": "yii2-extension", - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Anton Komarev", - "email": "ell@cybercog.su" + "name": "cybercog/yii2-google-analytics", + "description": "Google Analytics Widget for the Yii2 framework", + "keywords": [ + "yii2", + "google", + "analytics" + ], + "type": "yii2-extension", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Anton Komarev", + "email": "ell@cybercog.su" + } + ], + "require": { + "yiisoft/yii2": "*" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^1.11" + }, + "autoload": { + "psr-4": { + "cybercog\\yii\\googleanalytics\\": "src" + } } - ], - "require": { - "yiisoft/yii2": "*" - }, - "autoload": { - "psr-4": { - "cybercog\\yii\\googleanalytics\\": "src" - } - } -} \ No newline at end of file +} diff --git a/src/widgets/GATracking.php b/src/widgets/GATracking.php index d0bd6fd..380a249 100644 --- a/src/widgets/GATracking.php +++ b/src/widgets/GATracking.php @@ -1,29 +1,29 @@ */ class GATracking extends Widget { - /** - * Render + * Render . * @var bool */ public $omitScriptTag = false; /** - * The GA tracking ID + * The GA tracking ID. * @var string */ public $trackingId = null; @@ -53,13 +53,13 @@ class GATracking extends Widget public $debugTrace = false; /** - * Plugins list + * Plugins list. * @var array */ public $plugins = []; /** - * GA script filename + * GA script filename. * @var string */ private $_trackingFilename = 'analytics.js'; @@ -101,11 +101,11 @@ public function init() 'trackingFilename' => $this->_trackingFilename, 'trackingDebugTraceInit' => $this->_trackingDebugTraceInit, 'fields' => [ - 'anonymizeIp' => $this->anonymizeIp + 'anonymizeIp' => $this->anonymizeIp, // :TODO: Add more params ], // :TODO: Add availability to configure events - 'plugins' => $this->plugins + 'plugins' => $this->plugins, ]; } diff --git a/src/widgets/views/tracking.php b/src/widgets/views/tracking.php index 326c2a5..35e5de8 100644 --- a/src/widgets/views/tracking.php +++ b/src/widgets/views/tracking.php @@ -1,6 +1,6 @@ "; }