Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 11 support #2

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/php-cs-fixer.yml

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
run: ./vendor/bin/phpstan --error-format=github
25 changes: 25 additions & 0 deletions .github/workflows/pint.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
39 changes: 0 additions & 39 deletions .php_cs.dist.php

This file was deleted.

19 changes: 0 additions & 19 deletions CHANGELOG.md

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
6 changes: 2 additions & 4 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
includes:
- ./vendor/nunomaduro/larastan/extension.neon
- ./vendor/larastan/larastan/extension.neon

parameters:

paths:
- src

# The level 8 is the highest level
level: 8

ignoreErrors:

excludes_analyse:

checkMissingIterableValueType: false

checkGenericClassInNonGenericObjectType: false
checkGenericClassInNonGenericObjectType: false
1 change: 1 addition & 0 deletions src/Http/Middleware/TagManagerMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class TagManagerMiddleware
{
private TagManager $tagManager;

private Session $session;

public function __construct(TagManager $tagManager, Session $session)
Expand Down
28 changes: 14 additions & 14 deletions src/MeasurementProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion src/TagManagerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
1 change: 1 addition & 0 deletions src/View/Components/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
class Body extends Component
{
public string $id;

public bool $isEnabled;

public function __construct()
Expand Down
3 changes: 3 additions & 0 deletions src/View/Components/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down