{"id":37232905,"url":"https://github.com/phpab/analytics-mongodb","last_synced_at":"2026-01-15T03:51:25.897Z","repository":{"id":57040106,"uuid":"56712600","full_name":"phpab/analytics-mongodb","owner":"phpab","description":"Store PhpAb tests participations in MongoDB","archived":false,"fork":false,"pushed_at":"2016-05-02T21:19:41.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-17T23:21:26.626Z","etag":null,"topics":[],"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/phpab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-20T18:49:43.000Z","updated_at":"2016-04-26T22:17:48.000Z","dependencies_parsed_at":"2022-08-23T23:30:38.060Z","dependency_job_id":null,"html_url":"https://github.com/phpab/analytics-mongodb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phpab/analytics-mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpab%2Fanalytics-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpab%2Fanalytics-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpab%2Fanalytics-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpab%2Fanalytics-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phpab","download_url":"https://codeload.github.com/phpab/analytics-mongodb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phpab%2Fanalytics-mongodb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28419257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2026-01-15T03:51:25.263Z","updated_at":"2026-01-15T03:51:25.887Z","avatar_url":"https://github.com/phpab.png","language":"PHP","readme":"# Analytics-MongoDB\n\nStore [PhpAb](https://github.com/phpab/phpab) tests participations in MongoDB.\n\nNote: This is compatible with MongoDB and not with the legacy Mongo library.\n\n## Install\n\nVia Composer\n\n```bash\n$ composer require phpab/analytics-mongodb\n```\n\n## Usage\n\nUsage after full PhpAB example.\n\n```php\n\nuse PhpAb\\Storage\\Cookie;\nuse PhpAb\\Participation\\Manager;\nuse PhpAb\\Analytics\\DataCollector\\Generic;\nuse PhpAb\\Event\\Dispatcher;\nuse PhpAb\\Participation\\Filter\\Percentage;\nuse PhpAb\\Variant\\Chooser\\RandomChooser;\nuse PhpAb\\Variant\\SimpleVariant;\nuse PhpAb\\Variant\\CallbackVariant;\nuse PhpAb\\Engine\\Engine;\nuse PhpAb\\Test\\Test;\n\n$storage = new Cookie('phpab');\n$manager = new Manager($storage);\n\n$analyticsData = new Generic();\n\n$dispatcher = new Dispatcher();\n$dispatcher-\u003eaddSubscriber($analyticsData);\n\n$filter = new Percentage(50);\n$chooser = new RandomChooser();\n\n$engine = new Engine($manager, $dispatcher, $filter, $chooser);\n\n$test = new Test('foo_test');\n$test-\u003eaddVariant(new SimpleVariant('_control'));\n$test-\u003eaddVariant(new CallbackVariant('v1', function () {\n    echo 'v1';\n}));\n$test-\u003eaddVariant(new CallbackVariant('v2', function () {\n    echo 'v2';\n}));\n$test-\u003eaddVariant(new CallbackVariant('v3', function () {\n    echo 'v3';\n}));\n\n// Add some tests\n$engine-\u003eaddTest($test);\n\n$engine-\u003estart();\n\n// Here starts MongoDB interaction\n\n// Provide a MongoDB Collection to be injected\n$mongoCollection = (new \\MongoDB\\Client)-\u003ephpab-\u003erun;\n\n// Inject together with Analytics Data\n$analytics = new \\PhpAb\\Analytics\\MongoDB(\n        $analyticsData-\u003egetTestsData(), $mongoCollection\n);\n\n// Store it providing a user identifier and a scenario\n// typically a URL or a controller name\n\n$result = $analytics-\u003estore('1.2.3.4-abc', 'homepage.php');\n\nvar_dump($result);\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please open an issue in the issue tracker. We realize\nthis is not ideal but it's the fastest way to get the issue solved.\n\n## Credits\n\n- [Mariano F.co Benítez Mulet](https://github.com/pachico)\n- [All Contributors](https://github.com/phpab/analytics-mongodb/graphs/contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpab%2Fanalytics-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphpab%2Fanalytics-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphpab%2Fanalytics-mongodb/lists"}