{"id":20374957,"url":"https://github.com/michaelnabil230/laravel-analytics","last_synced_at":"2026-01-25T09:36:27.251Z","repository":{"id":41570200,"uuid":"487578192","full_name":"michaelnabil230/laravel-analytics","owner":"michaelnabil230","description":"A Laravel package to retrieve pageviews and other data from Database","archived":false,"fork":false,"pushed_at":"2023-10-09T07:10:34.000Z","size":114,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T07:17:31.622Z","etag":null,"topics":["data-analysis","data-structures","database","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelnabil230.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-01T15:53:19.000Z","updated_at":"2022-10-27T08:26:27.000Z","dependencies_parsed_at":"2024-11-15T05:16:29.785Z","dependency_job_id":null,"html_url":"https://github.com/michaelnabil230/laravel-analytics","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":0.28,"last_synced_commit":"d79a8000f5c714f9ee3b97ee2d32a35aa883e49b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/michaelnabil230/laravel-analytics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelnabil230%2Flaravel-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelnabil230%2Flaravel-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelnabil230%2Flaravel-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelnabil230%2Flaravel-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelnabil230","download_url":"https://codeload.github.com/michaelnabil230/laravel-analytics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelnabil230%2Flaravel-analytics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28750875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T09:00:19.176Z","status":"ssl_error","status_checked_at":"2026-01-25T09:00:04.131Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-analysis","data-structures","database","laravel","php"],"created_at":"2024-11-15T01:28:05.235Z","updated_at":"2026-01-25T09:36:27.238Z","avatar_url":"https://github.com/michaelnabil230.png","language":"PHP","funding_links":["https://www.buymeacoffee.com/michaelnabil230","https://ko-fi.com/michaelnabil230"],"categories":[],"sub_categories":[],"readme":"\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/support-ukraine.svg?t=1\" /\u003e](https://supportukrainenow.org)\n\n# This is my package laravel-analytics\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/michaelnabil230/laravel-analytics.svg?style=flat-square)](https://packagist.org/packages/michaelnabil230/laravel-analytics)\n[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/michaelnabil230/laravel-analytics/run-tests?label=tests)](https://github.com/michaelnabil230/laravel-analytics/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/michaelnabil230/laravel-analytics/Check%20\u0026%20fix%20styling?label=code%20style)](https://github.com/michaelnabil230/laravel-analytics/actions?query=workflow%3A\"Check+%26+fix+styling\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/michaelnabil230/laravel-analytics.svg?style=flat-square)](https://packagist.org/packages/michaelnabil230/laravel-analytics)\n\nThis is where your description should go. Limit it to a paragraph or two. Consider adding a small example.\n\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require michaelnabil230/laravel-analytics\n```\n\nYou can publish and run the migrations with:\n\n```bash\nphp artisan vendor:publish --tag=\"laravel-analytics-migrations\"\nphp artisan migrate\n```\n\nYou can publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"laravel-analytics-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n\n    'ip_model' =\u003e Ip::class,\n    'session_visiter_model' =\u003e SessionVisiter::class,\n    'visiter_model' =\u003e Visiter::class,\n\n    /*\n     * Which route paths are not trackable?\n     */\n    'ignore_paths' =\u003e [\n        // 'api/*',\n    ],\n\n    /*\n     * The Do Not Track Ips is used to disable Analytics for some IP addresses:\n     *\n     *     '127.0.0.1', '192.168.1.1'\n     *\n     * You can set ranges of IPs\n     *     '192.168.0.1-192.168.0.100'\n     *\n     * And use net masks\n     *      127.0.0.0/24 -\u003e range  127.0.0.1 - 127.0.0.255\n     *     '172.17.0.0/255.255.0.0'\n     */\n    'do_not_track_ips' =\u003e [\n        '127.0.0.2',\n    ],\n\n    /*\n    |--------------------------------------------------------------------------\n    | Drivers GeoIp\n    |--------------------------------------------------------------------------\n    |\n    | Should the geoip data be collected?\n    |\n    | Set the geoip driver.\n    |\n    | Supported: \"free_geo_ip\", \"ip_stack\"\n    */\n    'geo_ip' =\u003e [\n        'enabled' =\u003e true,\n        'default' =\u003e 'free_geo_ip',\n        'drivers' =\u003e [\n            'ip_stack' =\u003e [\n                'driver' =\u003e MichaelNabil230\\LaravelAnalytics\\GeoIp\\IpStack::class,\n                'options' =\u003e [\n                    'api_key' =\u003e '',\n                    'headers' =\u003e [\n                        // 'X-First' =\u003e 'foo',\n                    ],\n                ],\n            ],\n            'free_geo_ip' =\u003e [\n                'driver' =\u003e MichaelNabil230\\LaravelAnalytics\\GeoIp\\FreeGeoIp::class,\n                'options' =\u003e [\n                    'headers' =\u003e [\n                        // 'X-First' =\u003e 'foo',\n                    ],\n                ],\n            ],\n        ],\n    ],\n\n    /*\n     * All bot if you want defected one.\n     */\n    'bot_browsers' =\u003e [\n        'curl',\n        'python-requests',\n        'python-urllib',\n        'wget',\n        'unk',\n        'perl',\n        'go-http-client',\n    ],\n\n    /*\n     * Laravel internal variables on user authentication and login.\n     */\n    'authentication' =\u003e [\n        'guards' =\u003e [], // defaults to ['web']\n    ],\n];\n```\n\n### Register Middleware\n\nYou may register the package middleware in the `app/Http/Kernel.php` file:\n\n```php\n\u003c?php \n\nnamespace App\\Http;\n\nuse Illuminate\\Foundation\\Http\\Kernel as HttpKernel;\n\nclass Kernel extends HttpKernel {\n    /**\n    * The application's route middleware.\n    *\n    * @var array\n    */\n    protected $routeMiddleware = [\n        /**** OTHER MIDDLEWARE ****/\n        'analytics' =\u003e \\MichaelNabil230\\LaravelAnalytics\\Middleware\\Analytics::class,\n    ];\n}\n```\n\n\nYou can add the page view middleware to a specific route group, e.g. `web.php` like so:\n\n\n```php\nRoute::middleware('analytics')-\u003egroup(function () {\n    // ...\n});\n```\n\nThen you can pass `typeRequest` in your routes and default is `web-request` using middleware: \n\n```php\nRoute::middleware('analytics:api-request')-\u003egroup(function () {\n    // ...\n});\n```\n\n## Usage\n\n```php\n\nuse Illuminate\\Support\\Carbon;\nuse MichaelNabil230\\LaravelAnalytics\\LaravelAnalyticQueries;\n\n$topEvents = LaravelAnalyticQueries::topVisiterEvent()\n        // -\u003ewhere('event', 'test event')\n        // -\u003eis('bots')\n        // -\u003eis('ajax', false)\n        // -\u003euniqueSession()\n        // -\u003euniqueIp()\n        // -\u003ewith(['data'])\n        // -\u003etake(10)\n        // -\u003eselect('id') // Is very important: Don't use `select` here pass what u need in `topVisiterEvent`\n        // -\u003eaddSelect([DB::raw(\"COUNT(*) as 'count'\")])\n        -\u003eperiod(Carbon::now(), Carbon::now()-\u003eaddDays(7))\n        -\u003elimit(10)\n        -\u003eget();\n```\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Support\n\u003cp\u003e\n    \u003ca href=\"https://www.buymeacoffee.com/michaelnabil230\"\u003e \n         \u003cimg align=\"left\" src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" height=\"50\" width=\"210\" alt=\"michaelnabil230\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://ko-fi.com/michaelnabil230\"\u003e \n        \u003cimg align=\"left\" src=\"https://cdn.ko-fi.com/cdn/kofi3.png?v=3\" height=\"50\" width=\"210\" alt=\"michaelnabil230\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\u003cbr\u003e\u003cbr\u003e\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Michael Nabil](https://github.com/michaelnabil230)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelnabil230%2Flaravel-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelnabil230%2Flaravel-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelnabil230%2Flaravel-analytics/lists"}