Skip to content

Commit

Permalink
Merge pull request #55 from tighten/drift/ga4-update
Browse files Browse the repository at this point in the history
Update to GA4
  • Loading branch information
driftingly authored Mar 14, 2024
2 parents 6563d4f + 2a0db1a commit 3445d73
Show file tree
Hide file tree
Showing 33 changed files with 413 additions and 781 deletions.
38 changes: 16 additions & 22 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,27 @@ on:

jobs:
tests:
runs-on: ubuntu-latest
runs-on: ${{matrix.os}}
strategy:
matrix:
php: [8.0, 8.1]
os: [ubuntu-latest]
php: [8.1, 8.2]
laravel: [10.*, 11.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- php: 8.0
laravel: 8.*
testbench: 7.*
phpunit: 9.*
- php: 8.1
laravel: 8.*
testbench: 7.*
phpunit: 9.*
- php: 8.0
laravel: 9.*
testbench: 7.*
phpunit: 9.*
- php: 8.1
laravel: 9.*
testbench: 7.*
phpunit: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 11.*
php: 8.1

name: ${{ matrix.os }} - PHP ${{ matrix.php }}
name: PHP ${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -45,13 +39,13 @@ jobs:
- name: Install dependencies
run: |
composer config "http-basic.nova.laravel.com" "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_LICENSE_KEY }}"
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress --no-suggest
- name: Run PHP tests
run: vendor/bin/phpunit
env:
ANALYTICS_VIEW_ID: "${{ secrets.ANALYTICS_VIEW_ID }}"
ANALYTICS_PROPERTY_ID: "${{ secrets.ANALYTICS_PROPERTY_ID }}"
ANALYTICS_PROJECT_ID: "${{ secrets.ANALYTICS_PROJECT_ID }}"
ANALYTICS_PRIVATE_KEY_ID: "${{ secrets.ANALYTICS_PRIVATE_KEY_ID }}"
ANALYTICS_PRIVATE_KEY: "${{ secrets.ANALYTICS_PRIVATE_KEY }}"
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ composer.phar
composer.lock
phpunit.xml
mix-manifest.json
.phpunit.result.cache
.phpunit.result.cache
.phpunit.cache
.env
.env.testing
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@ yourapp/storage/app/analytics/service-account-credentials.json
Also add this to the `.env` for your Nova app:

```ini
ANALYTICS_VIEW_ID=
ANALYTICS_PROPERTY_ID=
```

## Upgrading to 4.0

Version 4.0 uses the new Google Analytics 4 Data API.

- Upgrades `spatie/laravel-analytics` to `v5.2`
- Drops support for PHP 8.0
- Drops support for Laravel 9
- Removes `FourteenDayActiveUsersMetric` metric which is not available in GA4

The required environment variable `ANALYTICS_VIEW_ID` has been renamed to `ANALYTICS_PROPERTY_ID` to match Google's usage.

## Usage
You must register the cards you want to display with Nova. This is typically done in the `cards` method of the `Main`
dashboard.
Expand All @@ -45,7 +56,6 @@ public function cards()
new \Tightenco\NovaGoogleAnalytics\ReferrersList,
new \Tightenco\NovaGoogleAnalytics\OneDayActiveUsersMetric,
new \Tightenco\NovaGoogleAnalytics\SevenDayActiveUsersMetric,
new \Tightenco\NovaGoogleAnalytics\FourteenDayActiveUsersMetric,
new \Tightenco\NovaGoogleAnalytics\TwentyEightDayActiveUsersMetric,
new \Tightenco\NovaGoogleAnalytics\SessionsMetric,
new \Tightenco\NovaGoogleAnalytics\SessionDurationMetric,
Expand All @@ -55,6 +65,21 @@ public function cards()
}
```

Register the tool with Nova in the `tools` method of your `NovaServiceProvider`:

```php
// in app/Providers/NovaServiceProvider.php

// ...

public function tools()
{
return [
new Tightenco\NovaGoogleAnalytics\Tool(),
];
}
```

## Features

#### View the Visitors and Pageview Metrics
Expand Down Expand Up @@ -88,7 +113,7 @@ cp .env.example .env.testing
Make sure, in that file, to define the following variables to run all tests:

```
ANALYTICS_VIEW_ID
ANALYTICS_PROPERTY_ID
ANALYTICS_PROJECT_ID
ANALYTICS_PRIVATE_KEY_ID
ANALYTICS_PRIVATE_KEY
Expand All @@ -115,7 +140,7 @@ If you discover any security related issues, please email [email protected] instea

## Support us

Tighten is a web development firm that works in Laravel, Vue, and React. You can learn more about us on our [web site](https://tighten.co/)
Tighten is a web development firm that works in Laravel, Vue, and React. You can learn more about us on our [web site](https://tighten.com/)

## License

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
}
],
"require": {
"php": "^8.0|^8.1",
"spatie/laravel-analytics": "^4.1"
"php": "^8.1",
"spatie/laravel-analytics": "^5.2"
},
"require-dev": {
"laravel/nova": "^4.0",
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.5",
"orchestra/testbench": "^8.21 | ^9.0",
"phpunit/phpunit": "^10.5",
"squizlabs/php_codesniffer": "^3.5",
"tightenco/tlint": "^6.2"
"tightenco/tlint": "^9.3"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 3445d73

Please sign in to comment.