A MongoDB Analytics Tracking and Parsing Package

dev-master 2020-05-05 14:02 UTC

This package is auto-updated.

Last update: 2020-07-05 14:16:45 UTC


Build Status styleci Scrutinizer Code Quality

Packagist Packagist Packagist

Simple Logging and Viewing for Analytics using MongoDB - Very rough first draft


Install via composer

composer require ash-powell/apanalytics

Register Service Provider

Note! This and next step are optional if you use laravel>=5.5 with package auto discovery feature.

Add service provider to config/app.php in providers section


Register Facade

Register package facade in config/app.php in aliases section


Publish Configuration File

php artisan vendor:publish --provider="AshPowell\APAnalytics\APAnalyticsServiceProvider" --tag="config"

Publish VueJS Analytic Chart Thing... Requires Vue-ApexCharts

php artisan vendor:publish --provider="AshPowell\APAnalytics\APAnalyticsServiceProvider" --tag="views"


Extend Analytic Models our Model instead of Elequent

This will make sure the correct db connection and collection are used

use AshPowell\APAnalytics\AnalyticModel as Model;

class ViewAnalytic extends Model;

To Log events simply use the built in helper as follows:

trackEvent('collection', $items, $userId = null, $params = []),
  • Collection will get plauralised
  • Items can be models, collections, or custom (see config for model formatting)
  • UserId is who performed the action, nullable, default is logged user
  • Params is an array of extra config, nullable also


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


This package relies heavily on jenssegers/laravel-mongodb.