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

ga-server

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ga-server - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

46

lib/query.js

@@ -9,2 +9,4 @@ var request = require('request'),

Query.prototype.startDate = function(date){
if (date == null) throw new Error('date is required!');
this.params['start-date'] = util.formatDate(date);

@@ -17,2 +19,4 @@ return this;

Query.prototype.endDate = function(date){
if (date == null) throw new Error('date is required!');
this.params['end-date'] = util.formatDate(date);

@@ -25,2 +29,4 @@ return this;

Query.prototype.metrics = function(metrics){
if (metrics == null) throw new Error('metrics is required!');
if (Array.isArray(metrics)) metrics = metrics.join(',');

@@ -32,2 +38,4 @@ this.params.metrics = metrics;

Query.prototype.dimensions = function(dimensions){
if (dimensions == null) return;
if (Array.isArray(dimensions)) dimensions = dimensions.join(',');

@@ -39,2 +47,4 @@ this.params.dimensions = dimensions;

Query.prototype.sort = function(sort){
if (sort == null) return;
if (Array.isArray(sort)) sort = sort.join(',');

@@ -46,2 +56,4 @@ this.params.sort = sort;

Query.prototype.filters = function(filters){
if (filters == null) return;
if (Array.isArray(filters)) filters = filters.join(',');

@@ -53,2 +65,4 @@ this.params.filters = filters;

Query.prototype.segment = function(segment){
if (segment == null) return;
this.params.segment = segment;

@@ -59,2 +73,4 @@ return this;

Query.prototype.samplingLevel = function(level){
if (level == null) return;
this.params.samplingLevel = level;

@@ -65,3 +81,5 @@ return this;

Query.prototype.startIndex = function(index){
this.params['start-index'] = index;
if (index == null) return;
this.params['start-index'] = +index;
return this;

@@ -71,7 +89,11 @@ };

Query.prototype.skip = function(i){
return this.startIndex(i + 1);
if (i == null) return;
return this.startIndex(+i + 1);
};
Query.prototype.maxResults = function(max){
this.params['max-results'] = max;
if (max == null) return;
this.params['max-results'] = +max;
return this;

@@ -83,2 +105,4 @@ };

Query.prototype.output = function(output){
if (output !== 'json' && output !== 'dataTable') return;
this.params.output = output;

@@ -89,2 +113,4 @@ return this;

Query.prototype.fields = function(fields){
if (fields == null) return;
this.params.fields = fields;

@@ -95,3 +121,5 @@ return this;

Query.prototype.prettyPrint = function(prettyPrint){
this.params.prettyPrint = prettyPrint;
if (prettyPrint == null) return;
this.params.prettyPrint = !!prettyPrint;
return this;

@@ -101,2 +129,4 @@ };

Query.prototype.userIp = function(ip){
if (ip == null) return;
this.params.userIp = ip;

@@ -109,2 +139,4 @@ return this;

Query.prototype.quotaUser = function(quotaUser){
if (quotaUser == null) return;
this.params.quotaUser = quotaUser;

@@ -117,2 +149,6 @@ return this;

if (params['start-date'] == null) throw new Error('start date is required!');
if (params['end-date'] == null) throw new Error('end date is required!');
if (params.metrics == null) throw new Error('metrics is required!');
this._getToken(function(err, token){

@@ -166,3 +202,3 @@ if (err) return callback(err);

var data = JSON.parse(body);
if (res.statusCode !== 200) return callback(new Error(data));
if (res.statusCode !== 200) return callback(util.formatError(data.error));

@@ -169,0 +205,0 @@ token.value = data.access_token;

@@ -50,2 +50,9 @@ var crypto = require('crypto');

return str;
};
exports.formatError = function(data){
var err = new Error(data.message + ' (Code: ' + data.code + ')');
err.code = data.code;
return err;
};

4

package.json
{
"name": "ga-server",
"version": "0.0.1",
"description": "Google Analytics server application",
"version": "0.0.2",
"description": "Google Analytics API for Node.js.",
"main": "lib/ga",

@@ -6,0 +6,0 @@ "scripts": {

@@ -1,1 +0,77 @@

# Google Analytics Server Application
# Google Analytics API
[![NPM version](https://badge.fury.io/js/ga-server.svg)](http://badge.fury.io/js/ga-server)
Google Analytics API for Node.js.
## Installation
``` bash
$ npm install ga-server
```
## Usage
Create a new instance.
``` js
var GoogleAnalytics = require('ga-server');
var ga = new GoogleAnalytics({
id: '',
clientEmail: '',
privateKey: ''
});
```
## API
See [here](https://developers.google.com/analytics/devguides/reporting/core/v3/reference#q_summary) for more info.
### startDate(date)
**Alias:** start
### endDate(date)
**Alias:** end
### metrics(metrics)
### dimensions(dimensions)
### sort(sort)
### filter(filters)
### segment(segment)
### samplingLevel(level)
### startIndex(index)
### skip(index)
This is an alias for `startIndex(i + 1)`.
### maxResults(max)
**Alias:** limit
### output(output)
### fields(fields)
### prettyPrint(prettyPrint)
### userIp(ip)
**Alias:** ip
### quotaUser(quotaUser)
### exec(callback)
## License
MIT
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