Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

renoki-co/laravel-firebase-analytics

Repository files navigation

Laravel Firebase Analytics

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published