Skip to content

40Digits/CLI-Analytics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI Analytics

CLI Analytics is intended to allow quick integration from the cli into analytic interfaces. Starting with version 0.0.1, CLI Analytics interfaces with Google Analytics.

Google Analytics Setup

When CLI Analytics is instantiated, it maps the Universal Analytics object to the track object with options sent in through the constructor. Below is an example of how to utilize Universal Analytics.

const analytics= require('cli-analytics')(tracking_id, options);
analytics.track.event(...)
analytics.track.pageview(...)
analytics.track.timing(...)

Getting Started

Quick Start

Universal Analytics Default Implementation:

const analytics = require('cli-analytics')(tracking_id, options);
analytics.track.event('Category', 'Action', 'Label', 'Value').send();

CLI Analytics Specific Methods

  • startTimer(name) - Instantiates a timer

  • getTimeDiff(name) - Returns the elapsed time of a specific timer in milliseconds.

Examples

Timeout Example, Display elapsed time after waiting 1 second
analytics.startTimer('timeout');
setTimeout(() => {
  console.log(analytics.getTimeDiff('timeout'));
}, 1000);
Normal Use Case Example, Get the time difference for the user selection.
analytics.startTimer('user-selection');
// ... User Selects Options ...
const timing = analytics.getTimeDiff('user-selection');
analytics.track.timing('User Selection', 'Panel 1', timing).send()

About

CLI Analytics is intended to allow quick integration from the cli into analytic interfaces.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published