Skip to content

A small script to log metrics on our service as well as Mixpanel

Notifications You must be signed in to change notification settings

honeinc/metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metrics.js Build Status

Metrics.js is a simple script that will log events to Hone's server as well as Mixpanel's. It is written with some ES6 features so it needs to compiled using es6ify.

Usage

Right now it is small and will hopefully be inlined so no queueing is setup, but it can be used in sync form

<script src="/path-to/metrics.min.js"></script>

Then we need to initialize metrics with the keys using

Metrics::init

  • params
    • options { Object }
      • options.domain { String } - domain to log events to
      • options.mixpanel { String } - mixpanel api key
metrics.init( {
    domain: 'http://localhost:8000',
    mixpanel: 'FOOBARBAZQUX'
} );

To track an event

Metrics::track

  • params
    • eventName { String } - Event name
    • meta { Object } - An Object with meta data about event
metrics.track( 'foo' , { 
    bar: 'baz',
    qux: 'foo'
} );

To identify a user

Metrics::identify

  • params
    • identity { Object } - An Object with id and email of a user
      • identity.id { String } - An unique identifier
      • identity.email { String } - The users email

This fires both mixpanel.identify & mixpanel.name_tag

metrics.identify( { 
    id: 'foobar', // goes to mixpanel.identify
    email: '[email protected]' // goes to mixpanel.name_tag
} );

To register a user

Metrics::register

  • params
    • user { Object } - An Object with user information to register with mixpanel

This only fires an event to mixpanel since we should already have the user in our systems

metrics.register( { User } );

Contributing

All the the dependencies to build the script can all be installed using npm.

$ npm install

To build the script all you need to run is.

$ npm run build

If your code looks good next to make sure it is all good run

$ npm test

to test your code. You will need Firefox to run the tests inside of.

About

A small script to log metrics on our service as well as Mixpanel

Resources

Stars

Watchers

Forks

Packages

No packages published