{"id":17190403,"url":"https://github.com/theworkflow/hapi-segment-analytics","last_synced_at":"2025-03-25T05:53:33.284Z","repository":{"id":145706791,"uuid":"92193287","full_name":"theworkflow/hapi-segment-analytics","owner":"theworkflow","description":"Hapi plugin to track requests and pre-responses in Segment.IO","archived":false,"fork":false,"pushed_at":"2017-05-29T22:45:36.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T06:42:16.730Z","etag":null,"topics":["analytics","hapi","hapijs","plugin","request","segment"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/theworkflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-23T16:06:46.000Z","updated_at":"2017-05-26T17:26:03.000Z","dependencies_parsed_at":"2023-04-16T11:00:56.418Z","dependency_job_id":null,"html_url":"https://github.com/theworkflow/hapi-segment-analytics","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fhapi-segment-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fhapi-segment-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fhapi-segment-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theworkflow%2Fhapi-segment-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theworkflow","download_url":"https://codeload.github.com/theworkflow/hapi-segment-analytics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245407763,"owners_count":20610232,"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":["analytics","hapi","hapijs","plugin","request","segment"],"created_at":"2024-10-15T01:22:28.805Z","updated_at":"2025-03-25T05:53:33.263Z","avatar_url":"https://github.com/theworkflow.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hapi-segment-analytics\n\n\u003e Hapi plugin to track request and pre-response data to Segment.IO\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\n`$ npm install hapi-segment-analytics`\n\n## Segment.IO Configuration\n\nTo get started with Segment, check out their [documentation](https://segment.com/docs/sources/server/node/#configuration)\n\n## Usage\n\n```\nserver.register({\n  register: require('hapi-segment-analytics'),\n  options: {\n    segmentKey: 'secret',\n    segmentOptions: {} // set flush props\n    getToken: (request) =\u003e request.id, // custom logic\n    skip: (request) =\u003e false // should track?\n  }\n})\n```\n\n`getToken` is a custom function used to grab some type of identifier to the end user.\nFor example, this may be an auth token.\n\n```js\n// Get auth token from request headers\n// Example headers\n// request.headers = { authorization: 'Token 123' }\nconst getToken = (request) =\u003e request.headers['authorization'].split(' ')[1]\n```\n\n`skip` is a custom function that skips tracking a `onRequest` and `onPreResponse` if\nconditions are met.\n\n```js\n// Skip tracking requests if the admin token is present\nconst skip = (request) =\u003e request.headers['authorization'].split(' ')[1] === 'adminToken'\n```\n\n## Contributing\n\nContributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.\n\n## License\n\n[MIT](LICENSE.md)\n\n[segmentDocs]: https://segment.com/docs/sources/server/node/#configuration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheworkflow%2Fhapi-segment-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheworkflow%2Fhapi-segment-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheworkflow%2Fhapi-segment-analytics/lists"}