renoki-co / laravel-firebase-analytics
Laravel Firebase Analytics adds blade directives to initialize, log events and set user properties for Firebase Analytics.
Fund package maintenance!
renoki-co
Installs: 5 021
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- laravel/framework: ^6.18.28|^7.22.1|^8.0
Requires (Dev)
- laravel/legacy-factories: ^1.0
- orchestra/database: ^6.0
- orchestra/testbench: ^6.0
This package is auto-updated.
Last update: 2020-12-05 13:39:30 UTC
README
Laravel Firebase Analytics adds blade directives to initialize, log events and set user properties for Firebase Analytics.
🤝 Supporting
Renoki Co. on GitHub aims on bringing a lot of open source projects and helpful projects to the world. Developing and maintaining projects everyday is a harsh work and tho, we love it.
If you are using your application in your day-to-day job, on presentation demos, hobby projects or even school projects, spread some kind words about our work or sponsor our work. Kind words will touch our chakras and vibe, while the sponsorships will keep the open source projects alive.
🚀 Installation
You can install the package via composer:
composer require renoki-co/laravel-firebase-analytics
🙌 Usage
Initialize in your <body>
tag using the @initializeFirebaseAnalytics
directive, passing the version of Firebase JS scripts and the Firebase configuration parameters:
<body> @initializeFirebaseAnalytics([ 'version' => '7.15.5', 'config' => [ 'apiKey' => 'some-key', 'authDomain' => 'firebaseapp', ... ], ]) ... </body>
Afterwards, you can trigger events as stated in Firebase Analytics docs:
<body> @initializeFirebaseAnalytics([ 'version' => '7.15.5', 'config' => [ 'apiKey' => 'some-key', 'authDomain' => 'firebaseapp', ... ], ]) @if ($loginSuccessful) @firebaseAnalyticsEvent([ 'name' => 'login', 'parameters' => [ 'method' => 'email', ], ]) @endif </body>
Or for logged in users or sessions, you can set default user properties:
<body> @initializeFirebaseAnalytics([ 'version' => '7.15.5', 'config' => [ 'apiKey' => 'some-key', 'authDomain' => 'firebaseapp', ... ], ]) @auth @firebaseAnalyticsUserProperties([ 'name' => auth()->user()->name, 'age' => auth()->user()->age, ]) @endauth </body>
More details about the usage can be found here:
- https://firebase.google.com/docs/analytics/get-started
- https://firebase.google.com/docs/analytics/events
- https://firebase.google.com/docs/analytics/user-properties
🐛 Testing
vendor/bin/phpunit
🤝 Contributing
Please see CONTRIBUTING for details.
🔒 Security
If you discover any security related issues, please email alex@renoki.org instead of using the issue tracker.