Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc5ae02
commit 8976b50
Showing
14 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# How to Contribute | ||
|
||
We'd love for you to help out. Read the contribution guidelines [here](http://docs.nailsapp.co.uk/contribute). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: 2 | ||
updates: | ||
|
||
# Maintain dependencies for Composer | ||
- package-ecosystem: "composer" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
reviewers: | ||
- "hellopablo" | ||
labels: | ||
- "dependencies" | ||
- "php" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: build_and_test | ||
on: [ push ] | ||
jobs: | ||
test: | ||
name: build_and_test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 7.3 | ||
|
||
- name: Cache Composer dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
|
||
- name: Install Composer dependencies | ||
run: composer install | ||
|
||
- name: Run tests | ||
run: composer test | ||
env: | ||
PRIVATE_KEY: 123abc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
parameters: | ||
level: 0 | ||
paths: | ||
- ../src | ||
- ../tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2021 Shed Collective Ltd hello@shedcollective.org | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Analytics Module for Nails | ||
|
||
![license](https://img.shields.io/badge/license-MIT-green.svg) | ||
[![tests](https://github.com/nails/module-analytics/actions/workflows/build_and_test.yml/badge.svg )](https://github.com/nails/module-analytics/actions) | ||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nails/module-analytics/badges/quality-score.png)](https://scrutinizer-ci.com/g/nails/module-analytics) | ||
|
||
This module provides a unified API for loading, configuring, and using analytic platforms. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "nails/module-analytics", | ||
"keywords": [], | ||
"homepage": "http://nailsapp.co.uk/modules/analytics", | ||
"description": "This module provides a unified API for loading, configuring, and using analytic platforms.", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Pablo de la Pena", | ||
"email": "p@nailsapp.co.uk", | ||
"homepage": "http://nailsapp.co.uk", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"email": "hello@nailsapp.co.uk" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require": { | ||
"nails\/common": "dev-develop" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "9.*", | ||
"phpstan/phpstan": "0.*" | ||
}, | ||
"scripts": { | ||
"test": "./vendor/bin/phpunit", | ||
"analyse": "./vendor/bin/phpstan analyse -c .phpstan/config.neon" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Nails\\Analytics\\": "src\/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Test\\Analytics\\": "tests\/" | ||
} | ||
}, | ||
"extra": { | ||
"nails": { | ||
"moduleName": "analytics", | ||
"type": "module", | ||
"namespace": "Nails\\Analytics\\", | ||
"data": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<phpunit bootstrap="tests/bootstrap.php"> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
use Nails\Analytics\Service; | ||
|
||
return [ | ||
'services' => [ | ||
'Drivers' => function (): Service\Drivers { | ||
if (class_exists('\App\Analytics\Service\Drivers')) { | ||
return new \App\Analytics\Service\Drivers(); | ||
} else { | ||
return new Service\Drivers(); | ||
} | ||
}, | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Nails\Analytics; | ||
|
||
/** | ||
* Class Constants | ||
* | ||
* @package Nails\Analytics | ||
*/ | ||
class Constants | ||
{ | ||
/** | ||
* The slug for this module | ||
* | ||
* @var string | ||
*/ | ||
const MODULE_SLUG = 'nails/module-analytics'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace Nails\Analytics\Event\Listener\System; | ||
|
||
use Nails\Analytics\Constants; | ||
use Nails\Common\Events; | ||
use Nails\Common\Events\Subscription; | ||
use Nails\Common\Exception\NailsException; | ||
use Nails\Factory; | ||
use ReflectionException; | ||
|
||
/** | ||
* Class Ready | ||
* | ||
* @package Nails\Analytics\Event\Listener\System | ||
*/ | ||
class Ready extends Subscription | ||
{ | ||
/** | ||
* Ready constructor. | ||
* | ||
* @throws NailsException | ||
* @throws ReflectionException | ||
*/ | ||
public function __construct() | ||
{ | ||
$this | ||
->setEvent(Events::SYSTEM_READY) | ||
->setNamespace(Events::getEventNamespace()) | ||
->setCallback([$this, 'execute']); | ||
} | ||
|
||
// -------------------------------------------------------------------------- | ||
|
||
public function execute(): void | ||
{ | ||
/** @var \Nails\Analytics\Service\Drivers $oDrivers */ | ||
$oDrivers = Factory::service('Drivers', Constants::MODULE_SLUG); | ||
foreach ($oDrivers->getAll() as $oDriver) { | ||
/** @var \Nails\Analytics\Interfaces\Driver $oInstance */ | ||
$oInstance = $oDrivers->getInstance($oDriver); | ||
$oInstance->boot(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Nails\Analytics\Interfaces; | ||
|
||
interface Driver | ||
{ | ||
public function boot(): self; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Nails\Analytics\Service; | ||
|
||
use Nails\Analytics\Constants; | ||
use Nails\Analytics\Interfaces\Driver; | ||
use Nails\Common\Model\BaseDriver; | ||
|
||
/** | ||
* Class Drivers | ||
* | ||
* @package Nails\Analytics\Service | ||
*/ | ||
class Drivers extends BaseDriver | ||
{ | ||
protected $sModule = Constants::MODULE_SLUG; | ||
protected $sMustImplement = Driver::class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
require 'vendor/autoload.php'; |