Best laravel framework open-source packages.

Bqanalytic

Laravel package to use analytic data imported to Big Query from Firebase Analytic
Updated 4 years ago

BQAnalytic

Latest Version on Packagist

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require rezuankassim/bqanalytic

Optionally you can publish the configuration file

$ php artisan vendor:publish RezuanKassim/BQAnalytic/BQAnalyticServiceProvider

Important

In your .env file, make sure you have these value setup

GOOGLE_CLOUD_APPLICATION_CREDENTIALS=path_to_your_credentials_file
GOOGLE_CLOUD_PROJECT_ID=your_google_cloud_project_id
BQANALYTIC_BQ_TABLE_NAME=your_bigquery_datasets_name
GOOGLE_CLOUD_APPLICATION_NAME=your_google_cloud_application_name

Then

$ php artisan migrate

After that

$ php artisan db:seed --class=AnalyticSeeder

If you an error popup when running the command above, you need to publish the vendor file.

Usage

Include this code into your user entity

use RezuanKassim\BQAnalytic\Traits\hasAnalyticPreferences;

....

class User extends Authenticatable
{
    use Notifiable, hasAnalyticPreferences;

Then run php artisan bqanalytic:export to export big query data into your local database

Note that: php artisan bqanalytic:export can receive two date which is start date and end date behind it like php artisan bqanalytic:export 20200420 20200420

Next, in your controller

use RezuanKassim\BQAnalytic\BQAnalytic;

...

$results = (new BQAnalytic(auth()->user(), Carbon::createFromFormat('d/m/Y', $range[0])->format('Ymd'), Carbon::createFromFormat('d/m/Y', $range[1])->format('Ymd')))->getAllAnalytics()[config('bqanalytic.google.accounts')[0]['name']];

Optionally you can enable multiple project by

BQANALYTIC_MULTIPLE_PROJECTS=true

setting this variable in your env and publishing the config file

and insert the code below in google => [accounts => [here]]

    [
        'name' => 'YOUR_PROJECT_NAME',
        'google_credential' => "FULL_PATH_TO_YOUR_CREDENTIALS",
        'google_project_id' => 'PROJECT_ID',
        'google_bq_dataset_name' => 'YOUR_DATASET_NAME'
    ]

By version 1.3, you are able to store all the clients in the database if you wish

BQANALYTIC_CLIENT_FROM_DB=true

in .env file

This will use an included RezuanKassim\BQAnalytic\BQClient model to store the clients information

Optionally you also can use own model by including

BQANALYTIC_CLIENT_MODEL=App\Client

in .env file

But remember to include these codes in your client model

use RezuanKassim\BQAnalytic\Traits\hasClientFromDB;

...

class Client extends Model
{
    use hasClientFromDB;

    protected $table = 'bq_clients';

    protected $guarded = ['created_at', 'updated_at', 'id'];

    protected $casts = [
        'status' => 'boolean'
    ];
}

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.