Skip to content

Commit 7ee2336

Browse files
authored
Merge pull request #45 from GeneaLabs/laravel-5.5
Laravel 5.5
2 parents 90030aa + f1191e5 commit 7ee2336

File tree

10 files changed

+210
-73
lines changed

10 files changed

+210
-73
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ language: php
33
php:
44
- 7.0
55
- 7.1
6+
- 7.2
67

78
before_script:
89
- travis_retry composer self-update
910
- travis_retry composer install --no-interaction --prefer-source --dev
1011

1112
script:
12-
- ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml
13+
- mkdir -p ./build/logs
14+
- ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml
1315

14-
after_script:
15-
- php vendor/bin/coveralls
16-
- wget https://scrutinizer-ci.com/ocular.phar
17-
- php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml
16+
after_success:
17+
- travis_retry php vendor/bin/php-coveralls -v
1818

1919
notifications:
2020
webhooks:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1111
(This is already detected in subscription update.)
1212
- Filter any incoming web-hook events that are in test mode.
1313

14+
## [0.7.4] - 7 Jan 2018
15+
### Added
16+
- `Mixpanel::xxx()` facade.
17+
- `thanks` package as dev-dependency, as well as pretty phpunit printer package.
18+
1419
## [0.7.3] - 5 Nov 2017
1520
### Added
1621
- initial integration tests.

CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
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.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
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.
28+
29+
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.
30+
31+
## Scope
32+
33+
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.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. 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.
38+
39+
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.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

CONTRIBUTING.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1-
# Contributing
2-
## Coding Standards
3-
- PSR-1/PSR-2
1+
# How to contribute
2+
We welcome everyone to submit pull requests with:
3+
- fixes for issues
4+
- change suggestions
5+
- updateing of documentation
6+
7+
However, not every pull request will automatically be accepted. I will review each carefully to make sure it is in line with
8+
the direction I want the package to continue in. This might mean that some pull requests are not accepted, or might stay
9+
unmerged until a place for them can be determined.
10+
11+
## Testing
12+
- [ ] After making your changes, make sure the tests still pass.
13+
- [ ] When adding new functionality, also add new tests.
14+
- [ ] When fixing errors write and satisfy new unit tests that replicate the issue.
15+
- [ ] Make sure there are no build errors on our CI server (https://ci.genealabs.com/build-status/view/11)
16+
- [ ] All code must past PHPCS and PHPMD PSR2 validation.
17+
18+
## Submitting changes
19+
When submitting a pull request, it is important to make sure to complete the following:
20+
- [ ] Add a descriptive header that explains in a single sentence what problem the PR solves.
21+
- [ ] Add a detailed description with animated screen-grab GIFs visualizing how it works.
22+
- [ ] Explain why you think it should be implemented one way vs. another, highlight performance improvements, etc.
23+
24+
## Coding conventions
25+
Start reading our code and you'll get the hang of it. We optimize for readability:
26+
- indent using four spaces (soft tabs)
27+
- use Blade for all views
28+
- avoid logic in views, put it in controllers or service classes
29+
- 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.
30+
- 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.
31+
- emphasis readability of code over patterns to reduce mental debt
32+
- always add an empty line around structures (if statements, loops, etc.)
33+
34+
Thanks!
35+
Mike Bronner, GeneaLabs

README.md

Lines changed: 78 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# MixPanel for Laravel 5
22
[![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)
33
[![Travis](https://img.shields.io/travis/GeneaLabs/laravel-mixpanel.svg)](https://travis-ci.org/GeneaLabs/laravel-mixpanel)
4-
[![SensioLabs Insight](https://img.shields.io/sensiolabs/i/12e6aa84-a68b-4cd3-a8ca-10d12b11cca6.svg)](https://insight.sensiolabs.com/projects/12e6aa84-a68b-4cd3-a8ca-10d12b11cca6)
54
[![Scrutinizer](https://img.shields.io/scrutinizer/g/GeneaLabs/laravel-mixpanel.svg)](https://scrutinizer-ci.com/g/GeneaLabs/laravel-mixpanel)
65
[![Coveralls](https://img.shields.io/coveralls/GeneaLabs/laravel-mixpanel.svg)](https://coveralls.io/github/GeneaLabs/laravel-mixpanel)
76
[![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
7675
### Page Views
7776
- 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.
7877

79-
## Usage
80-
### PHP Events
81-
82-
### Stripe Web-Hook
83-
If you wish to take advantage of the Stripe web-hook and track revenue per user,
84-
you should install Cashier: https://www.laravel.com/docs/5.5/billing
85-
86-
Once that has been completed, exempt the web-hook endpoint from CSRF-validation
87-
in `/app/Http/Middleware/VerifyCsrfToken.php`:
88-
```php
89-
protected $except = [
90-
'genealabs/laravel-mixpanel/stripe',
91-
];
92-
```
93-
94-
The only other step remaining is to register the web-hook with Stripe:
95-
Log into your Stripe account: https://dashboard.stripe.com/dashboard, and open
96-
your account settings' webhook tab:
97-
98-
Enter your MixPanel web-hook URL, similar to the following: `http://<your server.com>/genealabs/laravel-mixpanel/stripe`:
99-
![screen shot 2015-05-31 at 1 35 01 pm](https://cloud.githubusercontent.com/assets/1791050/7903765/53ba6fe4-079b-11e5-9f92-a588bd81641d.png)
100-
101-
Be sure to select "Live" if you are actually running live (otherwise put into test mode and update when you go live).
102-
Also, choose "Send me all events" to make sure Laravel Mixpanel can make full use of the Stripe data.
103-
104-
### JavaScript Events & Auto-Track
105-
#### Blade Template (Recommended)
106-
First publish the necessary assets:
107-
```sh
108-
php artisan mixpanel:publish --assets
109-
```
110-
111-
Then add the following to the head section of your layout template (already does
112-
the init call for you, using the token from your .env file):
113-
```blade
114-
@include('genealabs-laravel-mixpanel::partials.mixpanel')
115-
```
116-
117-
#### Laravel Elixir
118-
Add the following lines to your `/resources/js/app.js` (or equivalent), and
119-
don't forget to replace `YOUR_MIXPANEL_TOKEN` with your actual token:
120-
```js
121-
require('./../../../public/genealabs-laravel-mixpanel/js/mixpanel.js');
122-
mixpanel.init("YOUR_MIXPANEL_TOKEN");
123-
```
124-
12578
## Usage
12679
MixPanel is loaded into the IoC as a singleton. This means you don't have to manually call $mixPanel::getInstance() as
12780
described in the MixPanel docs. This is already done for you in the ServiceProvider.
@@ -154,7 +107,8 @@ class MyClass
154107

155108
If DI is impractical in certain situations, you can also manually retrieve it from the IoC:
156109
```php
157-
$mixPanel = app('mixpanel');
110+
$mixPanel = app('mixpanel'); // using app helper
111+
$mixPanel = Mixpanel::getFacadeRoot(); // using facade
158112
```
159113

160114
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:
165119

166120
And so on ...
167121

122+
### Stripe Web-Hook
123+
If you wish to take advantage of the Stripe web-hook and track revenue per user,
124+
you should install Cashier: https://www.laravel.com/docs/5.5/billing
125+
126+
Once that has been completed, exempt the web-hook endpoint from CSRF-validation
127+
in `/app/Http/Middleware/VerifyCsrfToken.php`:
128+
```php
129+
protected $except = [
130+
'genealabs/laravel-mixpanel/stripe',
131+
];
132+
```
133+
134+
The only other step remaining is to register the web-hook with Stripe:
135+
Log into your Stripe account: https://dashboard.stripe.com/dashboard, and open
136+
your account settings' webhook tab:
137+
138+
Enter your MixPanel web-hook URL, similar to the following: `http://<your server.com>/genealabs/laravel-mixpanel/stripe`:
139+
![screen shot 2015-05-31 at 1 35 01 pm](https://cloud.githubusercontent.com/assets/1791050/7903765/53ba6fe4-079b-11e5-9f92-a588bd81641d.png)
140+
141+
Be sure to select "Live" if you are actually running live (otherwise put into test mode and update when you go live).
142+
Also, choose "Send me all events" to make sure Laravel Mixpanel can make full use of the Stripe data.
143+
144+
### JavaScript Events & Auto-Track
145+
#### Blade Template (Recommended)
146+
First publish the necessary assets:
147+
```sh
148+
php artisan mixpanel:publish --assets
149+
```
150+
151+
Then add the following to the head section of your layout template (already does
152+
the init call for you, using the token from your .env file):
153+
```blade
154+
@include('genealabs-laravel-mixpanel::partials.mixpanel')
155+
```
156+
157+
#### Laravel Elixir
158+
Add the following lines to your `/resources/js/app.js` (or equivalent), and
159+
don't forget to replace `YOUR_MIXPANEL_TOKEN` with your actual token:
160+
```js
161+
require('./../../../public/genealabs-laravel-mixpanel/js/mixpanel.js');
162+
mixpanel.init("YOUR_MIXPANEL_TOKEN");
163+
```
164+
168165
### Laravel Integration
169166
Out of the box it will record the common events anyone would want to track. Also, if the default `$user->name` field is
170167
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:
340337
- Churned: <date plan was downgraded>
341338
- Plan When Churned: <plan name prior to downgrading>
342339
```
340+
341+
# The Fine Print
342+
## Commitment to Quality
343+
During package development I try as best as possible to embrace good design and
344+
development practices to try to ensure that this package is as good as it can
345+
be. My checklist for package development includes:
346+
347+
- ✅ Achieve as close to 100% code coverage as possible using unit tests.
348+
- ✅ Eliminate any issues identified by SensioLabs Insight and Scrutinizer.
349+
- ✅ Be fully PSR1, PSR2, and PSR4 compliant.
350+
- ✅ Include comprehensive documentation in README.md.
351+
- ✅ Provide an up-to-date CHANGELOG.md which adheres to the format outlined
352+
at <http://keepachangelog.com>.
353+
- ✅ Have no PHPMD or PHPCS warnings throughout all code.
354+
355+
## Contributing
356+
Please observe and respect all aspects of the included Code of Conduct <https://github.com/GeneaLabs/laravel-model-caching/blob/master/CODE_OF_CONDUCT.md>.
357+
358+
### Reporting Issues
359+
When reporting issues, please fill out the included template as completely as
360+
possible. Incomplete issues may be ignored or closed if there is not enough
361+
information included to be actionable.
362+
363+
### Submitting Pull Requests
364+
Please review the Contribution Guidelines <https://github.com/GeneaLabs/laravel-model-caching/blob/master/CONTRIBUTING.md>.
365+
Only PRs that meet all criterium will be accepted.
366+
367+
## ❤️ Open-Source Software - Give ⭐️
368+
We have included the awesome `symfony/thanks` composer package as a dev
369+
dependency. Let your OS package maintainers know you appreciate them by starring
370+
the packages you use. Simply run composer thanks after installing this package.
371+
(And not to worry, since it's a dev-dependency it won't be installed in your
372+
live environment.)

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
"mockery/mockery": "0.9.*",
3535
"phpmd/phpmd": "^2.6",
3636
"phpunit/phpunit": "5.7.*",
37-
"satooshi/php-coveralls" : "dev-master@dev",
38-
"sebastian/phpcpd": "*"
37+
"sebastian/phpcpd": "*",
38+
"symfony/thanks": "^1.0",
39+
"codedungeon/phpunit-result-printer": "^0.5.0",
40+
"php-coveralls/php-coveralls": "^2.0"
3941
},
4042
"autoload-dev": {
4143
"psr-4": {
@@ -46,7 +48,10 @@
4648
"laravel": {
4749
"providers": [
4850
"GeneaLabs\\LaravelMixpanel\\Providers\\Service"
49-
]
51+
],
52+
"alias": {
53+
"Mixpanel": "GeneaLabs\\LaravelMixpanel\\Facades\\Mixpanel"
54+
}
5055
}
5156
}
5257
}

phpunit.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
2+
<phpunit
3+
backupGlobals="false"
34
backupStaticAttributes="false"
5+
bootstrap="vendor/autoload.php"
46
colors="true"
57
convertErrorsToExceptions="true"
68
convertNoticesToExceptions="true"
79
convertWarningsToExceptions="true"
10+
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
811
processIsolation="false"
912
stopOnFailure="true"
1013
syntaxCheck="false"
11-
bootstrap="vendor/autoload.php"
1214
>
1315
<testsuites>
1416
<testsuite name="Feature">

src/Facades/Mixpanel.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php namespace GeneaLabs\LaravelMixpanel\Facades;
2+
3+
use Illuminate\Support\Facades\Facade;
4+
5+
class Mixpanel extends Facade
6+
{
7+
protected static function getFacadeAccessor() : string
8+
{
9+
return 'mixpanel';
10+
}
11+
}

tests/Unit/ExampleTest.php

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace GeneaLabs\LaravelMixpanel\Tests\Unit\Facades;
2+
3+
use GeneaLabs\LaravelMixpanel\Facades\Mixpanel;
4+
use GeneaLabs\LaravelMixpanel\LaravelMixpanel;
5+
use GeneaLabs\LaravelMixpanel\Tests\UnitTestCase;
6+
7+
/**
8+
* @SuppressWarnings(PHPMD.StaticAccess)
9+
*/
10+
class MixpanelTest extends UnitTestCase
11+
{
12+
public function testFacadeCanBeReferenced()
13+
{
14+
$instance = Mixpanel::getFacadeRoot();
15+
16+
$this->assertInstanceOf(LaravelMixpanel::class, $instance);
17+
}
18+
}

0 commit comments

Comments
 (0)