{"id":15046384,"url":"https://github.com/tattersoftware/codeigniter4-visits","last_synced_at":"2025-04-06T22:07:05.852Z","repository":{"id":34345921,"uuid":"176952474","full_name":"tattersoftware/codeigniter4-visits","owner":"tattersoftware","description":"Lightweight traffic tracking for CodeIgniter 4","archived":false,"fork":false,"pushed_at":"2024-11-21T06:46:18.000Z","size":150,"stargazers_count":29,"open_issues_count":1,"forks_count":10,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-03-30T20:11:52.267Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/tattersoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-21T13:41:23.000Z","updated_at":"2025-02-05T05:56:52.000Z","dependencies_parsed_at":"2024-02-03T14:29:23.364Z","dependency_job_id":"e1bbe9e7-2f5e-468f-a22d-1385be70b281","html_url":"https://github.com/tattersoftware/codeigniter4-visits","commit_stats":{"total_commits":75,"total_committers":4,"mean_commits":18.75,"dds":0.24,"last_synced_commit":"78b63cbede1258bda1aaa97b28b04601bd4a491e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-visits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-visits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-visits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tattersoftware%2Fcodeigniter4-visits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tattersoftware","download_url":"https://codeload.github.com/tattersoftware/codeigniter4-visits/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517882,"owners_count":20951713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-09-24T20:53:03.182Z","updated_at":"2025-04-06T22:07:05.823Z","avatar_url":"https://github.com/tattersoftware.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tatter\\Visits\nLightweight traffic tracking for CodeIgniter 4\n\n[![](https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPUnit/badge.svg)](https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/phpunit.yml)\n[![](https://github.com/tattersoftware/codeigniter4-visits/workflows/PHPStan/badge.svg)](https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/phpstan.yml)\n[![](https://github.com/tattersoftware/codeigniter4-visits/workflows/Deptrac/badge.svg)](https://github.com/tattersoftware/codeigniter4-visits/actions/workflows/deptrac.yml)\n[![Coverage Status](https://coveralls.io/repos/github/tattersoftware/codeigniter4-visits/badge.svg?branch=develop)](https://coveralls.io/github/tattersoftware/codeigniter4-visits?branch=develop)\n\n## Quick Start\n\n1. Install with Composer: `\u003e composer require tatter/visits`\n2. Update the database: `\u003e php spark migrate --all`\n3. Apply the `visits` filter in **app/Config/Filters.php**:\n```php\nclass Filters extends BaseConfig\n{\n    public $globals = [\n        'after' =\u003e ['visits'],\n    ];\n...\n```\n\n## Features\n\nProvides automated traffic tracking for CodeIgniter 4\n\n## Installation\n\nInstall easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities\nand always be up-to-date:\n```shell\n\u003e composer require tatter/visits\n```\n\nOr, install manually by downloading the source files and adding the directory to\n**app/Config/Autoload.php**.\n\nOnce the files are downloaded and included in the autoload, run any library migrations\nto ensure the database is set up correctly:\n```shell\n\u003e php spark migrate --all\n```\n\n## Configuration (optional)\n\nThe library's default behavior can be altered by extending its config file. Copy\n**examples/Visits.php** to **app/Config/** and follow the instructions in the\ncomments. If no config file is found in **app/Config/** the library will use its own.\n\n### Customization\n\nThe config file allows for some basic control over what gets counted as a \"hit\".\n* `$ignoreAjax`: Whether to ignore AJAX requests when recording\n\nFiltering by AJAX requests is not a guaranteed business; read more in the [User Guide](https://www.codeigniter.com/user_guide/general/ajax.html).\n\nIf you are using the `after` filter method it is also possible to adjust some behaviors based\non the application's Response instance:\n* `$ignoreRedirects`: Whether to ignore requests that result in a redirect response\n* `$requireBody`: Whether to ignore requests that result in an empty body\n* `$requireHtml`: Whether to ignore requests with Content Types other than HTML\n\n## Usage\n\nThe main function of this library is applied through a [Controller Filter](https://codeigniter4.github.io/CodeIgniter4/incoming/filters.html).\nThe `VisitsFilter` is pre-aliased for you as `visits` but needs to be applied to whichever\nroutes you would like to track. Read the User Guide for more details, but in most cases\napplying the filter globally will be the best fit:\n```php\n// app/Config/Filters.php\n\nclass Filters extends BaseConfig\n{\n    public $globals = [\n        'before' =\u003e [\n            'csrf',\n        ],\n        'after' =\u003e [\n            'visits',\n        ],\n    ];\n\n    // ...\n}\n```\n\nThe filter can be applied to either `before` or `after` methods, with the following expectations:\n* `before` filtering is likely to record more nuances in traffic (such as page loads before an error occurs) but they are less customizable\n* `after` filtering allows for finer control over what counts as a \"hit\" but may miss some instances captured by `before`\n\nApplying both `before` and `after` will duplicate your traffic information and should not be done.\n\n## Accessing data\n\nThis library provides a `VisitModel` and a `Visit` entity for convenient access to recorded\nentries. Feel free to extend these classes for any additional functionality.\n\n## Transformers\n\nBefore a visit is assessed for similar and recorded it may be passed through any number of\ntransformations. A transformer is a class that implements `Tatter\\Visits\\Interfaces\\Transformer`\nand has the single static method for applying a transformation:\n\n```php\npublic static function transform(Visit $visit, IncomingRequest $request): ?Visit;\n```\n\nTransformers work on the `Visit` class they are passed, and return either the modified\n`Visit` instance or `null` to indicate \"don't record this visit\" and halt operation. If\na modified `Visit` is returned it will be passed into the next Transformer and so on.\n\nTo active Transformers and set their order simply add them to the `$transformers` property\nof the config file:\n```php\nuse App\\Transformers\\AnonymousTransformer;\n\nclass Visits extends BaseConfig\n{\n    public array $transformers = [\n        AnonymousTransformer::class,\n    ];\n}\n```\n\n## User tracking\n\n**Visits** will use any Composer package that provides `codeigniter4/authentication-implementation`\nto identify an active user. It is not legal nor advisable to track user traffic in all cases,\nso make sure you are configuring your project appropriately for local laws and regulations.\nFiltering and anonymizing data to meet tighter specifications can be accomplished with Transformers.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattersoftware%2Fcodeigniter4-visits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftattersoftware%2Fcodeigniter4-visits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattersoftware%2Fcodeigniter4-visits/lists"}