diff --git a/.travis.yml b/.travis.yml index 2ff3f83..8cf2700 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,18 +3,18 @@ language: php php: - 7.0 - 7.1 + - 7.2 before_script: - travis_retry composer self-update - travis_retry composer install --no-interaction --prefer-source --dev script: - - ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml + - mkdir -p ./build/logs + - ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml -after_script: - - php vendor/bin/coveralls - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml +after_success: + - travis_retry php vendor/bin/php-coveralls -v notifications: webhooks: diff --git a/CHANGELOG.md b/CHANGELOG.md index f05fdd7..807e2b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). (This is already detected in subscription update.) - Filter any incoming web-hook events that are in test mode. +## [0.7.4] - 7 Jan 2018 +### Added +- `Mixpanel::xxx()` facade. +- `thanks` package as dev-dependency, as well as pretty phpunit printer package. + ## [0.7.3] - 5 Nov 2017 ### Added - initial integration tests. diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..0a9c9a7 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# 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 hello@genealabs.com. The project team will review and investigate all complaints, and will respond in a way that it deems 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 index a447979..8eb4c7e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,35 @@ -# Contributing -## Coding Standards -- PSR-1/PSR-2 +# How to contribute +We welcome everyone to submit pull requests with: +- fixes for issues +- change suggestions +- updateing of documentation + +However, not every pull request will automatically be accepted. I will review each carefully to make sure it is in line with + the direction I want the package to continue in. This might mean that some pull requests are not accepted, or might stay + unmerged until a place for them can be determined. + +## Testing +- [ ] After making your changes, make sure the tests still pass. +- [ ] When adding new functionality, also add new tests. +- [ ] When fixing errors write and satisfy new unit tests that replicate the issue. +- [ ] Make sure there are no build errors on our CI server (https://ci.genealabs.com/build-status/view/11) +- [ ] All code must past PHPCS and PHPMD PSR2 validation. + +## Submitting changes +When submitting a pull request, it is important to make sure to complete the following: +- [ ] Add a descriptive header that explains in a single sentence what problem the PR solves. +- [ ] Add a detailed description with animated screen-grab GIFs visualizing how it works. +- [ ] Explain why you think it should be implemented one way vs. another, highlight performance improvements, etc. + +## Coding conventions +Start reading our code and you'll get the hang of it. We optimize for readability: +- indent using four spaces (soft tabs) +- use Blade for all views +- avoid logic in views, put it in controllers or service classes +- ALWAYS put spaces after list items and method parameters (`[1, 2, 3]`, not `[1,2,3]`), around operators (`x += 1`, not `x+=1`), and around hash arrows. +- this is open source software. Consider the people who will read your code, and make it look nice for them. It's sort of like driving a car: Perhaps you love doing donuts when you're alone, but with passengers the goal is to make the ride as smooth as possible. +- emphasis readability of code over patterns to reduce mental debt +- always add an empty line around structures (if statements, loops, etc.) + +Thanks! +Mike Bronner, GeneaLabs diff --git a/README.md b/README.md index badfec7..e13ac43 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # MixPanel for Laravel 5 [![Join the chat at https://gitter.im/GeneaLabs/laravel-mixpanel](https://badges.gitter.im/GeneaLabs/laravel-mixpanel.svg)](https://gitter.im/GeneaLabs/laravel-mixpanel?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Travis](https://img.shields.io/travis/GeneaLabs/laravel-mixpanel.svg)](https://travis-ci.org/GeneaLabs/laravel-mixpanel) -[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/12e6aa84-a68b-4cd3-a8ca-10d12b11cca6.svg)](https://insight.sensiolabs.com/projects/12e6aa84-a68b-4cd3-a8ca-10d12b11cca6) [![Scrutinizer](https://img.shields.io/scrutinizer/g/GeneaLabs/laravel-mixpanel.svg)](https://scrutinizer-ci.com/g/GeneaLabs/laravel-mixpanel) [![Coveralls](https://img.shields.io/coveralls/GeneaLabs/laravel-mixpanel.svg)](https://coveralls.io/github/GeneaLabs/laravel-mixpanel) [![GitHub (pre-)release](https://img.shields.io/github/release/GeneaLabs/laravel-mixpanel/all.svg)](https://github.com/GeneaLabs/laravel-mixpanel) @@ -76,52 +75,6 @@ MIXPANEL_TOKEN=xxxxxxxxxxxxxxxxxxxxxx ### Page Views - Page view tracking has been removed in favor of Mixpanels in-built Autotrack functionality, which tracks all page views. To turn it on, visit your Mixpanel dashboard, click *Applications > Autotrack > Web > etc.* and enable Autotracking. -## Usage -### PHP Events - -### Stripe Web-Hook -If you wish to take advantage of the Stripe web-hook and track revenue per user, - you should install Cashier: https://www.laravel.com/docs/5.5/billing - -Once that has been completed, exempt the web-hook endpoint from CSRF-validation - in `/app/Http/Middleware/VerifyCsrfToken.php`: -```php - protected $except = [ - 'genealabs/laravel-mixpanel/stripe', - ]; -``` - -The only other step remaining is to register the web-hook with Stripe: - Log into your Stripe account: https://dashboard.stripe.com/dashboard, and open - your account settings' webhook tab: - - Enter your MixPanel web-hook URL, similar to the following: `http:///genealabs/laravel-mixpanel/stripe`: - ![screen shot 2015-05-31 at 1 35 01 pm](https://cloud.githubusercontent.com/assets/1791050/7903765/53ba6fe4-079b-11e5-9f92-a588bd81641d.png) - - Be sure to select "Live" if you are actually running live (otherwise put into test mode and update when you go live). - Also, choose "Send me all events" to make sure Laravel Mixpanel can make full use of the Stripe data. - -### JavaScript Events & Auto-Track -#### Blade Template (Recommended) -First publish the necessary assets: -```sh -php artisan mixpanel:publish --assets -``` - -Then add the following to the head section of your layout template (already does - the init call for you, using the token from your .env file): -```blade -@include('genealabs-laravel-mixpanel::partials.mixpanel') -``` - -#### Laravel Elixir -Add the following lines to your `/resources/js/app.js` (or equivalent), and - don't forget to replace `YOUR_MIXPANEL_TOKEN` with your actual token: -```js -require('./../../../public/genealabs-laravel-mixpanel/js/mixpanel.js'); -mixpanel.init("YOUR_MIXPANEL_TOKEN"); -``` - ## Usage MixPanel is loaded into the IoC as a singleton. This means you don't have to manually call $mixPanel::getInstance() as described in the MixPanel docs. This is already done for you in the ServiceProvider. @@ -154,7 +107,8 @@ class MyClass If DI is impractical in certain situations, you can also manually retrieve it from the IoC: ```php -$mixPanel = app('mixpanel'); +$mixPanel = app('mixpanel'); // using app helper +$mixPanel = Mixpanel::getFacadeRoot(); // using facade ``` After that you can make the usual calls to the MixPanel API: @@ -165,6 +119,49 @@ After that you can make the usual calls to the MixPanel API: And so on ... + ### Stripe Web-Hook + If you wish to take advantage of the Stripe web-hook and track revenue per user, + you should install Cashier: https://www.laravel.com/docs/5.5/billing + + Once that has been completed, exempt the web-hook endpoint from CSRF-validation + in `/app/Http/Middleware/VerifyCsrfToken.php`: + ```php + protected $except = [ + 'genealabs/laravel-mixpanel/stripe', + ]; + ``` + + The only other step remaining is to register the web-hook with Stripe: + Log into your Stripe account: https://dashboard.stripe.com/dashboard, and open + your account settings' webhook tab: + + Enter your MixPanel web-hook URL, similar to the following: `http:///genealabs/laravel-mixpanel/stripe`: + ![screen shot 2015-05-31 at 1 35 01 pm](https://cloud.githubusercontent.com/assets/1791050/7903765/53ba6fe4-079b-11e5-9f92-a588bd81641d.png) + + Be sure to select "Live" if you are actually running live (otherwise put into test mode and update when you go live). + Also, choose "Send me all events" to make sure Laravel Mixpanel can make full use of the Stripe data. + + ### JavaScript Events & Auto-Track + #### Blade Template (Recommended) + First publish the necessary assets: + ```sh + php artisan mixpanel:publish --assets + ``` + + Then add the following to the head section of your layout template (already does + the init call for you, using the token from your .env file): + ```blade + @include('genealabs-laravel-mixpanel::partials.mixpanel') + ``` + + #### Laravel Elixir + Add the following lines to your `/resources/js/app.js` (or equivalent), and + don't forget to replace `YOUR_MIXPANEL_TOKEN` with your actual token: + ```js + require('./../../../public/genealabs-laravel-mixpanel/js/mixpanel.js'); + mixpanel.init("YOUR_MIXPANEL_TOKEN"); + ``` + ### Laravel Integration Out of the box it will record the common events anyone would want to track. Also, if the default `$user->name` field is used that comes with Laravel, it will split up the name and use the last word as the last name, and everything prior for @@ -340,3 +337,36 @@ Out of the box it will record the following Stripe events in MixPanel for you: - Churned: - Plan When Churned: ``` + +# The Fine Print +## Commitment to Quality +During package development I try as best as possible to embrace good design and +development practices to try to ensure that this package is as good as it can +be. My checklist for package development includes: + +- ✅ Achieve as close to 100% code coverage as possible using unit tests. +- ✅ Eliminate any issues identified by SensioLabs Insight and Scrutinizer. +- ✅ Be fully PSR1, PSR2, and PSR4 compliant. +- ✅ Include comprehensive documentation in README.md. +- ✅ Provide an up-to-date CHANGELOG.md which adheres to the format outlined + at . +- ✅ Have no PHPMD or PHPCS warnings throughout all code. + +## Contributing +Please observe and respect all aspects of the included Code of Conduct . + +### Reporting Issues +When reporting issues, please fill out the included template as completely as +possible. Incomplete issues may be ignored or closed if there is not enough +information included to be actionable. + +### Submitting Pull Requests +Please review the Contribution Guidelines . +Only PRs that meet all criterium will be accepted. + +## ❤️ Open-Source Software - Give ⭐️ +We have included the awesome `symfony/thanks` composer package as a dev +dependency. Let your OS package maintainers know you appreciate them by starring +the packages you use. Simply run composer thanks after installing this package. +(And not to worry, since it's a dev-dependency it won't be installed in your +live environment.) diff --git a/composer.json b/composer.json index 470b014..400ce4d 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,10 @@ "mockery/mockery": "0.9.*", "phpmd/phpmd": "^2.6", "phpunit/phpunit": "5.7.*", - "satooshi/php-coveralls" : "dev-master@dev", - "sebastian/phpcpd": "*" + "sebastian/phpcpd": "*", + "symfony/thanks": "^1.0", + "codedungeon/phpunit-result-printer": "^0.5.0", + "php-coveralls/php-coveralls": "^2.0" }, "autoload-dev": { "psr-4": { @@ -46,7 +48,10 @@ "laravel": { "providers": [ "GeneaLabs\\LaravelMixpanel\\Providers\\Service" - ] + ], + "alias": { + "Mixpanel": "GeneaLabs\\LaravelMixpanel\\Facades\\Mixpanel" + } } } } diff --git a/phpunit.xml b/phpunit.xml index d7b48a9..e927f83 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,14 +1,16 @@ - diff --git a/src/Facades/Mixpanel.php b/src/Facades/Mixpanel.php new file mode 100644 index 0000000..4ca0063 --- /dev/null +++ b/src/Facades/Mixpanel.php @@ -0,0 +1,11 @@ +assertTrue(true); - } -} diff --git a/tests/Unit/Facades/MixpanelTest.php b/tests/Unit/Facades/MixpanelTest.php new file mode 100644 index 0000000..a4de88c --- /dev/null +++ b/tests/Unit/Facades/MixpanelTest.php @@ -0,0 +1,18 @@ +assertInstanceOf(LaravelMixpanel::class, $instance); + } +}