diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml deleted file mode 100644 index aad63b0..0000000 --- a/.github/workflows/php-cs-fixer.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Check & fix styling - -on: [ push ] - -jobs: - php-cs-fixer: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - ref: ${{ github.head_ref }} - - - name: Run PHP CS Fixer - uses: docker://oskarstark/php-cs-fixer-ga - with: - args: --config=.php_cs.dist.php --allow-risky=yes - - - name: Commit changes - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: Fix styling \ No newline at end of file diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 3c8743a..b55103b 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -1,17 +1,17 @@ -name: PHPStan +name: Run PHPStan on: push: - paths: - - '**.php' - - 'phpstan.neon.dist' + branches: [ master ] + pull_request: + branches: [ master ] jobs: phpstan: name: phpstan runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -20,7 +20,7 @@ jobs: coverage: none - name: Install composer dependencies - uses: ramsey/composer-install@v1 + uses: ramsey/composer-install@v2 - name: Run PHPStan - run: ./vendor/bin/phpstan --error-format=github \ No newline at end of file + run: ./vendor/bin/phpstan --error-format=github diff --git a/.github/workflows/pint.yml b/.github/workflows/pint.yml new file mode 100644 index 0000000..0bf5c75 --- /dev/null +++ b/.github/workflows/pint.yml @@ -0,0 +1,25 @@ +name: Run Pint + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + pint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Run Pint + uses: aglipanci/laravel-pint-action@2.3.0 + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Fix styling diff --git a/.php_cs.dist.php b/.php_cs.dist.php deleted file mode 100644 index 0a4a56d..0000000 --- a/.php_cs.dist.php +++ /dev/null @@ -1,39 +0,0 @@ -in([ - __DIR__.'/src', - ]) - ->name('*.php') - ->notName('*.blade.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new PhpCsFixer\Config()) - ->setRules([ - '@PSR12' => true, - 'array_syntax' => ['syntax' => 'short'], - 'ordered_imports' => ['sort_algorithm' => 'alpha'], - 'no_unused_imports' => true, - 'not_operator_with_successor_space' => true, - 'trailing_comma_in_multiline' => true, - 'phpdoc_scalar' => true, - 'unary_operator_spaces' => true, - 'binary_operator_spaces' => true, - 'blank_line_before_statement' => [ - 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], - ], - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_var_without_name' => true, - 'class_attributes_separation' => [ - 'elements' => [ - 'method' => 'one', - ], - ], - 'method_argument_space' => [ - 'on_multiline' => 'ensure_fully_multiline', - 'keep_multiple_spaces_after_comma' => true, - ], - 'single_trait_insert_per_statement' => true, - ]) - ->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 2e6750d..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,19 +0,0 @@ -# Changelog - -All notable changes to `laravel-tagmanager` will be documented in this file. - -## 1.3 - 2022-01-27 - -- Ecommerce events added - -## 1.2 - 2022-01-27 - -- Laravel 9 support added - -## 1.1 - 2021-12-23 - -- User-ID Middleware added - -## 1.0 - 2021-12-22 - -- Initial release diff --git a/README.md b/README.md index 746bbb3..d2dfba0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ [![Latest Stable Version](https://poser.pugx.org/label84/laravel-tagmanager/v/stable?style=flat-square)](https://packagist.org/packages/label84/laravel-tagmanager) [![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -[![Quality Score](https://img.shields.io/scrutinizer/g/label84/laravel-tagmanager.svg?style=flat-square)](https://scrutinizer-ci.com/g/label84/laravel-tagmanager) [![Total Downloads](https://img.shields.io/packagist/dt/label84/laravel-tagmanager.svg?style=flat-square)](https://packagist.org/packages/label84/laravel-tagmanager) Easier way to add Google Tag Manager to your Laravel application. Including support for User-ID, E-commerce and Server Side Events (Measurement Protocol). @@ -25,8 +24,8 @@ Easier way to add Google Tag Manager to your Laravel application. Including supp | Version | Release | |---------|---------| +| 11.x | 1.3 | | 10.x | 1.3 | -| 9.x | 1.3 | ## Installation diff --git a/composer.json b/composer.json index 883231a..066eca0 100644 --- a/composer.json +++ b/composer.json @@ -10,11 +10,11 @@ } ], "require": { - "illuminate/support": "^9.0|^10.0" + "illuminate/support": "^10.0|^11.0" }, "require-dev": { - "orchestra/testbench": "^7.0|^8.0", - "nunomaduro/larastan": "^2.0" + "orchestra/testbench": "^8.0|^9.0", + "larastan/larastan": "^2.0" }, "extra": { "laravel": { diff --git a/config/config.php b/config/config.php index 9c3bcdb..78e4c00 100644 --- a/config/config.php +++ b/config/config.php @@ -53,5 +53,5 @@ /** * The session key used to store the measurement protocol client id. */ - 'measurement_protocol_client_id_session_key' => 'measurement-protocol-client-id' + 'measurement_protocol_client_id_session_key' => 'measurement-protocol-client-id', ]; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 7297446..731ff22 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -1,12 +1,11 @@ includes: - - ./vendor/nunomaduro/larastan/extension.neon + - ./vendor/larastan/larastan/extension.neon parameters: paths: - src - # The level 8 is the highest level level: 8 ignoreErrors: @@ -14,5 +13,4 @@ parameters: excludes_analyse: checkMissingIterableValueType: false - - checkGenericClassInNonGenericObjectType: false \ No newline at end of file + checkGenericClassInNonGenericObjectType: false diff --git a/src/Http/Middleware/TagManagerMiddleware.php b/src/Http/Middleware/TagManagerMiddleware.php index 334f202..08392aa 100644 --- a/src/Http/Middleware/TagManagerMiddleware.php +++ b/src/Http/Middleware/TagManagerMiddleware.php @@ -10,6 +10,7 @@ class TagManagerMiddleware { private TagManager $tagManager; + private Session $session; public function __construct(TagManager $tagManager, Session $session) diff --git a/src/MeasurementProtocol.php b/src/MeasurementProtocol.php index 6515479..bc1c02a 100644 --- a/src/MeasurementProtocol.php +++ b/src/MeasurementProtocol.php @@ -18,7 +18,7 @@ public function __construct() $this->clientId = session(config('tagmanager.measurement_protocol_client_id_session_key'), ''); } - public function event(string $name, array $params = null): array + public function event(string $name, ?array $params = null): array { $event = [ 'name' => $name, @@ -37,19 +37,19 @@ public function event(string $name, array $params = null): array $response = Http::withHeaders([ 'content-type' => 'application/json', ]) - ->withQueryParameters([ - 'measurement_id' => config('tagmanager.measurement_id'), - 'api_secret' => config('tagmanager.measurement_protocol_api_secret'), - ]) - ->post($this->route(), array_merge( - [ - 'client_id' => $this->clientId, - 'events' => [$event], - ], - $this->getUserIdArray(), - )); - - if($this->isDebugEnabled) { + ->withQueryParameters([ + 'measurement_id' => config('tagmanager.measurement_id'), + 'api_secret' => config('tagmanager.measurement_protocol_api_secret'), + ]) + ->post($this->route(), array_merge( + [ + 'client_id' => $this->clientId, + 'events' => [$event], + ], + $this->getUserIdArray(), + )); + + if ($this->isDebugEnabled) { return $response->json(); } diff --git a/src/TagManagerServiceProvider.php b/src/TagManagerServiceProvider.php index 4251c45..8f93e97 100644 --- a/src/TagManagerServiceProvider.php +++ b/src/TagManagerServiceProvider.php @@ -29,7 +29,7 @@ public function boot(): void { if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__.'/../config/config.php' => config_path('tagmanager.php'), + __DIR__.'/../config/config.php' => config_path('tagmanager.php'), ], 'config'); } diff --git a/src/View/Components/Body.php b/src/View/Components/Body.php index ffb9a6d..e29c3ab 100644 --- a/src/View/Components/Body.php +++ b/src/View/Components/Body.php @@ -8,6 +8,7 @@ class Body extends Component { public string $id; + public bool $isEnabled; public function __construct() diff --git a/src/View/Components/Head.php b/src/View/Components/Head.php index c99d262..766e59d 100644 --- a/src/View/Components/Head.php +++ b/src/View/Components/Head.php @@ -11,8 +11,11 @@ class Head extends Component { public TagManager $tagManager; + public Session $session; + public string $id; + public bool $isEnabled; public function __construct(TagManager $tagManager, Session $session)