app-usage-stats

A convention for tracking javascript application usage

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
app-usage-stats
000.5.17 years ago8 years agoMinified + gzip package size for app-usage-stats in KB

Readme

view on npm npm module downloads Build Status Dependency Status js-standard-style

app-usage-stats

A convention for tracking javascript application usage, making full use of custom dimensions and metrics.
Example
const UsageStats = require('app-usage-stats')
const stats = new UsageStats('UA-987654321')

* [AppUsageStats](#exp_module_app-usage-stats--AppUsageStats) ⇐ <code>[UsageStats](https://github.com/75lb/usage-stats)</code> ⏏
    * [new AppUsageStats(tid, [options])](#new_module_app-usage-stats--AppUsageStats_new)
    * [.unsent](#module_app-usage-stats--AppUsageStats.AppUsageStats+unsent) : <code>Array.<object></code>
    * [.sent](#module_app-usage-stats--AppUsageStats.AppUsageStats+sent) : <code>Array.<object></code>
    * [.queuePath](#module_app-usage-stats--AppUsageStats.AppUsageStats+queuePath) : <code>string</code>
    * [.hit(dimension, metric, [options])](#module_app-usage-stats--AppUsageStats+hit)
    * [.save()](#module_app-usage-stats--AppUsageStats+save)
    * [.saveSync()](#module_app-usage-stats--AppUsageStats+saveSync)
    * [.load()](#module_app-usage-stats--AppUsageStats+load)
    * [.loadSync()](#module_app-usage-stats--AppUsageStats+loadSync)
    * [.send([options])](#module_app-usage-stats--AppUsageStats+send)

AppUsageStats ⇐ UsageStats

Kind: Exported class
Extends: UsageStats

new AppUsageStats(tid, options)

| Param | Type | Description | | --- | --- | --- | | tid | string | Google Analytics tracking ID | | options | object | | | options.dimensionMap | object | A custom dimension name to ID Map. | | options.metricMap | object | A custom metric name to ID Map. | | options.sendInterval | object | If specified, stats will be sent no more frequently than this period. |

usage.unsent : Array.<object>

Stats not yet sent.
Kind: instance property of AppUsageStats

usage.sent : Array.<object>

Stats sent.
Kind: instance property of AppUsageStats

usage.queuePath : string

Queued stats path. Defaults to ~/.usage-stats/${trackingId}-unsent.json.
Kind: instance property of AppUsageStats

usage.hit(dimension, metric, options)

Track a hit. The magic dimension name will be mapped to a GA screenView.
Kind: instance method of AppUsageStats
| Param | Type | Description | | --- | --- | --- | | dimension | Array.<object> | dimension-value maps | | metric | Array.<object> | metric-value maps | | options | object | | | options.timeout | number | A maxium wait period in ms, after which any pending requests will be aborted. | | options.send | number | Each hit will be sent. |

usage.save()

Save stats
Kind: instance method of AppUsageStats

usage.saveSync()

Save stats sync.
Kind: instance method of AppUsageStats

usage.load()

Load stats
Kind: instance method of AppUsageStats

usage.loadSync()

Loads stats sync.
Kind: instance method of AppUsageStats

usage.send(options)

Send and reset stats.
Kind: instance method of AppUsageStats
| Param | Type | Description | | --- | --- | --- | | options | object | | | options.timeout | number | A maxium wait period in ms, after which any pending requests will be aborted. |
© 2016-17 Lloyd Brookes \<75pound@gmail.com\>. Documented by jsdoc-to-markdown.