2.1.0 • Published 6 years ago

uttori-analytics-provider-json-file v2.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

view on npm npm module downloads Build Status Dependency Status Coverage Status

Uttori Analytics Provider - JSON File

Uttori analytics provider using JSON files on disk.

Install

npm install --save uttori-analytics-provider-json-file

Config

{
  directory: '',
  name: 'visits',
  extension: 'json',
}

API Reference

AnalyticsProvider

Page view analytics for Uttori documents using JSON files stored on the local file system.

Kind: global class
Properties

NameTypeDescription
configObjectThe configuration object.

new AnalyticsProvider(config)

Creates an instance of AnalyticsProvider.

ParamTypeDescription
configObjectA configuration object.
config.directorystringThe directory to store the JSON file containing the page view analytics.
config.namestringThe file name of the file containing the page view analytics.
config.paramstringThe file extension of the file containing the page view analytics.

Example (Init AnalyticsProvider)

const analyticsProvider = new AnalyticsProvider({ directory: 'data' });

analyticsProvider.update(slug)

Updates the view count for a given document slug.

Kind: instance method of AnalyticsProvider

ParamTypeDescription
slugstringThe slug ofthe document to be updated.

Example

analyticsProvider.update('faq');

analyticsProvider.get(slug) ⇒ Number

Returns the view count for a given document slug.

Kind: instance method of AnalyticsProvider
Returns: Number - View count for the given slug.

ParamTypeDescription
slugstringThe slug of the document to be looked up.

Example

analyticsProvider.get('faq');
➜ 10

analyticsProvider.getPopularDocuments(limit) ⇒ Array

Returns the most popular documents.

Kind: instance method of AnalyticsProvider
Returns: Array - View count for the given slug.

ParamTypeDescription
limitlimitThe number of documents to return.

Example

analyticsProvider.getPopularDocuments(10);
➜ [ { 'faq': 10 } ]

Tests

To run the test suite, first install the dependencies, then run npm test:

npm install
npm test
DEBUG=Uttori* npm test

Contributors

License

2.1.0

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago