Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi-segment-analytics

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-segment-analytics

Hapi plugin to track request and pre-response data to Segment.IO

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

hapi-segment-analytics

Hapi plugin to track request and pre-response data to Segment.IO

Table of Contents

  • Install
  • Usage
  • Contributing
  • License

Install

$ npm install hapi-segment-analytics

Segment.IO Configuration

To get started with Segment, check out their documentation

Usage

server.register({
  register: require('hapi-segment-analytics'),
  options: {
    segmentKey: 'secret',
    segmentOptions: {} // set flush props
    getToken: (request) => request.id, // custom logic
    skip: (request) => false // should track?
  }
})

getToken is a custom function used to grab some type of identifier to the end user. For example, this may be an auth token.

// Get auth token from request headers
// Example headers
// request.headers = { authorization: 'Token 123' }
const getToken = (request) => request.headers['authorization'].split(' ')[1]

skip is a custom function that skips tracking a onRequest and onPreResponse if conditions are met.

// Skip tracking requests if the admin token is present
const skip = (request) => request.headers['authorization'].split(' ')[1] === 'adminToken'

Contributing

Contributions welcome! Please read the contributing guidelines first.

License

MIT

Keywords

FAQs

Package last updated on 29 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc