{"id":20038883,"url":"https://github.com/defra/hapi-gapi","last_synced_at":"2026-03-12T01:01:27.183Z","repository":{"id":40289769,"uuid":"238731630","full_name":"DEFRA/hapi-gapi","owner":"DEFRA","description":"Google analytics platform integration for hapi","archived":false,"fork":false,"pushed_at":"2024-08-15T10:23:09.000Z","size":855,"stargazers_count":3,"open_issues_count":15,"forks_count":2,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-05T07:41:24.391Z","etag":null,"topics":["google-analytics","hapi"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DEFRA.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-06T16:21:09.000Z","updated_at":"2024-11-23T23:52:18.000Z","dependencies_parsed_at":"2024-11-13T10:44:08.519Z","dependency_job_id":null,"html_url":"https://github.com/DEFRA/hapi-gapi","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/DEFRA/hapi-gapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-gapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-gapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-gapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-gapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEFRA","download_url":"https://codeload.github.com/DEFRA/hapi-gapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fhapi-gapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30410356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T00:40:14.898Z","status":"ssl_error","status_checked_at":"2026-03-12T00:40:08.439Z","response_time":84,"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":["google-analytics","hapi"],"created_at":"2024-11-13T10:33:46.169Z","updated_at":"2026-03-12T01:01:27.073Z","avatar_url":"https://github.com/DEFRA.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hapi-gapi\n\n[![Build Status](https://travis-ci.org/DEFRA/hapi-gapi.svg?branch=master)](https://travis-ci.org/DEFRA/hapi-gapi)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=ncloc)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=sqale_index)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_hapi-gapi\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=DEFRA_hapi-gapi)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Dependabot](https://api.dependabot.com/badges/status?host=github\u0026repo=DEFRA/hapi-gapi)](https://dependabot.com/)\n[![GitHub issues](https://img.shields.io/github/issues/DEFRA/hapi-gapi.svg)](https://github.com/DEFRA/rod-licensing/issues/)\n[![Code size](https://img.shields.io/github/languages/code-size/DEFRA/hapi-gapi.svg)]()\n[![Repo size](https://img.shields.io/github/repo-size/DEFRA/hapi-gapi.svg)]()\n[![Licence](https://img.shields.io/badge/Licence-OGLv3-blue.svg)](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)\n\nhapi google analytics platform integration - updated for GA4\n\n## Cloning\n\nCloning via SSH from behind a firewall which blocks port 22:\n\n```\ngit clone ssh://git@ssh.github.com:443/DEFRA/hapi-gapi\n```\n\n## Installing the plugin\n\n```\nnpm install --save @defra/hapi-gapi\n```\n\n## Registering the plugin with hapi\n\n```javascript\nconst Hapi = require('@hapi/hapi')\nconst HapiGapi = require('@defra/hapi-gapi')\n\nconst server = Hapi.server({\n  host: 'localhost',\n  port: 3000\n})\n\nawait server.register({\n  plugin: HapiGapi,\n  options: {\n    propertySettings: [\n      {\n        id: 'G-YYYYYYY',\n        hitTypes: ['page_view']\n      }\n    ],\n    sessionIdProducer: async request =\u003e {\n      // Would normally use the request object to retrieve the proper session identifier\n      return 'test-session'\n    }\n  }\n})\n```\n\n| Option            | Description                                                                                                                                                                                                                                       |\n| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| propertySettings  | Defines the Google Analytics properties and the type of hits which are allowed to be sent to each. If empty, analytics data is not recorded (useful if you want to enable/disable via environment variables but still want the request decorated) |\n| sessionIdProducer | A method to retrieve an identifier to differentiate each user session                                                                                                                                                                             |\n\n## How to use\n\nThis plugin decorates the request object so that you can easily send data to Google Analytics. With the migration to GA4 this package sends basic pageview data with client ids and user ids generated by the session id producer. Page views can be sent as follows:\n\n### Page views\n\n```javascript\nawait request.ga.view(request)\n```\n\n**NOTE: By default this is not necessary, the plugin will automatically send page-views by hooking into the onPreResponse lifecycle hook**\n\n\n### Events with custom params\n You can send any custom params you need:\n```javascript\nawait request.ga.view(request, {\n  name: 'score'\n  params: {\n    test: 'test',\n    page_url: request.route.url\n  }\n})\n```\n\n## Contributing to this project\n\nIf you have an idea you'd like to contribute please log an issue.\n\nAll contributions should be submitted via a pull request.\n\n## License\n\nTHIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:\n\nhttp://www.nationalarchives.gov.uk/doc/open-government-licence/version/3\n\nThe following attribution statement MUST be cited in your products and applications when using this information.\n\n\u003e Contains public sector information licensed under the Open Government license v3\n\n### About the license\n\nThe Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.\n\nIt is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fhapi-gapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefra%2Fhapi-gapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fhapi-gapi/lists"}