renoki-co/laravel-firebase-analytics

This package is abandoned and no longer maintained. No replacement package was suggested.

Laravel Firebase Analytics adds blade directives to initialize, log events and set user properties for Firebase Analytics.

1.2.0 2020-09-06 18:50 UTC

This package is auto-updated.

Last update: 2020-12-05 13:39:30 UTC


README

CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

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:

🐛 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.

🎉 Credits